install: better link install

Remove links if not already linked before linking
This commit is contained in:
2 * r + 2 * t
2025-02-23 21:23:34 +11:00
parent 557e1e4abe
commit fd14efb773
6 changed files with 16 additions and 13 deletions
+1 -2
View File
@@ -20,7 +20,6 @@ update-repo discord $dist
setup-systemd-monitor discord $dist setup-systemd-monitor discord $dist
# Link themes to client config # Link themes to client config
confirm-overwrite $client/themes install-link $dist/themes $client/themes
ln -s $dist/themes $client/themes
log 'Done.' log 'Done.'
+4 -8
View File
@@ -10,20 +10,16 @@ set -l dist $C_DATA/fish
update-repo fish $dist update-repo fish $dist
# Install fish config # Install fish config
confirm-overwrite $CONFIG/fish/config.fish install-link $dist/config.fish $CONFIG/fish/config.fish
ln -s $dist/config.fish $CONFIG/fish/config.fish
# Install fish greeting # Install fish greeting
confirm-overwrite $CONFIG/fish/functions/fish_greeting.fish
mkdir -p $CONFIG/fish/functions mkdir -p $CONFIG/fish/functions
ln -s $dist/fish_greeting.fish $CONFIG/fish/functions/fish_greeting.fish install-link $dist/fish_greeting.fish $CONFIG/fish/functions/fish_greeting.fish
# Install starship config # Install starship config
confirm-overwrite $CONFIG/starship.toml install-link $dist/starship.toml $CONFIG/starship.toml
ln -s $dist/starship.toml $CONFIG/starship.toml
# Install fastfetch config # Install fastfetch config
confirm-overwrite $CONFIG/fastfetch/config.jsonc install-link $dist/fastfetch.jsonc $CONFIG/fastfetch/config.jsonc
ln -s $dist/fastfetch.jsonc $CONFIG/fastfetch/config.jsonc
log 'Done.' log 'Done.'
+1 -2
View File
@@ -25,8 +25,7 @@ else
end end
# Install uwsm envs # Install uwsm envs
confirm-overwrite $uwsm install-link $hypr/uwsm $uwsm
ln -s $hypr/uwsm $uwsm
# Enable ydotool if installed # Enable ydotool if installed
pacman -Q ydotool &> /dev/null && systemctl --user enable --now ydotool.service pacman -Q ydotool &> /dev/null && systemctl --user enable --now ydotool.service
+2 -1
View File
@@ -12,9 +12,10 @@ update-repo scripts $dist
# Install to path # Install to path
mkdir -p ~/.local/bin mkdir -p ~/.local/bin
ln -sf $dist/main.fish ~/.local/bin/caelestia install-link $dist/main.fish ~/.local/bin/caelestia
# Install completions # Install completions
test -e $CONFIG/fish/completions/caelestia.fish && rm $CONFIG/fish/completions/caelestia.fish
mkdir -p $CONFIG/fish/completions mkdir -p $CONFIG/fish/completions
cp $dist/completions/caelestia.fish $CONFIG/fish/completions/caelestia.fish cp $dist/completions/caelestia.fish $CONFIG/fish/completions/caelestia.fish
+7
View File
@@ -108,3 +108,10 @@ WantedBy=default.target" > $systemd/$module-monitor-scheme.path
systemctl --user start $module-monitor-scheme.service systemctl --user start $module-monitor-scheme.service
end end
end end
function install-link -a from to
if ! test -L $to -a (realpath $to) = (realpath $from)
confirm-overwrite $to
ln -s $from $to
end
end
+1
View File
@@ -3,6 +3,7 @@
. (dirname (status filename))/util.fish . (dirname (status filename))/util.fish
function confirm-copy -a from to function confirm-copy -a from to
test -L $to -a (realpath $to) = (realpath $from) && return
if test -e $to if test -e $to
read -l -p "input '$(realpath $to) already exists. Overwrite? [y/N] ' -n" confirm read -l -p "input '$(realpath $to) already exists. Overwrite? [y/N] ' -n" confirm
test "$confirm" = 'y' -o "$confirm" = 'Y' && log 'Continuing.' || return test "$confirm" = 'y' -o "$confirm" = 'Y' && log 'Continuing.' || return