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:
parent
cbe3ff94ac
commit
1e02be0a39
@ -1 +0,0 @@
|
||||
/home/lousy/git/dotfiles/.config/waybar/config-desktop
|
||||
@ -1,4 +0,0 @@
|
||||
{
|
||||
"label": "Logout",
|
||||
"command": "loginctl terminate-user $USER"
|
||||
}
|
||||
2
.local/bin/wp-vol
Normal file → Executable file
2
.local/bin/wp-vol
Normal file → Executable 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 "")
|
||||
|
||||
# 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
9
.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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user