summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-02-23 21:23:34 +1100
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-02-23 21:23:34 +1100
commitfd14efb7739961cf2d15057b96ef376c046e80f6 (patch)
treed8dcace910ce07f7ace251d5dc96e4aace1eb88c
parentscheme: light/dark mode (diff)
downloadcaelestia-cli-fd14efb7739961cf2d15057b96ef376c046e80f6.tar.gz
caelestia-cli-fd14efb7739961cf2d15057b96ef376c046e80f6.tar.bz2
caelestia-cli-fd14efb7739961cf2d15057b96ef376c046e80f6.zip
install: better link install
Remove links if not already linked before linking
-rwxr-xr-xinstall/discord.fish3
-rwxr-xr-xinstall/fish.fish12
-rwxr-xr-xinstall/hypr.fish3
-rwxr-xr-xinstall/scripts.fish3
-rw-r--r--install/util.fish7
-rwxr-xr-xinstall/vscode.fish1
6 files changed, 16 insertions, 13 deletions
diff --git a/install/discord.fish b/install/discord.fish
index 2eff70a..22bf936 100755
--- a/install/discord.fish
+++ b/install/discord.fish
@@ -20,7 +20,6 @@ update-repo discord $dist
setup-systemd-monitor discord $dist
# Link themes to client config
-confirm-overwrite $client/themes
-ln -s $dist/themes $client/themes
+install-link $dist/themes $client/themes
log 'Done.'
diff --git a/install/fish.fish b/install/fish.fish
index 10df9b7..ca1d186 100755
--- a/install/fish.fish
+++ b/install/fish.fish
@@ -10,20 +10,16 @@ set -l dist $C_DATA/fish
update-repo fish $dist
# Install fish config
-confirm-overwrite $CONFIG/fish/config.fish
-ln -s $dist/config.fish $CONFIG/fish/config.fish
+install-link $dist/config.fish $CONFIG/fish/config.fish
# Install fish greeting
-confirm-overwrite $CONFIG/fish/functions/fish_greeting.fish
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
-confirm-overwrite $CONFIG/starship.toml
-ln -s $dist/starship.toml $CONFIG/starship.toml
+install-link $dist/starship.toml $CONFIG/starship.toml
# Install fastfetch config
-confirm-overwrite $CONFIG/fastfetch/config.jsonc
-ln -s $dist/fastfetch.jsonc $CONFIG/fastfetch/config.jsonc
+install-link $dist/fastfetch.jsonc $CONFIG/fastfetch/config.jsonc
log 'Done.'
diff --git a/install/hypr.fish b/install/hypr.fish
index 90e99ef..615894f 100755
--- a/install/hypr.fish
+++ b/install/hypr.fish
@@ -25,8 +25,7 @@ else
end
# Install uwsm envs
-confirm-overwrite $uwsm
-ln -s $hypr/uwsm $uwsm
+install-link $hypr/uwsm $uwsm
# Enable ydotool if installed
pacman -Q ydotool &> /dev/null && systemctl --user enable --now ydotool.service
diff --git a/install/scripts.fish b/install/scripts.fish
index 8594828..a509a43 100755
--- a/install/scripts.fish
+++ b/install/scripts.fish
@@ -12,9 +12,10 @@ update-repo scripts $dist
# Install to path
mkdir -p ~/.local/bin
-ln -sf $dist/main.fish ~/.local/bin/caelestia
+install-link $dist/main.fish ~/.local/bin/caelestia
# Install completions
+test -e $CONFIG/fish/completions/caelestia.fish && rm $CONFIG/fish/completions/caelestia.fish
mkdir -p $CONFIG/fish/completions
cp $dist/completions/caelestia.fish $CONFIG/fish/completions/caelestia.fish
diff --git a/install/util.fish b/install/util.fish
index ad62230..d9a02f5 100644
--- a/install/util.fish
+++ b/install/util.fish
@@ -108,3 +108,10 @@ WantedBy=default.target" > $systemd/$module-monitor-scheme.path
systemctl --user start $module-monitor-scheme.service
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
diff --git a/install/vscode.fish b/install/vscode.fish
index 1f4b6b1..56ddd39 100755
--- a/install/vscode.fish
+++ b/install/vscode.fish
@@ -3,6 +3,7 @@
. (dirname (status filename))/util.fish
function confirm-copy -a from to
+ test -L $to -a (realpath $to) = (realpath $from) && return
if test -e $to
read -l -p "input '$(realpath $to) already exists. Overwrite? [y/N] ' -n" confirm
test "$confirm" = 'y' -o "$confirm" = 'Y' && log 'Continuing.' || return