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

- 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 <noreply@opencode.ai>
This commit is contained in:
Martin Büchler 2025-08-08 17:06:36 +02:00
parent cbe3ff94ac
commit 1e02be0a39
6 changed files with 32 additions and 28 deletions

View File

@ -1 +0,0 @@
/home/lousy/git/dotfiles/.config/waybar/config-desktop

View File

@ -1,4 +0,0 @@
{
"label": "Logout",
"command": "loginctl terminate-user $USER"
}

2
.local/bin/wp-vol Normal file → Executable file
View File

@ -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 "") MUTED=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep -q MUTED && echo " (muted)" || echo "")
# Show notification # 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"

9
.zshrc
View File

@ -12,6 +12,15 @@
# Environment settings # 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 # Do Not Track for CLI tools
export DO_NOT_TRACK=1 export DO_NOT_TRACK=1

View File

@ -31,26 +31,20 @@ done
# Symlink .config directory contents # Symlink .config directory contents
CONFIG_DIR="$DOTFILES_DIR/.config" CONFIG_DIR="$DOTFILES_DIR/.config"
if [ -d "$CONFIG_DIR" ]; then if [ -d "$CONFIG_DIR" ]; then
echo "Symlinking .config contents..." echo "Symlinking .config contents (files only, recursive)..."
for item in "$CONFIG_DIR"/*; do find "$CONFIG_DIR" -type f | while read -r srcfile; do
[ -e "$item" ] || continue # Get relative path from $CONFIG_DIR
baseitem="$(basename "$item")" relpath="${srcfile#$CONFIG_DIR/}"
target_dir="$HOME/.config/$baseitem" targetfile="$HOME/.config/$relpath"
targetdir="$(dirname "$targetfile")"
# Remove only if it's a symlink or a directory we manage # If targetdir is a symlink, remove it first
if [ -L "$target_dir" ]; then [ -L "$targetdir" ] && rm "$targetdir"
rm "$target_dir" mkdir -p "$targetdir"
elif [ -d "$target_dir" ] && [ ! -L "$target_dir" ]; then # Remove existing file/symlink at target
# Only remove if the directory is empty or matches our repo [ -L "$targetfile" ] && rm "$targetfile"
if [ -z "$(ls -A "$target_dir" 2>/dev/null)" ]; then [ -f "$targetfile" ] && rm "$targetfile"
rm -rf "$target_dir" ln -sf "$srcfile" "$targetfile"
else echo "Linked $srcfile -> $targetfile"
echo "Warning: $target_dir is a non-empty directory. Not removed."
fi
fi
ln -sf "$item" "$target_dir"
echo "Linked .config/$baseitem"
done done
# ===================== # =====================
@ -83,10 +77,16 @@ if [ -d "$CONFIG_DIR" ]; then
# Symlink each device-specific fragment # Symlink each device-specific fragment
for fragment in "${fragment_types[@]}"; do for fragment in "${fragment_types[@]}"; do
src="${CONFIG_DIR}/${fragment%%:*}" 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 if [ -f "$src" ]; then
# Remove existing file/symlink at target
[ -L "$tgt" ] && rm "$tgt"
[ -f "$tgt" ] && rm "$tgt"
ln -sf "$src" "$tgt" ln -sf "$src" "$tgt"
echo "Linked $(basename "$src") as $(basename "$tgt")" echo "Linked $src -> $tgt"
else else
echo "Warning: Device-specific fragment missing: $src" echo "Warning: Device-specific fragment missing: $src"
# To troubleshoot, ensure the fragment exists for your device/host # To troubleshoot, ensure the fragment exists for your device/host