WIP: Converts runs to be text files of packages to install / uninstall, begins before and after scripts to execute during runs.

This commit is contained in:
2025-11-09 22:15:29 -05:00
parent 381a0450e5
commit 9c007c9434
23 changed files with 259 additions and 206 deletions

202
run
View File

@@ -5,11 +5,127 @@
# Runs scripts in the `./runs` directory, which will install or uninstall # Runs scripts in the `./runs` directory, which will install or uninstall
# packages. It either runs a single script given an argument (filename in runs) # packages. It either runs a single script given an argument (filename in runs)
# or all scripts in the runs directory. # 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 if [ -z "$DEV_ENV" ]; then
echo "env var DEV_ENV needs to be present" log --error "env var DEV_ENV needs to be present" && exit 1
exit 1
fi fi
# if i just did DEV_ENV=$(pwd) ./run then this is needed for the rest of the # 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 shift
done done
# TODO: Setup proper logging using '$SCRIPTS/hypr/logging' export LOG_ENABLE_DRY_RUN="$dry_run"
log() {
if [[ $dry_run == "1" ]]; then
echo "[DRY_RUN]: $1"
else
echo "$1"
fi
}
# TODO: Remove. log --echo "RUN: -- grep: '$grep'"
run() { runs_dir=$(find $DEV_ENV/runs -mindepth 1 -maxdepth 1 -type f) # TODO: keep
local script=$1
local flag=$2
log "running script: $script $flag"
local actual_flags="-S --noconfirm" #runs_dir=$(find $DEV_ENV/runs -mindepth 1 -maxdepth 1 -executable) # TODO: remove.
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.
for s in $runs_dir; do for s in $runs_dir; do
if basename $s | grep -vq "$grep"; then if basename $s | grep -vq "$grep"; then
@@ -120,9 +170,11 @@ for s in $runs_dir; do
if [[ $uninstall == "1" ]]; then if [[ $uninstall == "1" ]]; then
# TODO: Use function instead. # TODO: Use function instead.
run $s --uninstall # run $s --uninstall
uninstall "$s"
else else
# TODO: Use function instead. # TODO: Use function instead.
run $s --install # run $s --install
install "$s"
fi fi
done done

16
runs/after/clipse Executable file
View File

@@ -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 $?

23
runs/after/dev Executable file
View File

@@ -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

15
runs/audio Executable file → Normal file
View File

@@ -1,8 +1,7 @@
#!/usr/bin/env bash # Packages to install / uninstall with this run.
pipewire
yay ${1:-"-S --noconfirm"} pipewire \ pavucontrol
pavucontrol \ wireplumber
wireplumber \ pipewire-jack
pipewire-jack \ pipewire-pulse
pipewire-pulse \ blueberry-wayland
blueberry-wayland

4
runs/before/dev Executable file
View File

@@ -0,0 +1,4 @@
#!/usr/bin/env bash
yay -S --noconfirm --needed rustup
rustup default stable

5
runs/brave Executable file → Normal file
View File

@@ -1,3 +1,2 @@
#!/usr/bin/env bash # Packages to install / uninstall with this run.
brave-bin
yay ${1:-"-S --noconfirm"} brave-bin

7
runs/clipse Executable file → Normal file
View File

@@ -1,3 +1,4 @@
#!/usr/bin/env bash # Packages to install / uninstall with this run.
#
yay ${1:-"-S --noconfirm"} clipse # Clipse manages clipboard history.
clipse

56
runs/dev Executable file → Normal file
View File

@@ -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 # Packages
yay -S --noconfirm --needed \ bat
bat \ bob
bob \ eza
eza \ fastfetch
fastfetch \ fzf
fzf \ git-lfs
git-lfs \ gum
gum \ jq
jq \ neovim
neovim \ nodejs
nodejs \ npm
npm \ pcre2
pcre2 \ ripgrep
ripgrep \ starship
starship \ tldr
tldr \ tmux
tmux \ tree-sitter-cli
tree-sitter-cli \ yazi
zoxide zoxide
# Fonts # Fonts
yay -S --noconfirm \ ttf-jetbrains-mono-nerd
ttf-jetbrains-mono-nerd \ ttf-firacode
ttf-firacode \ ttf-inconsolata-ne
ttf-inconsolata-nerd

5
runs/espanso Executable file → Normal file
View File

@@ -1,3 +1,2 @@
#!/usr/bin/env bash # Packages to install / uninstall with this run.
espanso-wayland-git
yay ${1:-"-S --noconfirm"} espanso-wayland-git

8
runs/ghostty Executable file → Normal file
View File

@@ -1,6 +1,2 @@
#!/usr/bin/env bash # Packages to install / uninstall with this run.
ghostty-git
# 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

6
runs/gopass Executable file → Normal file
View File

@@ -1,3 +1,3 @@
#!/usr/bin/env bash # Packages to install / uninstall with this run.
gopass-git
yay ${1:-"-S --noconfirm --needed"} gopass-git git-credential-gopass git-credential-gopass

18
runs/hyprland Executable file → Normal file
View File

@@ -1,9 +1,9 @@
#!/usr/bin/env bash # Packages to install / uninstall with this run.
hyprland-git
yay ${1:-"-S --noconfirm"} hyprland-git \ hyprpaper-git
hyprpaper-git \ hypridle-git
hypridle-git \ hyprlock-git
hyprlock-git \ hyprlauncher-git
hyprlauncher-git \ xdg-desktop-portal-hyprland-git
xdg-desktop-portal-hyprland-git \ bc # used for some scripts.
bc # used for some scripts. waybar

View File

@@ -1,5 +0,0 @@
#!/usr/bin/env bash
yay ${1:-"-S --noconfirm"} rustup
$DEV_ENV/env/.local/scripts/kanatactl bootstrap

5
runs/localsend Executable file → Normal file
View File

@@ -1,3 +1,2 @@
#!/usr/bin/env bash # Packages to install / uninstall with this run.
localsend-bin
yay ${1:-"-S --noconfirm"} localsend-bin

7
runs/nautilus Executable file → Normal file
View File

@@ -1,3 +1,4 @@
#!/usr/bin/env bash # Packages to install / uninstall with this run.
nautilus
yay ${1:-"-S --noconfirm"} nautilus nautilus-share gvfs-smb nautilus-share
gvfs-smb

32
runs/neomutt Executable file → Normal file
View File

@@ -1,17 +1,17 @@
#!/usr/bin/env bash # Packages to install / uninstall with this run.
yay ${1:-"-S --noconfirm"} neomutt \ neomutt
abook \ abook
mutt-wizard \ mutt-wizard
goimapnotify \ goimapnotify
lynx \ lynx
notmuch \ notmuch
urlview \ urlview
cronie \ cronie
protonmail-bridge \ protonmail-bridge
isync \ isync
msmtp \ msmtp
pass \ pass
ca-certificates \ ca-certificates
gettext \ gettext
cyrus-sasl-xoauth2-git cyrus-sasl-xoauth2-git

View File

@@ -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

7
runs/podman Executable file → Normal file
View File

@@ -1,3 +1,4 @@
#!/usr/bin/env bash # Packages to install / uninstall with this run.
podman
yay ${1:-"-S --noconfirm"} podman podman-docker podman-compose podman-docker
podman-compose

24
runs/system Executable file → Normal file
View File

@@ -1,12 +1,12 @@
#!/usr/bin/env bash # Packages to install / uninstall with this run
catppuccin-gtk-theme-mocha
yay ${1:-"-S --noconfirm"} catppuccin-gtk-theme-mocha \ kanata
nwg-look \ nwg-look
wl-clipboard \ wl-clipboard
pam-u2f \ pam-u2f
pcsc-tools \ pcsc-tools
swaync \ swaync
yubikey-manager \ yubikey-manager
nfs-utils \ nfs-utils
firewalld \ firewalld
zsh zsh

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env bash
yay ${1:-"-S --noconfirm"} thunderbird

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env bash
yay ${1:-"-S --noconfirm"} waybar

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env bash
yay ${1:-"-S --noconfirm"} yazi

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env bash
yay ${1:-"-S --noconfirm"} zen-browser-bin