From 587e29efe4584c8fa8016901302fd4214f78be66 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Tue, 28 Jan 2025 16:45:16 +1100 Subject: install scripts for all modules --- README.md | 4 ++- completions/caelestia.fish | 7 ++++- install.fish | 8 ------ install/discord.fish | 67 ++++++++++++++++++++++++++++++++++++++++++++++ install/foot.fish | 13 +++++++++ install/fuzzel.fish | 28 +++++++++++++++++++ install/hypr.fish | 16 +++++++++++ install/safeeyes.fish | 12 +++++++++ install/scripts.fish | 17 ++++++++++++ install/shell.fish | 13 +++++++++ install/util.fish | 55 +++++++++++++++++++++++++++++++++++++ main.fish | 21 ++++++++++----- scheme/apply-scheme.fish | 4 +-- util.fish | 4 +++ 14 files changed, 250 insertions(+), 19 deletions(-) delete mode 100755 install.fish create mode 100755 install/discord.fish create mode 100755 install/foot.fish create mode 100755 install/fuzzel.fish create mode 100755 install/hypr.fish create mode 100755 install/safeeyes.fish create mode 100755 install/scripts.fish create mode 100755 install/shell.fish create mode 100644 install/util.fish diff --git a/README.md b/README.md index 9eff4ac..8eb770c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ A collection of scripts for my caelestia dotfiles. ## Installation -Run the `install.fish` script in the base of the repo. +Clone this repo. + +Run `install/scripts.fish`. `~/.local/bin` must be in your path. ## Usage diff --git a/completions/caelestia.fish b/completions/caelestia.fish index c1ec161..dd12057 100644 --- a/completions/caelestia.fish +++ b/completions/caelestia.fish @@ -1,6 +1,6 @@ set -l seen '__fish_seen_subcommand_from' set -l has_opt '__fish_contains_opt' -set -l commands help shell toggle workspace-action scheme screenshot record clipboard clipboard-delete emoji-picker wallpaper pip +set -l commands help install shell toggle workspace-action scheme screenshot record clipboard clipboard-delete emoji-picker wallpaper pip set -l not_seen "not $seen $commands" # Disable file completions @@ -8,6 +8,7 @@ complete -c caelestia -f # Subcommands complete -c caelestia -n $not_seen -a 'help' -d 'Show help' +complete -c caelestia -n $not_seen -a 'install' -d 'Install a module' complete -c caelestia -n $not_seen -a 'shell' -d 'Start the shell or message it' complete -c caelestia -n $not_seen -a 'toggle' -d 'Toggle a special workspace' complete -c caelestia -n $not_seen -a 'workspace-action' -d 'Exec a dispatcher in the current group' @@ -20,6 +21,10 @@ complete -c caelestia -n $not_seen -a 'emoji-picker' -d 'Open the emoji picker' complete -c caelestia -n $not_seen -a 'wallpaper' -d 'Change the wallpaper' complete -c caelestia -n $not_seen -a 'pip' -d 'Picture in picture utilities' +# Install +set -l commands discord foot fuzzel hypr safeeyes scripts shell +complete -c caelestia -n "$seen install && not $seen $commands" -a "$commands" + # Shell set -l commands quit reload-css show brightness media set -l not_seen "$seen shell && not $seen $commands" diff --git a/install.fish b/install.fish deleted file mode 100755 index 029174c..0000000 --- a/install.fish +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/fish - -set -q XDG_CONFIG_HOME && set -l config $XDG_CONFIG_HOME/caelestia || set -l config ~/.config/caelestia -set -l dist $config/scripts - -git clone https://github.com/caelestia-dots/scripts.git $dist -mkdir -p ~/.local/bin -ln -s $dist/main.fish ~/.local/bin/caelestia diff --git a/install/discord.fish b/install/discord.fish new file mode 100755 index 0000000..c8f81d7 --- /dev/null +++ b/install/discord.fish @@ -0,0 +1,67 @@ +#!/bin/fish + +if test -z "$argv[1]" + echo 'Usage: caelestia install discord ' + exit 1 +end + +. (dirname (status filename))/util.fish + +install-deps git + +set -l systemd $CONFIG/../systemd/user +set -l client $CONFIG/../$argv[1] +set -l discord $CONFIG/discord + +# Clone repo +confirm-overwrite $discord +git clone https://github.com/caelestia-dots/discord.git $discord + +# 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 + +# Optionally install arRPC +read -l -p "input 'Install arRPC? [Y/n] ' -n" confirm +if test "$confirm" = 'n' -o "$confirm" = 'N' + log 'Skipping.' +else + log 'Installing arRPC...' + + install-deps npm + git clone 'https://github.com/OpenAsar/arrpc.git' $discord/arrpc + cd $discord/arrpc || exit + npm install + + echo "[Unit] +Description=arRPC Discord RPC daemon +After=network.target + +[Service] +Type=simple +ExecStart=node $discord/arrpc/src +Restart=on-failure +WorkingDirectory=$discord/arrpc + +[Install] +WantedBy=default.target" > $systemd/arrpc.service + + systemctl --user daemon-reload + systemctl --user enable --now arrpc.service +end + +# Link themes to client config +confirm-overwrite $client/themes +ln -s $discord/themes $client/themes + +log 'Done.' diff --git a/install/foot.fish b/install/foot.fish new file mode 100755 index 0000000..8e9c51e --- /dev/null +++ b/install/foot.fish @@ -0,0 +1,13 @@ +#!/bin/fish + +. (dirname (status filename))/util.fish + +install-deps git foot inotify-tools + +set -l foot $CONFIG/../foot + +confirm-overwrite $foot +git clone 'https://github.com/caelestia-dots/foot.git' $foot +sed -i 's|$SRC|'$foot'|g' $foot/foot.ini + +log 'Done.' diff --git a/install/fuzzel.fish b/install/fuzzel.fish new file mode 100755 index 0000000..eb3bf3b --- /dev/null +++ b/install/fuzzel.fish @@ -0,0 +1,28 @@ +#!/bin/fish + +. (dirname (status filename))/util.fish + +install-deps git fuzzel-git + +set -l systemd $CONFIG/../systemd/user +set -l fuzzel $CONFIG/../fuzzel + +# Clone repo +confirm-overwrite $fuzzel +git clone 'https://github.com/caelestia-dots/fuzzel.git' $fuzzel + +# 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 + +log 'Done.' diff --git a/install/hypr.fish b/install/hypr.fish new file mode 100755 index 0000000..4ff9088 --- /dev/null +++ b/install/hypr.fish @@ -0,0 +1,16 @@ +#!/bin/fish + +. (dirname (status filename))/util.fish + +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)' 'hypricker-git (colour picker)' 'foot (terminal emulator)' 'firefox (web browser)' 'vscodium-bin (IDE)' 'thunar (file manager)' 'nemo (secondary file manager)' 'fuzzel (secondary app launcher)' + +set -l hypr $CONFIG/../hypr + +confirm-overwrite $hypr +git clone 'https://github.com/caelestia-dots/hypr.git' $hypr + +sudo pacman -S --needed --noconfirm ydotool +systemctl --user enable --now ydotool.service + +log 'Done.' diff --git a/install/safeeyes.fish b/install/safeeyes.fish new file mode 100755 index 0000000..93da2d2 --- /dev/null +++ b/install/safeeyes.fish @@ -0,0 +1,12 @@ +#!/bin/fish + +. (dirname (status filename))/util.fish + +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 + +log 'Done.' diff --git a/install/scripts.fish b/install/scripts.fish new file mode 100755 index 0000000..d31049d --- /dev/null +++ b/install/scripts.fish @@ -0,0 +1,17 @@ +#!/bin/fish + +. (dirname (status filename))/util.fish + +install-deps git hyprland-git hyprpaper-git okolors-git imagemagick wl-clipboard fuzzel-git socat foot jq +install-optional-deps 'vesktop-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 + +confirm-overwrite $dist + +git clone 'https://github.com/caelestia-dots/scripts.git' $dist + +mkdir -p ~/.local/bin +ln -s $dist/main.fish ~/.local/bin/caelestia + +log 'Done.' diff --git a/install/shell.fish b/install/shell.fish new file mode 100755 index 0000000..ac3e228 --- /dev/null +++ b/install/shell.fish @@ -0,0 +1,13 @@ +#!/bin/fish + +. (dirname (status filename))/util.fish + +install-deps git dart-sass 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 + +confirm-overwrite $shell +git clone 'https://github.com/caelestia-dots/shell.git' $shell + +log 'Done.' diff --git a/install/util.fish b/install/util.fish new file mode 100644 index 0000000..3f54c86 --- /dev/null +++ b/install/util.fish @@ -0,0 +1,55 @@ +. (dirname (status filename))/../util.fish + +function confirm-overwrite -a path + if test -e $path + read -l -p "input '$(realpath $path) already exists. Overwrite? [y/N] ' -n" confirm + if test "$confirm" = 'y' -o "$confirm" = 'Y' + log 'Continuing.' + rm -rf $path + else + log 'Exiting.' + exit + end + end +end + +function install-deps + # All dependencies already installed + pacman -Q $argv &> /dev/null && return + + # Get AUR helper or install if none + which yay > /dev/null && set -l helper yay || set -l helper paru + if ! which paru > /dev/null + warn 'No AUR helper found' + read -l -p "input 'Install yay? [Y/n] ' -n" confirm + if test "$confirm" = 'n' -o "$confirm" = 'N' + warn "Manually install yay or paru and try again." + warn "Alternatively, install the dependencies '$argv' manually and try again." + exit + else + sudo pacman -S --needed git base-devel + git clone https://aur.archlinux.org/yay.git + cd yay + makepkg -si + cd .. + rm -rf yay + + # First use, see https://github.com/Jguer/yay?tab=readme-ov-file#first-use + yay -Y --gendb + yay -Y --devel --save + end + end + + # Install + log "Installing dependencies '$argv'" + $helper -S --needed --noconfirm $argv +end + +function install-optional-deps + for dep in $argv + if ! pacman -Q $dep &> /dev/null + read -l -p "input 'Install $dep? [Y/n] ' -n" confirm + test "$confirm" != 'n' -a "$confirm" != 'N' && install-deps (cut -f 1 -d ' ' $dep) + end + end +end diff --git a/main.fish b/main.fish index 1f054c0..26e24f1 100755 --- a/main.fish +++ b/main.fish @@ -7,10 +7,10 @@ set -l src (dirname (realpath (status filename))) if test "$argv[1]" = shell # Start shell if no args if test -z "$argv[2..]" - set -q CAELESTIA_SHELL_DIR && set shell_dir $CAELESTIA_SHELL_DIR || set shell_dir $CONFIG/shell + set -q CAELESTIA_SHELL_DIR && set -l shell_dir $CAELESTIA_SHELL_DIR || set -l shell_dir $CONFIG/shell $shell_dir/run.fish else - if contains 'caelestia' (astal -l) + if contains -- 'caelestia' (astal -l) log "Sent command '$argv[2..]' to shell" astal -i caelestia $argv[2..] else @@ -22,7 +22,7 @@ end if test "$argv[1]" = toggle set -l valid_toggles communication music sysmon specialws - contains "$argv[2]" $valid_toggles && $src/toggles/$argv[2].fish || error "Invalid toggle: $argv[2]" + contains -- "$argv[2]" $valid_toggles && $src/toggles/$argv[2].fish || error "Invalid toggle: $argv[2]" exit end @@ -33,16 +33,22 @@ end if test "$argv[1]" = scheme set -l valid_schemes dynamic mocha macchiato frappe latte - if contains "$argv[2]" $valid_schemes + if contains -- "$argv[2]" $valid_schemes echo -n $argv[2] > $CACHE/scheme/current.txt || error "Invalid scheme: $argv[2]" test -f $CONFIG/gtk/update-scheme.fish && $CONFIG/gtk/update-scheme.fish end exit end -set valid_subcommands screenshot record clipboard clipboard-delete emoji-picker wallpaper pip +if test "$argv[1]" = install + set -l valid_modules discord foot fuzzel hypr safeeyes scripts shell + contains -- "$argv[2]" $valid_modules && $src/install/$argv[2].fish || error "Invalid module: $argv[2]" + exit +end + +set -l valid_subcommands screenshot record clipboard clipboard-delete emoji-picker wallpaper pip -if contains "$argv[1]" $valid_subcommands +if contains -- "$argv[1]" $valid_subcommands $src/$argv[1].fish $argv[2..] exit end @@ -51,9 +57,10 @@ test "$argv[1]" != help && error "Unknown command: $argv[1]" echo 'Usage: caelestia COMMAND [ ...args ]' echo -echo 'COMMAND := help | shell | toggle | workspace-action | scheme | screenshot | record | clipboard | clipboard-delete | emoji-picker | wallpaper | pip' +echo 'COMMAND := help | install | shell | toggle | workspace-action | scheme | screenshot | record | clipboard | clipboard-delete | emoji-picker | wallpaper | pip' echo echo ' help: show this help message' +echo ' install: install a module' echo ' shell: start the shell or message it' echo ' toggle: toggle a special workspace' echo ' workspace-action: execute a Hyprland workspace dispatcher in the current group' diff --git a/scheme/apply-scheme.fish b/scheme/apply-scheme.fish index aff4275..ecea2d5 100755 --- a/scheme/apply-scheme.fish +++ b/scheme/apply-scheme.fish @@ -44,9 +44,9 @@ end set -l src (dirname (status filename)) set -l colours ($src/gen-scheme.fish $argv[1]) -if test -d $CONFIG/hypr +if test -d $CONFIG/../hypr/scheme log 'Generating hypr scheme' - gen-hypr $colours > $CONFIG/hypr/scheme/dynamic.conf + gen-hypr $colours > $CONFIG/../hypr/scheme/dynamic.conf end if test -d $CONFIG/shell diff --git a/util.fish b/util.fish index caae353..4a2fb4e 100644 --- a/util.fish +++ b/util.fish @@ -18,5 +18,9 @@ function error -a text return 1 end +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 -- cgit v1.2.3-freya