From 669eaa61cbead28957c0b541212e05a8ca8c7a7f Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sat, 22 Feb 2025 14:25:41 +1100 Subject: install: better install + use data and state Don't complete remove repos, use git pull instead Use XDG_DATA_HOME and XDG_STATE_HOME --- install/discord.fish | 25 ++++++------------------- install/foot.fish | 7 +++---- install/fuzzel.fish | 19 +++---------------- install/gtk.fish | 20 ++++---------------- install/hypr.fish | 25 ++++++++++++++++--------- install/safeeyes.fish | 6 ++---- install/scripts.fish | 11 +++++------ install/shell.fish | 6 +++--- install/util.fish | 44 ++++++++++++++++++++++++++++++++++++++++++++ install/vscode.fish | 9 ++++----- main.fish | 6 +++--- record.fish | 8 ++++---- scheme/gen-scheme.fish | 4 ++-- screenshot.fish | 4 ++-- util.fish | 8 +++++--- wallpaper.fish | 14 +++++++------- 16 files changed, 113 insertions(+), 103 deletions(-) diff --git a/install/discord.fish b/install/discord.fish index 98d7fad..2eff70a 100755 --- a/install/discord.fish +++ b/install/discord.fish @@ -10,30 +10,17 @@ end install-deps git install-optional-deps 'arrpc (rich presence)' -set -l systemd $CONFIG/../systemd/user -set -l client $CONFIG/../$argv[1] -set -l discord $CONFIG/discord +set -l client $CONFIG/$argv[1] +set -l dist $C_DATA/discord -# Clone repo -confirm-overwrite $discord -git clone https://github.com/caelestia-dots/discord.git $discord +# Update/Clone repo +update-repo discord $dist # Install systemd service -if test -d $systemd - log 'Installing systemd service...' - - echo "[Service] -Type=oneshot -ExecStart=$discord/monitor/update.fish" > $systemd/discord-monitor-scheme.service - cp $discord/monitor/discord-monitor-scheme.path $systemd/discord-monitor-scheme.path - - systemctl --user daemon-reload - systemctl --user enable --now discord-monitor-scheme.path - systemctl --user start discord-monitor-scheme.service -end +setup-systemd-monitor discord $dist # Link themes to client config confirm-overwrite $client/themes -ln -s $discord/themes $client/themes +ln -s $dist/themes $client/themes log 'Done.' diff --git a/install/foot.fish b/install/foot.fish index 8e9c51e..941630f 100755 --- a/install/foot.fish +++ b/install/foot.fish @@ -4,10 +4,9 @@ install-deps git foot inotify-tools -set -l foot $CONFIG/../foot +set -l dist $CONFIG/foot -confirm-overwrite $foot -git clone 'https://github.com/caelestia-dots/foot.git' $foot -sed -i 's|$SRC|'$foot'|g' $foot/foot.ini +update-repo foot $dist +sed -i 's|$SRC|'$dist'|g' $dist/foot.ini log 'Done.' diff --git a/install/fuzzel.fish b/install/fuzzel.fish index eb3bf3b..3f22fee 100755 --- a/install/fuzzel.fish +++ b/install/fuzzel.fish @@ -4,25 +4,12 @@ install-deps git fuzzel-git -set -l systemd $CONFIG/../systemd/user -set -l fuzzel $CONFIG/../fuzzel +set -l dist $CONFIG/fuzzel # Clone repo -confirm-overwrite $fuzzel -git clone 'https://github.com/caelestia-dots/fuzzel.git' $fuzzel +update-repo fuzzel $dist # Install systemd service -if test -d $systemd - log 'Installing systemd service...' - - echo "[Service] -Type=oneshot -ExecStart=$fuzzel/monitor/update.fish" > $systemd/fuzzel-monitor-scheme.service - cp $fuzzel/monitor/fuzzel-monitor-scheme.path $systemd/fuzzel-monitor-scheme.path - - systemctl --user daemon-reload - systemctl --user enable --now fuzzel-monitor-scheme.path - systemctl --user start fuzzel-monitor-scheme.service -end +setup-systemd-monitor fuzzel $dist log 'Done.' diff --git a/install/gtk.fish b/install/gtk.fish index 10e41e4..c3cca61 100755 --- a/install/gtk.fish +++ b/install/gtk.fish @@ -4,24 +4,12 @@ install-deps git adw-gtk-theme -set -l gtk $CONFIG/gtk -set -l systemd $CONFIG/../systemd/user +set -l dist $C_DATA/gtk -confirm-overwrite $gtk -git clone 'https://github.com/caelestia-dots/gtk.git' $gtk +# Update/Clone repo +update-repo gtk $dist # Install systemd service -if test -d $systemd - log 'Installing systemd service...' - - echo "[Service] -Type=oneshot -ExecStart=$gtk/monitor/update.fish" > $systemd/gtk-monitor-scheme.service - cp $gtk/monitor/gtk-monitor-scheme.path $systemd/gtk-monitor-scheme.path - - systemctl --user daemon-reload - systemctl --user enable --now gtk-monitor-scheme.path - systemctl --user start gtk-monitor-scheme.service -end +setup-systemd-monitor gtk $dist log 'Done.' diff --git a/install/hypr.fish b/install/hypr.fish index e93c0ba..e7761cf 100755 --- a/install/hypr.fish +++ b/install/hypr.fish @@ -5,13 +5,24 @@ install-deps git uwsm hyprland-git hyprpaper-git hyprlock-git hypridle-git polkit-gnome gnome-keyring wl-clipboard wireplumber install-optional-deps 'gammastep (night light)' 'wlogout (secondary session menu)' 'grimblast-git (screenshot freeze)' 'hyprpicker-git (colour picker)' 'foot (terminal emulator)' 'firefox (web browser)' 'vscodium-bin (IDE)' 'thunar (file manager)' 'nemo (secondary file manager)' 'fuzzel (secondary app launcher)' 'ydotool (alternate paste)' 'trash-cli (auto trash)' -set -l hypr $CONFIG/../hypr -set -l uwsm $CONFIG/../uwsm +set -l hypr $CONFIG/hypr +set -l uwsm $CONFIG/uwsm # Cause hyprland autogenerates a config file when it is removed -confirm-overwrite $hypr dummy -git clone 'https://github.com/caelestia-dots/hypr.git' /tmp/caelestia-hypr -rm -rf $hypr && mv /tmp/caelestia-hypr $hypr +set -l remote https://github.com/caelestia-dots/hypr.git +if test -d $hypr + cd $hypr || exit + if test "$(git config --get remote.origin.url)" != $remote + cd .. || exit + confirm-overwrite $hypr dummy + git clone $remote /tmp/caelestia-hypr + rm -rf $hypr && mv /tmp/caelestia-hypr $hypr + else + git pull + end +else + git clone $remote $dir +end # Install uwsm envs confirm-overwrite $uwsm @@ -20,8 +31,4 @@ mv $hypr/uwsm $uwsm # Enable ydotool if installed pacman -Q ydotool &> /dev/null && systemctl --user enable --now ydotool.service -# Reload hyprland config to get rid of error messages -sleep .1 -hyprctl reload - log 'Done.' diff --git a/install/safeeyes.fish b/install/safeeyes.fish index 93da2d2..05582fa 100755 --- a/install/safeeyes.fish +++ b/install/safeeyes.fish @@ -4,9 +4,7 @@ install-deps git dart-sass aylurs-gtk-shell-git alsa-utils libappindicator-gtk3 -set -l safeeyes $CONFIG/safeeyes - -confirm-overwrite $safeeyes -git clone 'https://github.com/caelestia-dots/safeeyes.git' $safeeyes +# Update/Clone repo +update-repo safeeyes $C_DATA/safeeyes log 'Done.' diff --git a/install/scripts.fish b/install/scripts.fish index 3cca775..bc5770b 100755 --- a/install/scripts.fish +++ b/install/scripts.fish @@ -5,18 +5,17 @@ install-deps git hyprland-git hyprpaper-git okolors-git imagemagick wl-clipboard fuzzel-git socat foot jq python install-optional-deps 'equibop-bin (discord client)' 'btop (system monitor)' 'wf-recorder (screen recorder)' 'grim (screenshot tool)' 'firefox (web browser)' 'spotify-adblock (music player)' -set -l dist $CONFIG/scripts +set -l dist $C_DATA/scripts -# Clone repo -confirm-overwrite $dist -git clone 'https://github.com/caelestia-dots/scripts.git' $dist +# Update/Clone repo +update-repo scripts $dist # Install to path mkdir -p ~/.local/bin ln -s $dist/main.fish ~/.local/bin/caelestia # Install completions -mkdir -p $CONFIG/../fish/completions -cp $dist/completions/caelestia.fish $CONFIG/../fish/completions/caelestia.fish +mkdir -p $CONFIG/fish/completions +cp $dist/completions/caelestia.fish $CONFIG/fish/completions/caelestia.fish log 'Done.' diff --git a/install/shell.fish b/install/shell.fish index c48b817..2e9d117 100755 --- a/install/shell.fish +++ b/install/shell.fish @@ -5,10 +5,10 @@ install-deps git dart-sass libastal-gjs-git libastal-meta npm curl libnotify ttf-material-symbols-variable-git ttf-jetbrains-mono-nerd ttf-rubik-vf pacman-contrib install-optional-deps 'uwsm (for systems using uwsm)' 'yay (AUR package management)' 'fd (launcher file search)' 'wl-clipboard (clipboard support)' 'foot (opening stuff in terminal)' -set -l shell $CONFIG/shell +set -l shell $C_DATA/shell -confirm-overwrite $shell -git clone 'https://github.com/caelestia-dots/shell.git' $shell +# Update/Clone repo +update-repo shell $shell cd $shell || exit npm install diff --git a/install/util.fish b/install/util.fish index 6fca2f9..ad62230 100644 --- a/install/util.fish +++ b/install/util.fish @@ -64,3 +64,47 @@ function install-optional-deps end end end + +function update-repo -a module dir + set -l remote https://github.com/caelestia-dots/$module.git + if test -d $dir + cd $dir || exit + if test "$(git config --get remote.origin.url)" != $remote + cd .. || exit + confirm-overwrite $dir + git clone $remote $dir + else + git pull + end + else + git clone $remote $dir + end +end + +function setup-systemd-monitor -a module dir + set -l systemd $CONFIG/systemd/user + if which systemctl &> /dev/null + log 'Installing systemd service...' + + mkdir -p $systemd + echo "[Unit] +Description=Sync $module and caelestia schemes + +[Service] +Type=oneshot +ExecStart=$dir/monitor/update.fish" > $systemd/$module-monitor-scheme.service + echo "[Unit] +Description=Sync $module and caelestia schemes (monitor) + +[Path] +PathModified=%S/caelestia/scheme/current.txt +Unit=$module-monitor-scheme.service + +[Install] +WantedBy=default.target" > $systemd/$module-monitor-scheme.path + + systemctl --user daemon-reload + systemctl --user enable --now $module-monitor-scheme.path + systemctl --user start $module-monitor-scheme.service + end +end diff --git a/install/vscode.fish b/install/vscode.fish index e74163a..1f4b6b1 100755 --- a/install/vscode.fish +++ b/install/vscode.fish @@ -12,15 +12,14 @@ end install-deps git -set -l dist $CONFIG/vscode +set -l dist $C_DATA/vscode -# Clone repo -confirm-overwrite $dist -git clone 'https://github.com/caelestia-dots/vscode.git' $dist +# Update/Clone repo +update-repo vscode $dist # Install settings for prog in 'Code' 'Code - OSS' 'VSCodium' - set -l conf $CONFIG/../$prog + set -l conf $CONFIG/$prog if test -d $conf confirm-copy $dist/settings.json $conf/User/settings.json confirm-copy $dist/keybindings.json $conf/User/keybindings.json diff --git a/main.fish b/main.fish index 3586c3d..5dbc043 100755 --- a/main.fish +++ b/main.fish @@ -34,9 +34,9 @@ end if test "$argv[1]" = scheme set -l valid_schemes (path change-extension '' $src/data/schemes/* | sed 's!.*/!!') if contains -- "$argv[2]" $valid_schemes - mkdir -p $CACHE/scheme - cp $src/data/schemes/$argv[2].txt $CACHE/scheme/current.txt - echo -n $argv[2] > $CACHE/scheme/current-name.txt + mkdir -p $C_STATE/scheme + cp $src/data/schemes/$argv[2].txt $C_STATE/scheme/current.txt + echo -n $argv[2] > $C_STATE/scheme/current-name.txt else error "Invalid scheme: $argv[2]" end diff --git a/record.fish b/record.fish index 1463346..7d76d52 100755 --- a/record.fish +++ b/record.fish @@ -47,14 +47,14 @@ end . (dirname (status filename))/util.fish set storage_dir (xdg-user-dir VIDEOS)/Recordings -set cache_dir $CACHE/record +set state_dir $C_STATE/record mkdir -p $storage_dir -mkdir -p $cache_dir +mkdir -p $state_dir set file_ext 'mp4' -set recording_path "$cache_dir/recording.$file_ext" -set notif_id_path "$cache_dir/notifid.txt" +set recording_path "$state_dir/recording.$file_ext" +set notif_id_path "$state_dir/notifid.txt" if pgrep wf-recorder > /dev/null pkill wf-recorder diff --git a/scheme/gen-scheme.fish b/scheme/gen-scheme.fish index 2cc54d0..ff0058e 100755 --- a/scheme/gen-scheme.fish +++ b/scheme/gen-scheme.fish @@ -11,7 +11,7 @@ set -l src (dirname (status filename)) . $src/../util.fish -test -f "$argv[1]" && set -l img "$argv[1]" || set -l img $CACHE/wallpaper/current +test -f "$argv[1]" && set -l img "$argv[1]" || set -l img $C_STATE/wallpaper/current set -l img (realpath $img) # Light theme if background lighter than foreground @@ -24,7 +24,7 @@ else set colour_scheme dark end -test "$(cat $CACHE/scheme/current.txt)" = dynamic && gsettings set org.gnome.desktop.interface color-scheme \'prefer-$colour_scheme\' +test "$(cat $C_STATE/scheme/current.txt)" = dynamic && gsettings set org.gnome.desktop.interface color-scheme \'prefer-$colour_scheme\' # 2nd line except first element is the palette # The first element in lines 3+ are the layers diff --git a/screenshot.fish b/screenshot.fish index a0f6177..7363631 100755 --- a/screenshot.fish +++ b/screenshot.fish @@ -2,8 +2,8 @@ . (dirname (status filename))/util.fish -mkdir -p "$CACHE/screenshots" -set -l tmp_file "$CACHE/screenshots/$(date +'%Y%m%d%H%M%S')" +mkdir -p "$C_CACHE/screenshots" +set -l tmp_file "$C_CACHE/screenshots/$(date +'%Y%m%d%H%M%S')" grim $argv $tmp_file; and wl-copy < $tmp_file; or exit 1 set -l action (notify-send -i 'image-x-generic-symbolic' -h "STRING:image-path:$tmp_file" \ diff --git a/util.fish b/util.fish index 4a2fb4e..027b546 100644 --- a/util.fish +++ b/util.fish @@ -1,4 +1,4 @@ -function _out -a colour -a level -a text +function _out -a colour level text set_color $colour # Pass arguments other than text to echo echo $argv[4..] -- ":: [$level] $text" @@ -22,5 +22,7 @@ function input -a text _out blue INPUT $text $argv[2..] end -set -q XDG_CONFIG_HOME && set CONFIG $XDG_CONFIG_HOME/caelestia || set CONFIG $HOME/.config/caelestia -set -q XDG_CACHE_HOME && set CACHE $XDG_CACHE_HOME/caelestia || set CACHE $HOME/.cache/caelestia +set -q XDG_DATA_HOME && set -l C_DATA $XDG_DATA_HOME/caelestia || set -l C_DATA $HOME/.local/share/caelestia +set -q XDG_STATE_HOME && set -l C_STATE $XDG_STATE_HOME/caelestia || set -l C_STATE $HOME/.local/state/caelestia +set -q XDG_CACHE_HOME && set -l C_CACHE $XDG_CACHE_HOME/caelestia || set -l C_CACHE $HOME/.cache/caelestia +set -q XDG_CONFIG_HOME && set -l CONFIG $XDG_CONFIG_HOME || set -l CONFIG $HOME/.config diff --git a/wallpaper.fish b/wallpaper.fish index 80f510a..eb03cfd 100755 --- a/wallpaper.fish +++ b/wallpaper.fish @@ -35,10 +35,10 @@ if set -q _flag_h echo ' -F, --no-filter Do not filter by size' echo ' -t, --threshold The minimum percentage of the size the image must be greater than to be selected (default '$threshold')' else - set cache_dir $CACHE/wallpaper + set state_dir $C_STATE/wallpaper # The path to the last chosen wallpaper - set last_wallpaper_path "$cache_dir/last.txt" + set last_wallpaper_path "$state_dir/last.txt" # Use wallpaper given as argument else choose random if set -q _flag_f @@ -113,13 +113,13 @@ else # Generate colour scheme for wallpaper set -l src (dirname (status filename)) $src/scheme/gen-scheme.fish $chosen_wallpaper > $src/data/schemes/dynamic.txt - if test -f $CACHE/scheme/current.txt -a "$(cat $CACHE/scheme/current-name.txt)" = 'dynamic' - cp $src/data/schemes/dynamic.txt $CACHE/scheme/current.txt + if test -f $C_STATE/scheme/current.txt -a "$(cat $C_STATE/scheme/current-name.txt)" = 'dynamic' + cp $src/data/schemes/dynamic.txt $C_STATE/scheme/current.txt end # Store the wallpaper chosen - mkdir -p $cache_dir + mkdir -p $state_dir echo $chosen_wallpaper > $last_wallpaper_path - ln -sf $chosen_wallpaper "$cache_dir/current" - magick $chosen_wallpaper -fill black -colorize 10% -blur 0x10 "$cache_dir/blur" & + ln -sf $chosen_wallpaper "$state_dir/current" + magick $chosen_wallpaper -fill black -colorize 10% -blur 0x10 "$state_dir/blur" & end -- cgit v1.2.3-freya