From d78c3b985bd8e643e57af933d8f95f7dac4cef7f Mon Sep 17 00:00:00 2001 From: Don Williams Date: Sun, 1 Feb 2026 00:44:20 -0500 Subject: Fixed copy.sh to set default waybar links and check for broken links On branch development Your branch is up to date with 'origin/development'. Changes to be committed: modified: copy.sh --- copy.sh | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'copy.sh') diff --git a/copy.sh b/copy.sh index 05d80e2e..8999ab01 100755 --- a/copy.sh +++ b/copy.sh @@ -589,9 +589,22 @@ else config_remove="" fi -# Check if ~/.config/waybar/config does not exist or is a symlink -if [ ! -e "$HOME/.config/waybar/config" ] || [ -L "$HOME/.config/waybar/config" ]; then - ln -sf "$config_file" "$HOME/.config/waybar/config" 2>&1 | tee -a "$LOG" +# Ensure waybar config uses the normalized default. +# - If the current path is not a symlink (regular file), convert it to a symlink. +# - If the symlink points somewhere else (or is broken), reset it to the new default. +WAYBAR_CONFIG_LINK="$HOME/.config/waybar/config" +WAYBAR_CONFIG_TARGET="$config_file" +if [ -e "$WAYBAR_CONFIG_TARGET" ]; then + if [ -L "$WAYBAR_CONFIG_LINK" ]; then + current_target=$(readlink "$WAYBAR_CONFIG_LINK" || true) + if [ "$current_target" != "$WAYBAR_CONFIG_TARGET" ] || [ ! -e "$WAYBAR_CONFIG_LINK" ]; then + ln -sf "$WAYBAR_CONFIG_TARGET" "$WAYBAR_CONFIG_LINK" 2>&1 | tee -a "$LOG" + fi + else + ln -sf "$WAYBAR_CONFIG_TARGET" "$WAYBAR_CONFIG_LINK" 2>&1 | tee -a "$LOG" + fi +else + echo "${WARN} Waybar default config target not found at $WAYBAR_CONFIG_TARGET; leaving $WAYBAR_CONFIG_LINK as-is." 2>&1 | tee -a "$LOG" fi # Remove inappropriate waybar configs @@ -665,9 +678,22 @@ else cleanup_backups prompt "$LOG" fi -# Check if ~/.config/waybar/style.css does not exist or is a symlink -if [ ! -e "$HOME/.config/waybar/style.css" ] || [ -L "$HOME/.config/waybar/style.css" ]; then - ln -sf "$waybar_style" "$HOME/.config/waybar/style.css" 2>&1 | tee -a "$LOG" +# Ensure waybar style uses the normalized default. +# - If the current path is not a symlink (regular file), convert it to a symlink. +# - If the symlink points somewhere else (or is broken), reset it to the new default. +WAYBAR_STYLE_LINK="$HOME/.config/waybar/style.css" +WAYBAR_STYLE_TARGET="$waybar_style" +if [ -e "$WAYBAR_STYLE_TARGET" ]; then + if [ -L "$WAYBAR_STYLE_LINK" ]; then + current_target=$(readlink "$WAYBAR_STYLE_LINK" || true) + if [ "$current_target" != "$WAYBAR_STYLE_TARGET" ] || [ ! -e "$WAYBAR_STYLE_LINK" ]; then + ln -sf "$WAYBAR_STYLE_TARGET" "$WAYBAR_STYLE_LINK" 2>&1 | tee -a "$LOG" + fi + else + ln -sf "$WAYBAR_STYLE_TARGET" "$WAYBAR_STYLE_LINK" 2>&1 | tee -a "$LOG" + fi +else + echo "${WARN} Waybar default style target not found at $WAYBAR_STYLE_TARGET; leaving $WAYBAR_STYLE_LINK as-is." 2>&1 | tee -a "$LOG" fi printf "\n%.0s" {1..1} -- cgit v1.2.3