aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Singleton <matt@xcolour.net>2024-11-06 15:58:54 -0600
committerMatt Singleton <matt@xcolour.net>2024-11-06 15:58:54 -0600
commitbd9538a24a9207b4bd88f71956a817b5b042874b (patch)
tree711e5747dae7dc668344a3e42d8856e560819842
parent2be10e1420afea58f859ea4ec5b7565ac1849de2 (diff)
support scripts
-rwxr-xr-xstow/console-utils/.local/bin/doom29
-rwxr-xr-xstow/waybar/.local/bin/checkbackup34
2 files changed, 63 insertions, 0 deletions
diff --git a/stow/console-utils/.local/bin/doom b/stow/console-utils/.local/bin/doom
new file mode 100755
index 0000000..5085e20
--- /dev/null
+++ b/stow/console-utils/.local/bin/doom
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+case $1 in
+ doom)
+ iwad="$HOME/Games/doom/DOOM.WAD"
+ ;;
+ sigil)
+ iwad="$HOME/Games/doom/DOOM.WAD"
+ pwad="$HOME/Games/doom/SIGIL_v1_21.wad"
+ ;;
+ doom2)
+ iwad="$HOME/Games/doom/DOOM2.WAD"
+ ;;
+ tnt)
+ iwad="$HOME/Games/doom/TNT.WAD"
+ ;;
+ plutonia)
+ iwad="$HOME/Games/doom/PLUTONIA.WAD"
+ ;;
+ *)
+esac
+
+if [ -n "$pwad" ] && [ -n "$iwad" ]; then
+ flatpak run --filesystem="$HOME/Games/doom:ro" io.github.fabiangreffrath.Doom -iwad "$iwad" -merge "$pwad"
+elif [ -n "$iwad" ]; then
+ flatpak run --filesystem="$HOME/Games/doom:ro" io.github.fabiangreffrath.Doom -iwad "$iwad"
+else
+ flatpak run --filesystem="$HOME/Games/doom:ro" io.github.fabiangreffrath.Doom
+fi
diff --git a/stow/waybar/.local/bin/checkbackup b/stow/waybar/.local/bin/checkbackup
new file mode 100755
index 0000000..24393d1
--- /dev/null
+++ b/stow/waybar/.local/bin/checkbackup
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+set -euo pipefail
+
+if command -v systemctl > /dev/null; then
+ SYSTEMCTLCMD="systemctl"
+fi
+if command -v jq > /dev/null; then
+ JQCMD="jq"
+fi
+if [ -z "${SYSTEMCTLCMD+x}" ] || [ -z "${JQCMD+x}" ]; then
+ echo "{\"tooltip\": \"requires 'jq' and 'systemctl'\", \"text\": \"\"}"
+ exit 1
+fi
+
+backup_metadata_file=/var/cache/borgbackup/last.txt
+
+if [ ! -f "$backup_metadata_file" ]; then
+ echo "{\"tooltip\": \"backup metadata missing\", \"text\": \"\"}"
+ exit 1
+fi
+
+now_ts="$(date +%s)"
+last_backup_ts="$(stat -c %Y "$backup_metadata_file")"
+
+icon=""
+class=""
+output="$(cat "$backup_metadata_file")"
+if [ $(( now_ts - last_backup_ts)) -gt $(( 25 * 60 * 60 )) ]; then
+ class="script-error"
+fi
+# this is a literal expression for `jq`
+# shellcheck disable=SC2016
+$JQCMD --unbuffered -n -c '{tooltip: $ARGS.positional[0], text: $ARGS.positional[1], class: $ARGS.positional[2]}' --args "$output" "$icon" "$class"