From 1e02be0a391d6cbfc2bccfafb849fa18ba3d4aa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20B=C3=BCchler?= Date: Fri, 8 Aug 2025 17:06:36 +0200 Subject: [PATCH] refactor: symlinks script now only links files (not directories), traverses recursively, and ensures target dirs are not symlinks; remove custom wlogout config and device-specific repo symlinks for maintainability MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Only files are symlinked, not directories - Symlinks are created in target config dirs, not inside repo - Target dirs are checked and cleaned if symlinks - Removes wlogout config and device-specific repo symlinks - Updates .zshrc and wp-vol for robustness 🤖 Generated with [opencode](https://opencode.ai) Co-Authored-By: opencode --- .config/hypr/includes/hypridle.conf | 0 .config/waybar/config | 1 - .config/wlogout/layout | 4 --- .local/bin/wp-vol | 2 +- .zshrc | 9 ++++++ modules/02-symlinks.sh | 44 ++++++++++++++--------------- 6 files changed, 32 insertions(+), 28 deletions(-) delete mode 100644 .config/hypr/includes/hypridle.conf delete mode 120000 .config/waybar/config delete mode 100644 .config/wlogout/layout mode change 100644 => 100755 .local/bin/wp-vol diff --git a/.config/hypr/includes/hypridle.conf b/.config/hypr/includes/hypridle.conf deleted file mode 100644 index e69de29..0000000 diff --git a/.config/waybar/config b/.config/waybar/config deleted file mode 120000 index 3273116..0000000 --- a/.config/waybar/config +++ /dev/null @@ -1 +0,0 @@ -/home/lousy/git/dotfiles/.config/waybar/config-desktop \ No newline at end of file diff --git a/.config/wlogout/layout b/.config/wlogout/layout deleted file mode 100644 index 32b2a43..0000000 --- a/.config/wlogout/layout +++ /dev/null @@ -1,4 +0,0 @@ -{ - "label": "Logout", - "command": "loginctl terminate-user $USER" -} diff --git a/.local/bin/wp-vol b/.local/bin/wp-vol old mode 100644 new mode 100755 index 38b531c..5849c4f --- a/.local/bin/wp-vol +++ b/.local/bin/wp-vol @@ -8,4 +8,4 @@ VOLUME=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{printf "%d", $2 * 100}') MUTED=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep -q MUTED && echo " (muted)" || echo "") # Show notification -notify-send -a Volume -h string:x-canonical-private-synchronous:volume -u low "Volume: $VOLUME%$MUTED" +notify-send -a Volume -h string:x-canonical-private-synchronous:volume -h int:value:$VOLUME -u low "Volume: $VOLUME%$MUTED" diff --git a/.zshrc b/.zshrc index f44e7a6..668b7e2 100644 --- a/.zshrc +++ b/.zshrc @@ -12,6 +12,15 @@ # Environment settings # ===================== +# Ensure ~/.local/bin is in PATH (XDG standard) +if [ -d "$HOME/.local/bin" ] && [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then + export PATH="$HOME/.local/bin:$PATH" +fi +# Optionally add XDG-compliant bin dir if present +if [ -d "${XDG_DATA_HOME:-$HOME/.local/share}/bin" ] && [[ ":$PATH:" != *":${XDG_DATA_HOME:-$HOME/.local/share}/bin:"* ]]; then + export PATH="${XDG_DATA_HOME:-$HOME/.local/share}/bin:$PATH" +fi + # Do Not Track for CLI tools export DO_NOT_TRACK=1 diff --git a/modules/02-symlinks.sh b/modules/02-symlinks.sh index 92836d2..5859522 100755 --- a/modules/02-symlinks.sh +++ b/modules/02-symlinks.sh @@ -31,26 +31,20 @@ done # Symlink .config directory contents CONFIG_DIR="$DOTFILES_DIR/.config" if [ -d "$CONFIG_DIR" ]; then - echo "Symlinking .config contents..." - for item in "$CONFIG_DIR"/*; do - [ -e "$item" ] || continue - baseitem="$(basename "$item")" - target_dir="$HOME/.config/$baseitem" - - # Remove only if it's a symlink or a directory we manage - if [ -L "$target_dir" ]; then - rm "$target_dir" - elif [ -d "$target_dir" ] && [ ! -L "$target_dir" ]; then - # Only remove if the directory is empty or matches our repo - if [ -z "$(ls -A "$target_dir" 2>/dev/null)" ]; then - rm -rf "$target_dir" - else - echo "Warning: $target_dir is a non-empty directory. Not removed." - fi - fi - - ln -sf "$item" "$target_dir" - echo "Linked .config/$baseitem" + echo "Symlinking .config contents (files only, recursive)..." + find "$CONFIG_DIR" -type f | while read -r srcfile; do + # Get relative path from $CONFIG_DIR + relpath="${srcfile#$CONFIG_DIR/}" + targetfile="$HOME/.config/$relpath" + targetdir="$(dirname "$targetfile")" + # If targetdir is a symlink, remove it first + [ -L "$targetdir" ] && rm "$targetdir" + mkdir -p "$targetdir" + # Remove existing file/symlink at target + [ -L "$targetfile" ] && rm "$targetfile" + [ -f "$targetfile" ] && rm "$targetfile" + ln -sf "$srcfile" "$targetfile" + echo "Linked $srcfile -> $targetfile" done # ===================== @@ -83,10 +77,16 @@ if [ -d "$CONFIG_DIR" ]; then # Symlink each device-specific fragment for fragment in "${fragment_types[@]}"; do src="${CONFIG_DIR}/${fragment%%:*}" - tgt="${CONFIG_DIR}/${fragment##*:}" + tgt_rel="${fragment##*:}" + tgt="$HOME/.config/$tgt_rel" + tgt_dir="$(dirname "$tgt")" + mkdir -p "$tgt_dir" if [ -f "$src" ]; then + # Remove existing file/symlink at target + [ -L "$tgt" ] && rm "$tgt" + [ -f "$tgt" ] && rm "$tgt" ln -sf "$src" "$tgt" - echo "Linked $(basename "$src") as $(basename "$tgt")" + echo "Linked $src -> $tgt" else echo "Warning: Device-specific fragment missing: $src" # To troubleshoot, ensure the fragment exists for your device/host