diff --git a/run b/run index e173e3c..ca212f1 100755 --- a/run +++ b/run @@ -5,11 +5,127 @@ # Runs scripts in the `./runs` directory, which will install or uninstall # packages. It either runs a single script given an argument (filename in runs) # or all scripts in the runs directory. -# + +set -e +set -o nounset +set -o pipefail + +THIS_FILE=${BASH_SOURCE[0]} +LOG_LABEL=$(basename $THIS_FILE) +LOG_FILE=${LOG_FILE:-"$LOG_LABEL.log"} + +declare dry_run grep uninstall + +log() { + logging log --source "$THIS_FILE" "$@" +} + +# TODO: Remove. +run() { + local script=$1 + local flag=$2 + log "running script: $script $flag" + + local actual_flags="-S --noconfirm" + + if [[ $flag == "--uninstall" ]]; then + actual_flags="-Rns" + fi + log "ok, here's the actual script:: $s $actual_flags" + + if [[ $dry_run == "0" ]]; then + $script $actual_flags + fi +} + +after() { + local after + local file=${1:-""} + local arg=${2:-""} + + # Check for after script, and run it if found. + after=$(find "$DEV_ENV/runs/after" -mindepth 1 -maxdepth 1 -executable -name "$(basename "$file")" | head -1) + if [[ -n "$after" ]]; then + log --echo " running after script: '$after'" + [[ $dry_run == "0" ]] && source "$after" "$arg" + fi +} + +before() { + local before + local file=${1:-""} + local arg=${2:-""} + + before=$(find "$DEV_ENV/runs/before" -mindepth 1 -maxdepth 1 -executable -name "$(basename "$file")" | head -1) + if [[ -n "$before" ]]; then + log --echo " running before script: '$before'" + [[ $dry_run == "0" ]] && source "$before" "$arg" + fi +} + +install() { + local file line pkg after before + + # Ensure yay is installed before proceeding. + [[ $dry_run == "0" ]] && . "$DEV_ENV/runs/before/yay" + + file=${1:-""} + # Early out if the file is not readable. + [[ ! -r $file ]] && exit 1 + log --echo "Installing packages from: $file" + + before "$file" install + + # Loop over lines in the file and install the packages. + while read -r line; do + # Skip lines that begin with '#' (comments) + if [[ ! $line =~ ^# ]]; then + # Remove any inline comments. + pkg=${line%% \#*} + if [[ -n $pkg ]]; then + log --echo " pkg: '$pkg'" + [[ $dry_run == "0" ]] && yay -S --noconfirm --needed "$pkg" + fi + fi + done <"$file" + + after "$file" install +} + +uninstall() { + local file line pkg + + file=${1:-""} + # Early out if the file is not readable. + [[ ! -r $file ]] && exit 1 + + log --echo "Uninstalling packages from: $file" + + before "$file" uninstall + + # Loop over lines in the file and uninstall the packages. + while read -r line; do + # Skip lines that begin with '#' (comments) + if [[ ! $line =~ ^# ]]; then + # Remove any inline comments. + pkg=${line%% \#*} + log --echo " pkg: '$pkg'" + [[ $dry_run == "0" ]] && yay -Rns "$pkg" + fi + done <"$file" + + after "$file" uninstall + +} + +############################## MAIN ############################## + +# Setup logging file and label. +source "$SCRIPTS/hypr/logging" +setup-logging "$LOG_FILE" "$LOG_LABEL" if [ -z "$DEV_ENV" ]; then - echo "env var DEV_ENV needs to be present" - exit 1 + log --error "env var DEV_ENV needs to be present" && exit 1 fi # if i just did DEV_ENV=$(pwd) ./run then this is needed for the rest of the @@ -39,78 +155,12 @@ while [[ $# -gt 0 ]]; do shift done -# TODO: Setup proper logging using '$SCRIPTS/hypr/logging' -log() { - if [[ $dry_run == "1" ]]; then - echo "[DRY_RUN]: $1" - else - echo "$1" - fi -} +export LOG_ENABLE_DRY_RUN="$dry_run" -# TODO: Remove. -run() { - local script=$1 - local flag=$2 - log "running script: $script $flag" +log --echo "RUN: -- grep: '$grep'" +runs_dir=$(find $DEV_ENV/runs -mindepth 1 -maxdepth 1 -type f) # TODO: keep - local actual_flags="-S --noconfirm" - - if [[ $flag == "--uninstall" ]]; then - actual_flags="-Rns" - fi - log "ok, here's the actual script:: $s $actual_flags" - - if [[ $dry_run == "0" ]]; then - $script $actual_flags - fi - -} - -install() { - local file line pkg - - file=${1:-""} - # Early out if the file is not readable. - [[ ! -r $file ]] && exit 1 - - # Loop over lines in the file and install the packages. - while read -r line; do - # Skip lines that begin with '#' (comments) - if [[ ! $line =~ ^# ]]; then - # Remove any inline comments. - pkg=${line%% \#*} - # TODO: We should log something here?? - [[ $dry_run == "0" ]] && yay -S --noconfirm --needed "$pkg" - fi - done <"$file" -} - -uninstall() { - local file line pkg - - file=${1:-""} - # Early out if the file is not readable. - [[ ! -r $file ]] && exit 1 - - # Loop over lines in the file and uninstall the packages. - while read -r line; do - # Skip lines that begin with '#' (comments) - if [[ ! $line =~ ^# ]]; then - # Remove any inline comments. - pkg=${line%% \#*} - # TODO: We should log something here?? - [[ $dry_run == "0" ]] && yay -Rns "$pkg" - fi - done <"$file" -} - -############################## MAIN ############################## - -log "RUN: -- grep: $grep" - -#runs_dir=$(find $DEV_ENV/runs -mindepth 1 -maxdepth 1 -type f) # TODO: keep -runs_dir=$(find $DEV_ENV/runs -mindepth 1 -maxdepth 1 -executable) # TODO: remove. +#runs_dir=$(find $DEV_ENV/runs -mindepth 1 -maxdepth 1 -executable) # TODO: remove. for s in $runs_dir; do if basename $s | grep -vq "$grep"; then @@ -120,9 +170,11 @@ for s in $runs_dir; do if [[ $uninstall == "1" ]]; then # TODO: Use function instead. - run $s --uninstall + # run $s --uninstall + uninstall "$s" else # TODO: Use function instead. - run $s --install + # run $s --install + install "$s" fi done diff --git a/runs/after/clipse b/runs/after/clipse new file mode 100755 index 0000000..ee177a5 --- /dev/null +++ b/runs/after/clipse @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share} + +install() { + mkdir -p "$XDG_DATA_HOME/clipse" + setsid uwsm app -- clipse -listen +} + +uninstall() { + rm -rf "$XDG_DATA_HOME/clipse" +} + +arg=${1:-""} +[[ $arg == "install" ]] && install && exit $? +[[ $arg == "uninstall" ]] && uninstall && exit $? diff --git a/runs/after/dev b/runs/after/dev new file mode 100755 index 0000000..f75b0d8 --- /dev/null +++ b/runs/after/dev @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +install() { + # TODO: Handle install / uninstall. + bob install nightly && + bob install stable && + bob use nightly +} + +uninstall() { + echo "FIX ME!" +} + +arg=${1:-""} + +if [[ $arg == "install" ]]; then + install && exit $? +elif [[ $arg == "uninstall" ]]; then + uninstall && exit $? +else + # TODO: Using logging. + echo "Error, invalid option" && exit 1 +fi diff --git a/runs/audio b/runs/audio old mode 100755 new mode 100644 index 91526c5..fdf256b --- a/runs/audio +++ b/runs/audio @@ -1,8 +1,7 @@ -#!/usr/bin/env bash - -yay ${1:-"-S --noconfirm"} pipewire \ - pavucontrol \ - wireplumber \ - pipewire-jack \ - pipewire-pulse \ - blueberry-wayland +# Packages to install / uninstall with this run. +pipewire +pavucontrol +wireplumber +pipewire-jack +pipewire-pulse +blueberry-wayland diff --git a/runs/before/dev b/runs/before/dev new file mode 100755 index 0000000..e1e6380 --- /dev/null +++ b/runs/before/dev @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +yay -S --noconfirm --needed rustup +rustup default stable diff --git a/runs/brave b/runs/brave old mode 100755 new mode 100644 index ef7b435..384f2c9 --- a/runs/brave +++ b/runs/brave @@ -1,3 +1,2 @@ -#!/usr/bin/env bash - -yay ${1:-"-S --noconfirm"} brave-bin +# Packages to install / uninstall with this run. +brave-bin diff --git a/runs/clipse b/runs/clipse old mode 100755 new mode 100644 index 5e26c19..cb817b5 --- a/runs/clipse +++ b/runs/clipse @@ -1,3 +1,4 @@ -#!/usr/bin/env bash - -yay ${1:-"-S --noconfirm"} clipse +# Packages to install / uninstall with this run. +# +# Clipse manages clipboard history. +clipse diff --git a/runs/dev b/runs/dev old mode 100755 new mode 100644 index 9993bf6..9b8e251 --- a/runs/dev +++ b/runs/dev @@ -1,36 +1,24 @@ -#!/usr/bin/env bash - -if ! command -v yay >/dev/null 2>&1; then - sudo pacman -S --noconfirm --needed git base-devel - git clone https://aur.archlinux.org/yay.git ~/yay - cd ~/yay - makepkg -si - rm -rf ~/yay -fi - # Packages -yay -S --noconfirm --needed \ - bat \ - bob \ - eza \ - fastfetch \ - fzf \ - git-lfs \ - gum \ - jq \ - neovim \ - nodejs \ - npm \ - pcre2 \ - ripgrep \ - starship \ - tldr \ - tmux \ - tree-sitter-cli \ - zoxide - +bat +bob +eza +fastfetch +fzf +git-lfs +gum +jq +neovim +nodejs +npm +pcre2 +ripgrep +starship +tldr +tmux +tree-sitter-cli +yazi +zoxide # Fonts -yay -S --noconfirm \ - ttf-jetbrains-mono-nerd \ - ttf-firacode \ - ttf-inconsolata-nerd +ttf-jetbrains-mono-nerd +ttf-firacode +ttf-inconsolata-ne diff --git a/runs/espanso b/runs/espanso old mode 100755 new mode 100644 index ed09606..fcf926e --- a/runs/espanso +++ b/runs/espanso @@ -1,3 +1,2 @@ -#!/usr/bin/env bash - -yay ${1:-"-S --noconfirm"} espanso-wayland-git +# Packages to install / uninstall with this run. +espanso-wayland-git diff --git a/runs/ghostty b/runs/ghostty old mode 100755 new mode 100644 index 5303abf..81eef13 --- a/runs/ghostty +++ b/runs/ghostty @@ -1,6 +1,2 @@ -#!/usr/bin/env bash - -# Flags get passed in from the run script, but if -# ran directly the default is going to be to install. - -yay "${1:-"-S --noconfirm --needed"}" ghostty +# Packages to install / uninstall with this run. +ghostty-git diff --git a/runs/gopass b/runs/gopass old mode 100755 new mode 100644 index c1122db..51e2ae2 --- a/runs/gopass +++ b/runs/gopass @@ -1,3 +1,3 @@ -#!/usr/bin/env bash - -yay ${1:-"-S --noconfirm --needed"} gopass-git git-credential-gopass +# Packages to install / uninstall with this run. +gopass-git +git-credential-gopass diff --git a/runs/hyprland b/runs/hyprland old mode 100755 new mode 100644 index ac094ae..0fd168d --- a/runs/hyprland +++ b/runs/hyprland @@ -1,9 +1,9 @@ -#!/usr/bin/env bash - -yay ${1:-"-S --noconfirm"} hyprland-git \ - hyprpaper-git \ - hypridle-git \ - hyprlock-git \ - hyprlauncher-git \ - xdg-desktop-portal-hyprland-git \ - bc # used for some scripts. +# Packages to install / uninstall with this run. +hyprland-git +hyprpaper-git +hypridle-git +hyprlock-git +hyprlauncher-git +xdg-desktop-portal-hyprland-git +bc # used for some scripts. +waybar diff --git a/runs/kanata b/runs/kanata deleted file mode 100755 index bdc22c0..0000000 --- a/runs/kanata +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -yay ${1:-"-S --noconfirm"} rustup - -$DEV_ENV/env/.local/scripts/kanatactl bootstrap diff --git a/runs/localsend b/runs/localsend old mode 100755 new mode 100644 index ce2e8f0..7536c74 --- a/runs/localsend +++ b/runs/localsend @@ -1,3 +1,2 @@ -#!/usr/bin/env bash - -yay ${1:-"-S --noconfirm"} localsend-bin +# Packages to install / uninstall with this run. +localsend-bin diff --git a/runs/nautilus b/runs/nautilus old mode 100755 new mode 100644 index 85d70d3..f93df4d --- a/runs/nautilus +++ b/runs/nautilus @@ -1,3 +1,4 @@ -#!/usr/bin/env bash - -yay ${1:-"-S --noconfirm"} nautilus nautilus-share gvfs-smb +# Packages to install / uninstall with this run. +nautilus +nautilus-share +gvfs-smb diff --git a/runs/neomutt b/runs/neomutt old mode 100755 new mode 100644 index 32c9b34..82a651e --- a/runs/neomutt +++ b/runs/neomutt @@ -1,17 +1,17 @@ -#!/usr/bin/env bash +# Packages to install / uninstall with this run. -yay ${1:-"-S --noconfirm"} neomutt \ - abook \ - mutt-wizard \ - goimapnotify \ - lynx \ - notmuch \ - urlview \ - cronie \ - protonmail-bridge \ - isync \ - msmtp \ - pass \ - ca-certificates \ - gettext \ - cyrus-sasl-xoauth2-git +neomutt +abook +mutt-wizard +goimapnotify +lynx +notmuch +urlview +cronie +protonmail-bridge +isync +msmtp +pass +ca-certificates +gettext +cyrus-sasl-xoauth2-git diff --git a/runs/obs-studio b/runs/obs-studio deleted file mode 100755 index 76ce457..0000000 --- a/runs/obs-studio +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -# Needs installed from AUR. -if [[ ! $(yay -Q libajantv2 2>/dev/null) ]]; then - yay -S libajantv2 -fi - -cd $HOME/pkgbuilds/obs-studio-arm && makepkg -si diff --git a/runs/podman b/runs/podman old mode 100755 new mode 100644 index f79e518..a0a0cab --- a/runs/podman +++ b/runs/podman @@ -1,3 +1,4 @@ -#!/usr/bin/env bash - -yay ${1:-"-S --noconfirm"} podman podman-docker podman-compose +# Packages to install / uninstall with this run. +podman +podman-docker +podman-compose diff --git a/runs/system b/runs/system old mode 100755 new mode 100644 index a8db348..95d4b6a --- a/runs/system +++ b/runs/system @@ -1,12 +1,12 @@ -#!/usr/bin/env bash - -yay ${1:-"-S --noconfirm"} catppuccin-gtk-theme-mocha \ - nwg-look \ - wl-clipboard \ - pam-u2f \ - pcsc-tools \ - swaync \ - yubikey-manager \ - nfs-utils \ - firewalld \ - zsh +# Packages to install / uninstall with this run +catppuccin-gtk-theme-mocha +kanata +nwg-look +wl-clipboard +pam-u2f +pcsc-tools +swaync +yubikey-manager +nfs-utils +firewalld +zsh diff --git a/runs/thunderbird b/runs/thunderbird deleted file mode 100755 index 1a4491f..0000000 --- a/runs/thunderbird +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -yay ${1:-"-S --noconfirm"} thunderbird diff --git a/runs/waybar b/runs/waybar deleted file mode 100755 index be1dc92..0000000 --- a/runs/waybar +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -yay ${1:-"-S --noconfirm"} waybar diff --git a/runs/yazi b/runs/yazi deleted file mode 100755 index c27bf17..0000000 --- a/runs/yazi +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -yay ${1:-"-S --noconfirm"} yazi diff --git a/runs/zen b/runs/zen deleted file mode 100755 index 7fdf89e..0000000 --- a/runs/zen +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -yay ${1:-"-S --noconfirm"} zen-browser-bin