From 2ec630fdbf9c9ca691c95d773b33c34584cdde8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Steinh=C3=BCbl?= Date: Wed, 7 Aug 2024 22:46:13 +0200 Subject: [PATCH 1/7] feat: goog --- README.md | 4 +++- common/.gitignore | 1 + common/dump.py | 2 ++ common/sync.py | 2 ++ goog | 28 ++++++++++++++++++++++++++++ 5 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 common/.gitignore create mode 100644 common/dump.py create mode 100644 common/sync.py create mode 100755 goog diff --git a/README.md b/README.md index b6ff77e..00ba2b6 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -This repository contains my configs, themes and other stuff that I'm using on void linux. +# Void Linux Configuration + +My configuration files, themes and other stuff I daily use on my machine. diff --git a/common/.gitignore b/common/.gitignore new file mode 100644 index 0000000..bee8a64 --- /dev/null +++ b/common/.gitignore @@ -0,0 +1 @@ +__pycache__ diff --git a/common/dump.py b/common/dump.py new file mode 100644 index 0000000..b80b22c --- /dev/null +++ b/common/dump.py @@ -0,0 +1,2 @@ +def dump(): + exit(1) diff --git a/common/sync.py b/common/sync.py new file mode 100644 index 0000000..033cc64 --- /dev/null +++ b/common/sync.py @@ -0,0 +1,2 @@ +def sync(): + exit(1) diff --git a/goog b/goog new file mode 100755 index 0000000..8347d70 --- /dev/null +++ b/goog @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 + +from getopt import getopt +import sys + +from common.dump import dump +from common.sync import sync + +stuff = { + "~/.config/{kitty,nvim,openbox,pipewire,tint2,zed}", + "~/.themes", + "~/.local/bin/{yarn}" +} + +options, _ = getopt(sys.argv[1:], "ds", ["dump", "sync"]) + +for option, _ in options: + if option in ("-d", "--dump"): + dump(stuff) + break + + if option in ("-s", "--sync"): + sync(stuff) + break + +print("Usage: ./goog [-d | --dump] [-s | --sync]\n") +print("A simple tool for dumping dotfiles and syncing them") +exit(1) From 67a6b1ec42cca52c41c4ef83661e0e6877f30c40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Steinh=C3=BCbl?= Date: Thu, 8 Aug 2024 12:28:10 +0200 Subject: [PATCH 2/7] feat: dump --- common/dump.py | 18 +++++++++++++++++- common/sync.py | 2 +- common/util.py | 15 +++++++++++++++ goog | 13 ++++++++----- 4 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 common/util.py diff --git a/common/dump.py b/common/dump.py index b80b22c..c63e8e0 100644 --- a/common/dump.py +++ b/common/dump.py @@ -1,2 +1,18 @@ -def dump(): +from glob import glob +from os.path import expanduser, isdir +from os import mkdir +from shutil import copy2 +import shutil + +def dump(stuff: list[str]): + for pattern in stuff: + expand = expanduser(pattern) + + for path in glob(expand, recursive=True): + normalized_path = path.removeprefix(expanduser("~/")) + if isdir(normalized_path): + mkdir(normalized_path) + else: + shutil.copy2(path, normalized_path) + exit(1) diff --git a/common/sync.py b/common/sync.py index 033cc64..85dd0dc 100644 --- a/common/sync.py +++ b/common/sync.py @@ -1,2 +1,2 @@ -def sync(): +def sync(stuff: list[str]): exit(1) diff --git a/common/util.py b/common/util.py new file mode 100644 index 0000000..df81fa5 --- /dev/null +++ b/common/util.py @@ -0,0 +1,15 @@ +import re + +def expand(pattern: str) -> list[str]: + match = re.search(r'\{([^{}]*)\}', pattern) + if not match: + return [pattern] + + pre, post = pattern[:match.start()], pattern[match.end():] + options = match.group(1).split(',') + + expanded_patterns = [] + for option in options: + expanded_patterns.extend(expand(pre + option + post)) + + return expanded_patterns diff --git a/goog b/goog index 8347d70..6e3a70b 100755 --- a/goog +++ b/goog @@ -5,12 +5,15 @@ import sys from common.dump import dump from common.sync import sync +from common.util import expand -stuff = { - "~/.config/{kitty,nvim,openbox,pipewire,tint2,zed}", - "~/.themes", - "~/.local/bin/{yarn}" -} +stuff: list[str] = [ + *expand("~/.config/{kitty,nvim,openbox,pipewire,tint2,zed}/**"), + "~/.themes/**", + *expand("~/.local/bin/{yarn}"), + "~/.bashrc", + "~/.xbindkeysrc" +] options, _ = getopt(sys.argv[1:], "ds", ["dump", "sync"]) From 9592196853e799af9ba9a1d1e4c74f7827e5d321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Steinh=C3=BCbl?= Date: Thu, 8 Aug 2024 12:31:06 +0200 Subject: [PATCH 3/7] feat: dump --- .bashrc | 3 +++ .config/nvim/after/plugin/presence.lua | 2 +- .config/nvim/lua/hyrik/packer.lua | 3 ++- .config/nvim/plugin/packer_compiled.lua | 7 ++++++- .config/openbox/autostart | 2 +- .config/openbox/menu.xml | 5 ++++- .../pipewire.conf.d/20-disable-auto-grain.conf | 1 + common/dump.py | 14 ++++++-------- 8 files changed, 24 insertions(+), 13 deletions(-) diff --git a/.bashrc b/.bashrc index 9a69d7d..611c1ae 100644 --- a/.bashrc +++ b/.bashrc @@ -41,3 +41,6 @@ rbenv() { export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +# moon +export PATH="$HOME/.moon/bin:$PATH" diff --git a/.config/nvim/after/plugin/presence.lua b/.config/nvim/after/plugin/presence.lua index 64dac6c..f46b0d2 100644 --- a/.config/nvim/after/plugin/presence.lua +++ b/.config/nvim/after/plugin/presence.lua @@ -3,7 +3,7 @@ require("presence").setup({ neovim_image_text = "Neovim", -- Text displayed when hovered over the Neovim image main_image = "neovim", -- Main image display (either "neovim" or "file") client_id = "793271441293967371", -- Use your own Discord application client id (not recommended) - log_level = nil, -- Log messages at or above this level (one of the following: "debug", "info", "warn", "error") + log_level = "debug", -- Log messages at or above this level (one of the following: "debug", "info", "warn", "error") debounce_timeout = 10, -- Number of seconds to debounce events (or calls to `:lua package.loaded.presence:update(, true)`) enable_line_number = false, -- Displays the current line number instead of the current project blacklist = {}, -- A list of strings or Lua patterns that disable Rich Presence if the current file name, path, or workspace matches diff --git a/.config/nvim/lua/hyrik/packer.lua b/.config/nvim/lua/hyrik/packer.lua index 59f3184..0ee4157 100644 --- a/.config/nvim/lua/hyrik/packer.lua +++ b/.config/nvim/lua/hyrik/packer.lua @@ -24,8 +24,9 @@ return require("packer").startup(function(use) use "theprimeagen/harpoon" use "mbbill/undotree" use "tpope/vim-fugitive" - use "andweeb/presence.nvim" + use "jiriks74/presence.nvim" use "wakatime/vim-wakatime" + use "github/copilot.vim" use { 'nvim-lualine/lualine.nvim', diff --git a/.config/nvim/plugin/packer_compiled.lua b/.config/nvim/plugin/packer_compiled.lua index 8ee5ac5..464baf0 100644 --- a/.config/nvim/plugin/packer_compiled.lua +++ b/.config/nvim/plugin/packer_compiled.lua @@ -89,6 +89,11 @@ _G.packer_plugins = { path = "/home/hyro/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", url = "https://github.com/hrsh7th/cmp-nvim-lsp" }, + ["copilot.vim"] = { + loaded = true, + path = "/home/hyro/.local/share/nvim/site/pack/packer/start/copilot.vim", + url = "https://github.com/github/copilot.vim" + }, harpoon = { loaded = true, path = "/home/hyro/.local/share/nvim/site/pack/packer/start/harpoon", @@ -153,7 +158,7 @@ _G.packer_plugins = { ["presence.nvim"] = { loaded = true, path = "/home/hyro/.local/share/nvim/site/pack/packer/start/presence.nvim", - url = "https://github.com/andweeb/presence.nvim" + url = "https://github.com/jiriks74/presence.nvim" }, ["telescope.nvim"] = { loaded = true, diff --git a/.config/openbox/autostart b/.config/openbox/autostart index 5df2fa7..aa1ae79 100644 --- a/.config/openbox/autostart +++ b/.config/openbox/autostart @@ -1,6 +1,6 @@ tint2 & xcompmgr & -nitrogen --restore +xwallpaper --zoom ~/Pictures/Th0q7eQ.jpg xrandr --output eDP-1 --auto --output HDMI-1 --mode 1920x1080 --rate 144 --primary --left-of eDP-1 xbindkeys xinput --set-prop "pointer:Razer Razer DeathAdder Essential" "libinput Accel Speed" -0.85 diff --git a/.config/openbox/menu.xml b/.config/openbox/menu.xml index ace353f..541a249 100644 --- a/.config/openbox/menu.xml +++ b/.config/openbox/menu.xml @@ -12,9 +12,12 @@ - + idea + + zed + diff --git a/.config/pipewire/pipewire.conf.d/20-disable-auto-grain.conf b/.config/pipewire/pipewire.conf.d/20-disable-auto-grain.conf index 1dd9b3b..abecc93 100644 --- a/.config/pipewire/pipewire.conf.d/20-disable-auto-grain.conf +++ b/.config/pipewire/pipewire.conf.d/20-disable-auto-grain.conf @@ -5,6 +5,7 @@ pulse.rules = [ # Disable mic auto gain for some applications matches = [ { application.process.binary = "chrome" } + { application.process.binary = "chromium" } { application.process.binary = "Discord" } { application.process.binary = "teams" } { application.process.binary = "skypeforlinux" } diff --git a/common/dump.py b/common/dump.py index c63e8e0..f679f91 100644 --- a/common/dump.py +++ b/common/dump.py @@ -1,18 +1,16 @@ from glob import glob -from os.path import expanduser, isdir -from os import mkdir -from shutil import copy2 import shutil +import os def dump(stuff: list[str]): for pattern in stuff: - expand = expanduser(pattern) + expand = os.path.expanduser(pattern) for path in glob(expand, recursive=True): - normalized_path = path.removeprefix(expanduser("~/")) - if isdir(normalized_path): - mkdir(normalized_path) - else: + normalized_path = path.removeprefix(os.path.expanduser("~/")) + if os.path.isdir(normalized_path) and not os.path.exists(normalized_path): + os.mkdir(normalized_path) + elif os.path.isfile(normalized_path): shutil.copy2(path, normalized_path) exit(1) From fb76f298577c809358bc3442f77ee186cc65789a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Steinh=C3=BCbl?= Date: Thu, 8 Aug 2024 12:42:31 +0200 Subject: [PATCH 4/7] fix: dump handle dirnames, existing dirs --- .config/zed/settings.json | 56 +++++++++++++++++++++++++++++++++++++++ .local/bin/yarn | 8 ++++++ common/dump.py | 13 ++++++--- goog | 1 + 4 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 .config/zed/settings.json create mode 100755 .local/bin/yarn diff --git a/.config/zed/settings.json b/.config/zed/settings.json new file mode 100644 index 0000000..2f969c1 --- /dev/null +++ b/.config/zed/settings.json @@ -0,0 +1,56 @@ +// Zed settings +// +// For information on how to configure Zed, see the Zed +// documentation: https://zed.dev/docs/configuring-zed +// +// To see all of Zed's default settings without changing your +// custom settings, run the `open default settings` command +// from the command palette or from `Zed` application menu. +{ + "theme": "One Dark", + "ui_font_size": 15, + "buffer_font_size": 14, + // Mine + "format_on_save": "on", + "terminal": { + "font_family": "DejaVuSansM Nerd Font", + "line_height": "standard", + "font_size": 15 + }, + "project_panel": { + "default_width": 320 + }, + // ruby + "lsp": { + "solargraph": { + "initialization_options": { + "diagnostics": true, + "formatting": false + } + } + } + // The following settings have been changed from the upstream defaults to + // improve security and privacy. Here are the upstream defaults, you can + // uncomment them if you like. + // + // "features": { + // // Enable copilot (provided by an online service). + // "copilot": true, + // "inline_completion_provider": "copilot" + // }, + // "assistant": { + // "version": "1", + // // Enable the assistant (provided by an online service). + // "enabled": true + // }, + // "telemetry": { + // // Send debug info like crash reports to Zed Industries. + // "diagnostics": true, + // // Send anonymized usage data like what languages you're using Zed with + // // to Zed Industries. + // "metrics": true + // }, + // "journal": { + // "hour_format": "hour12" + // } +} diff --git a/.local/bin/yarn b/.local/bin/yarn new file mode 100755 index 0000000..9c24903 --- /dev/null +++ b/.local/bin/yarn @@ -0,0 +1,8 @@ +#!/bin/bash + +if [[ $1 == "build" ]]; then + bun run $@ + exit +fi + +bun $@ diff --git a/common/dump.py b/common/dump.py index f679f91..c7deb22 100644 --- a/common/dump.py +++ b/common/dump.py @@ -8,9 +8,16 @@ def dump(stuff: list[str]): for path in glob(expand, recursive=True): normalized_path = path.removeprefix(os.path.expanduser("~/")) - if os.path.isdir(normalized_path) and not os.path.exists(normalized_path): - os.mkdir(normalized_path) - elif os.path.isfile(normalized_path): + if os.path.isdir(path): + if os.path.exists(normalized_path): + shutil.rmtree(normalized_path) + + os.makedirs(normalized_path) + else: + dirname = os.path.dirname(normalized_path) + if dirname: + os.makedirs(dirname, exist_ok=True) + shutil.copy2(path, normalized_path) exit(1) diff --git a/goog b/goog index 6e3a70b..7663c7a 100755 --- a/goog +++ b/goog @@ -9,6 +9,7 @@ from common.util import expand stuff: list[str] = [ *expand("~/.config/{kitty,nvim,openbox,pipewire,tint2,zed}/**"), + "~/.config/starship.toml", "~/.themes/**", *expand("~/.local/bin/{yarn}"), "~/.bashrc", From 5c9f8b7ca467bce510d903f9a72bbcc40529e0b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Steinh=C3=BCbl?= Date: Thu, 8 Aug 2024 12:45:37 +0200 Subject: [PATCH 5/7] docs: how to synchronize section --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 00ba2b6..b087399 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ # Void Linux Configuration My configuration files, themes and other stuff I daily use on my machine. + +### How to synchronize? + +You can use [goog](./goog) for automatic synchronization. Option `-s` forces goog to copy all dotfiles into directories. + +```sh +$ ./goog -s +``` From 05c1191be29c78454c3487999cad4ffa5e834741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Steinh=C3=BCbl?= Date: Thu, 8 Aug 2024 13:01:33 +0200 Subject: [PATCH 6/7] feat: goog sync --- common/sync.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/common/sync.py b/common/sync.py index 85dd0dc..40119d1 100644 --- a/common/sync.py +++ b/common/sync.py @@ -1,2 +1,31 @@ +from glob import glob +import shutil +import os + def sync(stuff: list[str]): + for pattern in stuff: + normalized_pattern = pattern.removeprefix("~") + normalized_pattern = normalized_pattern.removeprefix("/") + pattern_prefix = pattern[:2] if pattern.startswith("~") else pattern[0] + overwrite = False + + for path in glob(normalized_pattern, recursive=True): + + system_path = os.path.expanduser(pattern_prefix + path) + if os.path.isdir(path): + os.makedirs(system_path, exist_ok=True) + else: + print(f"Copying {path} to {system_path}") + if os.path.exists(system_path) and not overwrite: + print(f"Path {system_path} already exists. Do you want to overwrite it with {path}? y/n/a") + + ask = input() + if ask not in ("y", "a"): + continue + + overwrite = ask == "a" + + shutil.copy2(path, system_path) + + exit(1) From 75d9369452cac0ec2a1f2009d6dcde1846049dfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Steinh=C3=BCbl?= Date: Thu, 8 Aug 2024 14:47:58 +0200 Subject: [PATCH 7/7] feat: logging --- common/sync.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/sync.py b/common/sync.py index 40119d1..e69c7bc 100644 --- a/common/sync.py +++ b/common/sync.py @@ -15,9 +15,9 @@ def sync(stuff: list[str]): if os.path.isdir(path): os.makedirs(system_path, exist_ok=True) else: - print(f"Copying {path} to {system_path}") + print(f":: Copying {path} to {system_path}") if os.path.exists(system_path) and not overwrite: - print(f"Path {system_path} already exists. Do you want to overwrite it with {path}? y/n/a") + print(f":: Path {system_path} already exists. Do you want to overwrite it with {path}? y/n/a") ask = input() if ask not in ("y", "a"):