commit 25aa4993edcc029ada235df0f774283909bbfaac
parent ac9eb107cfab668c0d6ffe3b8ccc26362230ee96
Author: mtmn <miro@haravara.org>
Date: Fri, 8 May 2026 20:27:41 +0200
chore: run shfmt on all shell scripts
Diffstat:
18 files changed, 398 insertions(+), 360 deletions(-)
diff --git a/modules/mixins/dotfiles/bin/clipmenu b/modules/mixins/dotfiles/bin/clipmenu
@@ -1,7 +1,7 @@
#!/bin/sh
-cliphist list \
- | awk -F'\t' '{print $2 "\t" $1}' \
- | dmenu "$@" \
- | awk -F'\t' '{print $2 "\t" $1}' \
- | cliphist decode \
- | wl-copy
+cliphist list |
+ awk -F'\t' '{print $2 "\t" $1}' |
+ dmenu "$@" |
+ awk -F'\t' '{print $2 "\t" $1}' |
+ cliphist decode |
+ wl-copy
diff --git a/modules/mixins/dotfiles/bin/git-diff-upstream b/modules/mixins/dotfiles/bin/git-diff-upstream
@@ -2,13 +2,13 @@
set -euo pipefail
usage() {
- echo "Usage: $0 --repo <url> --branch <branch> --prefix <path>"
- exit 1
+ echo "Usage: $0 --repo <url> --branch <branch> --prefix <path>"
+ exit 1
}
cleanup() {
- [ -n "${upstream_dir:-}" ] && rm -rf "$upstream_dir"
- [ -n "${upstream_dir:-}" ] && git remote remove "$remote_name"
+ [ -n "${upstream_dir:-}" ] && rm -rf "$upstream_dir"
+ [ -n "${upstream_dir:-}" ] && git remote remove "$remote_name"
}
trap cleanup EXIT
@@ -17,13 +17,25 @@ branch=""
prefix=""
while [[ "$#" -gt 0 ]]; do
- case $1 in
- --repo) repo_url="$2"; shift ;;
- --branch) branch="$2"; shift ;;
- --prefix) prefix="$2"; shift ;;
- *) echo "Unknown parameter: $1"; usage ;;
- esac
- shift
+ case $1 in
+ --repo)
+ repo_url="$2"
+ shift
+ ;;
+ --branch)
+ branch="$2"
+ shift
+ ;;
+ --prefix)
+ prefix="$2"
+ shift
+ ;;
+ *)
+ echo "Unknown parameter: $1"
+ usage
+ ;;
+ esac
+ shift
done
[ -z "$repo_url" ] || [ -z "$branch" ] || [ -z "$prefix" ] && usage
@@ -36,9 +48,9 @@ upstream_dir="${clean_prefix}.upstream"
cd "$(git rev-parse --show-toplevel)"
if ! git remote | grep -q "^${remote_name}$"; then
- git remote add -f "$remote_name" "$repo_url"
+ git remote add -f "$remote_name" "$repo_url"
else
- git fetch "$remote_name"
+ git fetch "$remote_name"
fi
[ -d "$upstream_dir" ] && rm -rf "$upstream_dir"
@@ -46,9 +58,9 @@ mkdir -p "$upstream_dir"
git archive --format=tar "${remote_name}/${branch}" | tar -xf - -C "$upstream_dir"
-if ! command -v difft &> /dev/null; then
- echo "Error: difft (difftastic) not found." >&2
- exit 1
+if ! command -v difft &>/dev/null; then
+ echo "Error: difft (difftastic) not found." >&2
+ exit 1
fi
difft --color=always "$clean_prefix" "$upstream_dir" | less -R
diff --git a/modules/mixins/dotfiles/bin/huemenu b/modules/mixins/dotfiles/bin/huemenu
@@ -2,36 +2,39 @@
set -euo pipefail
if ! mode=$(echo -e "work\nsleep" | dmenu "$@"); then
- exit 1
+ exit 1
fi
[ -z "$mode" ] && exit 1
if ! color=$(echo -e "relax\nconcentrate\nreading\ndimmed\nskip\noff" | dmenu "$@"); then
- exit 1
+ exit 1
fi
[ -z "$color" ] && exit 1
brightness="skip"
if [ "$color" != "off" ]; then
- if ! brightness=$(seq 100 -10 10 | sed 's/$/%/' | dmenu "$@"); then
- exit 1
- fi
- [ -z "$brightness" ] && exit 1
+ if ! brightness=$(seq 100 -10 10 | sed 's/$/%/' | dmenu "$@"); then
+ exit 1
+ fi
+ [ -z "$brightness" ] && exit 1
fi
case "$mode" in
- work) light_id=2 ;;
- sleep) light_id=1 ;;
- *) echo "Error: Unknown mode '$mode'" >&2; exit 1 ;;
+work) light_id=2 ;;
+sleep) light_id=1 ;;
+*)
+ echo "Error: Unknown mode '$mode'" >&2
+ exit 1
+ ;;
esac
if [ "$color" = "off" ]; then
- hue "$light_id" off || echo "Warning: Failed to turn off light $light_id" >&2
+ hue "$light_id" off || echo "Warning: Failed to turn off light $light_id" >&2
else
- if [ "$color" != "skip" ]; then
- hue light "$light_id" "$color" || echo "Warning: Failed to set color '$color' for light $light_id" >&2
- fi
- if [ "$brightness" != "skip" ]; then
- hue "$light_id" brightness "$brightness" || echo "Warning: Failed to set brightness '$brightness' for light $light_id" >&2
- fi
+ if [ "$color" != "skip" ]; then
+ hue light "$light_id" "$color" || echo "Warning: Failed to set color '$color' for light $light_id" >&2
+ fi
+ if [ "$brightness" != "skip" ]; then
+ hue "$light_id" brightness "$brightness" || echo "Warning: Failed to set brightness '$brightness' for light $light_id" >&2
+ fi
fi
diff --git a/modules/mixins/dotfiles/bin/langmenu b/modules/mixins/dotfiles/bin/langmenu
@@ -5,22 +5,22 @@ choice=$(echo -e "en\nsk" | dmenu "$@")
[ -z "$choice" ] && exit 0
case "$choice" in
- en)
- if [ -n "${WAYLAND_DISPLAY:-}" ]; then
- riverctl keyboard-layout us
- else
- setxkbmap us
- fi
- ;;
- sk)
- if [ -n "${WAYLAND_DISPLAY:-}" ]; then
- riverctl keyboard-layout -variant qwerty sk
- else
- setxkbmap sk qwerty
- fi
- ;;
- *)
- echo "Error: Unknown layout '$choice'" >&2
- exit 1
- ;;
+en)
+ if [ -n "${WAYLAND_DISPLAY:-}" ]; then
+ riverctl keyboard-layout us
+ else
+ setxkbmap us
+ fi
+ ;;
+sk)
+ if [ -n "${WAYLAND_DISPLAY:-}" ]; then
+ riverctl keyboard-layout -variant qwerty sk
+ else
+ setxkbmap sk qwerty
+ fi
+ ;;
+*)
+ echo "Error: Unknown layout '$choice'" >&2
+ exit 1
+ ;;
esac
diff --git a/modules/mixins/dotfiles/bin/moshrc b/modules/mixins/dotfiles/bin/moshrc
@@ -1,20 +1,19 @@
#!/usr/bin/env bash
# moshrc is an alternative to sshrc for mosh users
-
function moshrc() {
- local SSHHOME=${SSHHOME:=~}
- if [ -f $SSHHOME/.sshrc ]; then
- local files=.sshrc
- if [ -d $SSHHOME/.sshrc.d ]; then
- files="$files .sshrc.d"
- fi
- SIZE=$(tar cfz - -h -C $SSHHOME $files | wc -c)
- if [ $SIZE -gt 65536 ]; then
- echo >&2 $'.sshrc.d and .sshrc files must be less than 64kb\ncurrent size: '$SIZE' bytes'
- exit 1
- fi
- mosh "$@" -- /bin/bash -c "
+ local SSHHOME=${SSHHOME:=~}
+ if [ -f $SSHHOME/.sshrc ]; then
+ local files=.sshrc
+ if [ -d $SSHHOME/.sshrc.d ]; then
+ files="$files .sshrc.d"
+ fi
+ SIZE=$(tar cfz - -h -C $SSHHOME $files | wc -c)
+ if [ $SIZE -gt 65536 ]; then
+ echo >&2 $'.sshrc.d and .sshrc files must be less than 64kb\ncurrent size: '$SIZE' bytes'
+ exit 1
+ fi
+ mosh "$@" -- /bin/bash -c "
command -v xxd >/dev/null 2>&1 || { echo >&2 \"sshrc requires xxd to be installed on the server, but it's not. Aborting.\"; exit 1; }
if [ -e /etc/motd ]; then cat /etc/motd; fi
if [ -e /etc/update-motd.d ]; then run-parts /etc/update-motd.d/; fi
@@ -24,15 +23,17 @@ function moshrc() {
echo $'$(cat $0 | xxd -p)' | xxd -p -r > \$SSHHOME/moshrc
chmod +x \$SSHHOME/moshrc
- echo $'$( cat << 'EOF' | xxd -p
+ echo $'$(
+ cat <<'EOF' | xxd -p
if [ -e /etc/bash.bashrc ]; then source /etc/bash.bashrc; fi
if [ -e ~/.bashrc ]; then source ~/.bashrc; fi
source $SSHHOME/.sshrc;
export PATH=$PATH:$SSHHOME
EOF
-)' | xxd -p -r > \$SSHHOME/sshrc.bashrc
+ )' | xxd -p -r > \$SSHHOME/sshrc.bashrc
- echo $'$( cat << 'EOF' | xxd -p
+ echo $'$(
+ cat <<'EOF' | xxd -p
#!/usr/bin/env bash
exec bash --rcfile <(echo '
if [ -e /etc/bash.bashrc ]; then source /etc/bash.bashrc; fi
@@ -41,20 +42,23 @@ source '$SSHHOME'/.sshrc;
export PATH=$PATH:'$SSHHOME'
') "$@"
EOF
-)' | xxd -p -r > \$SSHHOME/bashsshrc
+ )' | xxd -p -r > \$SSHHOME/bashsshrc
chmod +x \$SSHHOME/bashsshrc
echo $'$(tar czf - -h -C $SSHHOME $files | xxd -p)' | xxd -p -r | tar mxzf - -C \$SSHHOME
export SSHHOME=\$SSHHOME
bash --rcfile \$SSHHOME/sshrc.bashrc
"
- else
- echo "No such file: $SSHHOME/.sshrc"
- fi
+ else
+ echo "No such file: $SSHHOME/.sshrc"
+ fi
}
if [ "$1" ]; then
- command -v xxd >/dev/null 2>&1 || { echo >&2 "sshrc requires xxd to be installed locally, but it's not. Aborting."; exit 1; }
- moshrc "$@"
+ command -v xxd >/dev/null 2>&1 || {
+ echo >&2 "sshrc requires xxd to be installed locally, but it's not. Aborting."
+ exit 1
+ }
+ moshrc "$@"
else
- ssh
+ ssh
fi
diff --git a/modules/mixins/dotfiles/bin/nota b/modules/mixins/dotfiles/bin/nota
@@ -15,55 +15,55 @@ cd -- "$data_dir" || exit
: "${GPG=0}"
editor=${EDITOR:-${VISUAL:-vi}}
-(( GPG )) && editor=${PGP_EDITOR:-"$editor"}
+((GPG)) && editor=${PGP_EDITOR:-"$editor"}
-if (( NOTA_READ_ONLY )); then
- # The linter is wrong here, we don't want to do $(cat).
- # shellcheck disable=SC2209
- editor=cat
- (( GPG )) && editor='gpg -q -d'
+if ((NOTA_READ_ONLY)); then
+ # The linter is wrong here, we don't want to do $(cat).
+ # shellcheck disable=SC2209
+ editor=cat
+ ((GPG)) && editor='gpg -q -d'
fi
unsanitised_basename=${1:-"$(date +%F)"}
case $unsanitised_basename in
- git|ls) exec "$@" ;;
- *' days ago'|yesterday|tomorrow|today)
- unsanitised_basename=$(date -d "$unsanitised_basename" +%F)
- ;;
+git | ls) exec "$@" ;;
+*' days ago' | yesterday | tomorrow | today)
+ unsanitised_basename=$(date -d "$unsanitised_basename" +%F)
+ ;;
esac
basename=${unsanitised_basename//\//_}
file=$data_dir/$basename
-(( GPG )) && file=$file.gpg
-(( MARKDOWN )) && file=$file.md
+((GPG)) && file=$file.gpg
+((MARKDOWN)) && file=$file.md
lock_base="$file.lock"
lock="$lock_base.$$"
-if ! (( NOTA_READ_ONLY )); then
- for existing_lock_file in "$lock_base".*; do
- pid=${existing_lock_file##*.}
- if [[ -d "/proc/$pid" ]]; then
- printf 'Refusing to open %s as it is locked\n' "$file" >&2
- exit 6
- else
- printf 'Removing stale lock %s\n' "$existing_lock_file" >&2
- rmdir -- "$existing_lock_file"
- fi
- done
-
- trap 'rmdir -- "$lock"' EXIT
- mkdir -- "$lock"
+if ! ((NOTA_READ_ONLY)); then
+ for existing_lock_file in "$lock_base".*; do
+ pid=${existing_lock_file##*.}
+ if [[ -d "/proc/$pid" ]]; then
+ printf 'Refusing to open %s as it is locked\n' "$file" >&2
+ exit 6
+ else
+ printf 'Removing stale lock %s\n' "$existing_lock_file" >&2
+ rmdir -- "$existing_lock_file"
+ fi
+ done
+
+ trap 'rmdir -- "$lock"' EXIT
+ mkdir -- "$lock"
fi
$editor -- "$file"
-(( NOTA_READ_ONLY )) && exit 0
+((NOTA_READ_ONLY)) && exit 0
if ! [[ -f "$file" ]]; then
- printf 'Not committing as %s is missing\n' "$unsanitised_basename" >&2
- exit 5
+ printf 'Not committing as %s is missing\n' "$unsanitised_basename" >&2
+ exit 5
fi
git init
diff --git a/modules/mixins/dotfiles/bin/nsxiv-rifle b/modules/mixins/dotfiles/bin/nsxiv-rifle
@@ -4,32 +4,33 @@ TMPDIR="${TMPDIR:-/tmp}"
tmp="$TMPDIR/nsxiv_rifle_$$"
is_img_extension() {
- grep -iE '\.(jpe?g|png|gif|svg|jxl|webp|tiff|heif|avif|ico|bmp|pam|pbm|ppm|tga|qoi|ff)$'
+ grep -iE '\.(jpe?g|png|gif|svg|jxl|webp|tiff|heif|avif|ico|bmp|pam|pbm|ppm|tga|qoi|ff)$'
}
listfiles() {
- find -L "$1" -maxdepth 1 -type f -print |
- is_img_extension | sort | tee "$tmp"
+ find -L "$1" -maxdepth 1 -type f -print |
+ is_img_extension | sort | tee "$tmp"
}
open_img() {
- file="$1"; shift;
- # only go through listfiles() if the file has a valid img extension
- if echo "$file" | is_img_extension >/dev/null 2>&1; then
- trap 'rm -f $tmp' EXIT
- count="$(listfiles "///${file%/*}" | grep -nF "$file")"
- fi
- if [ -n "$count" ]; then
- nsxiv -i -n "${count%%:*}" "$@" < "$tmp"
- else
- # fallback incase file didn't have a valid extension, or we couldn't
- # find it inside the list
- nsxiv "$file" "$@"
- fi
+ file="$1"
+ shift
+ # only go through listfiles() if the file has a valid img extension
+ if echo "$file" | is_img_extension >/dev/null 2>&1; then
+ trap 'rm -f $tmp' EXIT
+ count="$(listfiles "///${file%/*}" | grep -nF "$file")"
+ fi
+ if [ -n "$count" ]; then
+ nsxiv -i -n "${count%%:*}" "$@" <"$tmp"
+ else
+ # fallback incase file didn't have a valid extension, or we couldn't
+ # find it inside the list
+ nsxiv "$file" "$@"
+ fi
}
uri2path() {
- python3 - "$@" <<'___HEREDOC'
+ python3 - "$@" <<'___HEREDOC'
from urllib.parse import unquote, urlparse
from sys import argv
for arg in argv[1:]:
@@ -37,15 +38,19 @@ for arg in argv[1:]:
___HEREDOC
}
-file="$1"; shift;
+file="$1"
+shift
case "$file" in
- "") echo "Usage: ${0##*/} PICTURE [OPTIONS...]" >&2; exit 1 ;;
- /*) open_img "$file" "$@" ;;
- "~"/*) open_img "$HOME/${file#"~"/}" "$@" ;;
- file:///*) open_img "$(uri2path "$file")" "$@" ;;
- trash:///*)
- trash_dir="${XDG_DATA_HOME:-$HOME/.local/share}/Trash/files"
- open_img "${trash_dir}$(uri2path "$file")" -N "nsxiv_trash" "$@"
- ;;
- *) open_img "$PWD/$file" "$@" ;;
+"")
+ echo "Usage: ${0##*/} PICTURE [OPTIONS...]" >&2
+ exit 1
+ ;;
+/*) open_img "$file" "$@" ;;
+"~"/*) open_img "$HOME/${file#"~"/}" "$@" ;;
+file:///*) open_img "$(uri2path "$file")" "$@" ;;
+trash:///*)
+ trash_dir="${XDG_DATA_HOME:-$HOME/.local/share}/Trash/files"
+ open_img "${trash_dir}$(uri2path "$file")" -N "nsxiv_trash" "$@"
+ ;;
+*) open_img "$PWD/$file" "$@" ;;
esac
diff --git a/modules/mixins/dotfiles/bin/passmenu b/modules/mixins/dotfiles/bin/passmenu
@@ -8,19 +8,19 @@ prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
prefix="${prefix%/}/"
if [ ! -d "$prefix" ]; then
- echo "Error: Password store '$prefix' not found" >&2
- exit 1
+ echo "Error: Password store '$prefix' not found" >&2
+ exit 1
fi
-password_files=( "$prefix"**/*.gpg )
-password_files=( "${password_files[@]#"$prefix"}" )
-password_files=( "${password_files[@]%.gpg}" )
+password_files=("$prefix"**/*.gpg)
+password_files=("${password_files[@]#"$prefix"}")
+password_files=("${password_files[@]%.gpg}")
password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@")
[ -z "$password" ] && exit 0
if [[ "$password" == *otp* ]]; then
- pass otp -c "$password" >/dev/null 2>&1
+ pass otp -c "$password" >/dev/null 2>&1
else
- pass show -c "$password" >/dev/null 2>&1
+ pass show -c "$password" >/dev/null 2>&1
fi
diff --git a/modules/mixins/dotfiles/bin/plsmenu b/modules/mixins/dotfiles/bin/plsmenu
@@ -6,19 +6,19 @@ year=$(date "+%y")
month_sanitized=".${month}_${year}"
options=(
- "$month_sanitized"
- "infame"
- "ambient"
- "experimental"
- "club"
- "mud"
- "weird"
- "bass"
- "140"
- "match"
- "sad"
- "happy"
- "screenshots"
+ "$month_sanitized"
+ "infame"
+ "ambient"
+ "experimental"
+ "club"
+ "mud"
+ "weird"
+ "bass"
+ "140"
+ "match"
+ "sad"
+ "happy"
+ "screenshots"
)
choice=$(printf '%s\n' "${options[@]}" | dmenu "$@")
@@ -26,9 +26,9 @@ choice=$(printf '%s\n' "${options[@]}" | dmenu "$@")
[ -z "$choice" ] && exit 0
if [ "$choice" = "$month" ]; then
- playlist="$current_month_playlist"
+ playlist="$current_month_playlist"
else
- playlist="$choice"
+ playlist="$choice"
fi
eval "$("$HOME/bin/amen-or-not")" && zsh -c "mpd_add_to_playlist '$playlist'"
diff --git a/modules/mixins/dotfiles/bin/qw b/modules/mixins/dotfiles/bin/qw
@@ -1,9 +1,9 @@
#!/usr/bin/env bash
qemu-system-x86_64 -M q35,usb=on,acpi=on,hpet=off -m 2G \
- -cpu host,hv_relaxed,hv_frequencies,hv_vpindex,hv_ipi,hv_tlbflush,hv_spinlocks=0x1fff,hv_synic,hv_runtime,hv_time,hv_stimer,hv_vapic \
- -smp cores=2 -accel kvm -drive file="$HOME"/misc/random/win7.qcow2 -device usb-tablet \
- -device VGA,vgamem_mb=128 -nic user,model=e1000 -monitor stdio \
- -device usb-ehci,id=ehci \
- -device usb-host,bus=ehci.0,vendorid=0x0781,productid=0x5588 \
- -audiodev pipewire,id=snd0 -device intel-hda -device hda-duplex,audiodev=snd0 \
- -drive file=fat:rw:"$HOME"/misc/random/qemu_shared/,format=raw,media=disk
+ -cpu host,hv_relaxed,hv_frequencies,hv_vpindex,hv_ipi,hv_tlbflush,hv_spinlocks=0x1fff,hv_synic,hv_runtime,hv_time,hv_stimer,hv_vapic \
+ -smp cores=2 -accel kvm -drive file="$HOME"/misc/random/win7.qcow2 -device usb-tablet \
+ -device VGA,vgamem_mb=128 -nic user,model=e1000 -monitor stdio \
+ -device usb-ehci,id=ehci \
+ -device usb-host,bus=ehci.0,vendorid=0x0781,productid=0x5588 \
+ -audiodev pipewire,id=snd0 -device intel-hda -device hda-duplex,audiodev=snd0 \
+ -drive file=fat:rw:"$HOME"/misc/random/qemu_shared/,format=raw,media=disk
diff --git a/modules/mixins/dotfiles/bin/remind b/modules/mixins/dotfiles/bin/remind
@@ -12,9 +12,9 @@ LOG_FILE="$HOME/.remind_history"
# Check if parameters are provided
if [ $# -lt 2 ]; then
- echo "Usage: remind <time> \"<message>\""
- echo "Time formats: 30s, 5m, 2h, 1d, or HH:MM"
- exit 1
+ echo "Usage: remind <time> \"<message>\""
+ echo "Time formats: 30s, 5m, 2h, 1d, or HH:MM"
+ exit 1
fi
# Parse time and message
@@ -23,30 +23,30 @@ MESSAGE="$2"
# Check if the time is in HH:MM format
if [[ "$TIME" =~ ^([0-1][0-9]|2[0-3]):([0-5][0-9])$ ]]; then
- # Calculate seconds until the specified time
- CURRENT_TIME=$(date +%s)
- TARGET_TIME=$(date -d "$(date +%Y-%m-%d) $TIME" +%s)
+ # Calculate seconds until the specified time
+ CURRENT_TIME=$(date +%s)
+ TARGET_TIME=$(date -d "$(date +%Y-%m-%d) $TIME" +%s)
- # If the target time is already passed for today, schedule for tomorrow
- if [ $TARGET_TIME -le $CURRENT_TIME ]; then
- TARGET_TIME=$(date -d "$(date -d 'tomorrow' +%Y-%m-%d) $TIME" +%s)
- fi
+ # If the target time is already passed for today, schedule for tomorrow
+ if [ $TARGET_TIME -le $CURRENT_TIME ]; then
+ TARGET_TIME=$(date -d "$(date -d 'tomorrow' +%Y-%m-%d) $TIME" +%s)
+ fi
- SECONDS=$((TARGET_TIME - CURRENT_TIME))
- TRIGGER_TIME=$(date -d "@$TARGET_TIME" "+%Y-%m-%d %H:%M:%S")
- SLEEP_ARG="${SECONDS}s"
+ SECONDS=$((TARGET_TIME - CURRENT_TIME))
+ TRIGGER_TIME=$(date -d "@$TARGET_TIME" "+%Y-%m-%d %H:%M:%S")
+ SLEEP_ARG="${SECONDS}s"
else
- # Handle relative time formats (30s, 5m, 2h, 1d)
- case "$TIME" in
- *s) SECONDS="${TIME%s}" ;;
- *m) SECONDS=$((${TIME%m} * 60)) ;;
- *h) SECONDS=$((${TIME%h} * 3600)) ;;
- *d) SECONDS=$((${TIME%d} * 86400)) ;;
- *) SECONDS="$TIME" ;;
- esac
+ # Handle relative time formats (30s, 5m, 2h, 1d)
+ case "$TIME" in
+ *s) SECONDS="${TIME%s}" ;;
+ *m) SECONDS=$((${TIME%m} * 60)) ;;
+ *h) SECONDS=$((${TIME%h} * 3600)) ;;
+ *d) SECONDS=$((${TIME%d} * 86400)) ;;
+ *) SECONDS="$TIME" ;;
+ esac
- TRIGGER_TIME=$(date -d "+$SECONDS seconds" "+%Y-%m-%d %H:%M:%S")
- SLEEP_ARG="$TIME"
+ TRIGGER_TIME=$(date -d "+$SECONDS seconds" "+%Y-%m-%d %H:%M:%S")
+ SLEEP_ARG="$TIME"
fi
# Create the reminder files if they don't exist
@@ -54,17 +54,17 @@ touch "$REMINDER_FILE"
touch "$LOG_FILE"
# Log the reminder
-echo "[$TRIGGER_TIME] $MESSAGE" >> "$LOG_FILE"
+echo "[$TRIGGER_TIME] $MESSAGE" >>"$LOG_FILE"
# Schedule the notification
(
- sleep "$SLEEP_ARG"
- notify-send -u critical "Reminder" "$MESSAGE"
- echo "Completed: [$TRIGGER_TIME] $MESSAGE" >> "$LOG_FILE"
- # Remove from active reminders file once completed
- sed -i "\|^\[$TRIGGER_TIME\] $MESSAGE$|d" "$REMINDER_FILE"
+ sleep "$SLEEP_ARG"
+ notify-send -u critical "Reminder" "$MESSAGE"
+ echo "Completed: [$TRIGGER_TIME] $MESSAGE" >>"$LOG_FILE"
+ # Remove from active reminders file once completed
+ sed -i "\|^\[$TRIGGER_TIME\] $MESSAGE$|d" "$REMINDER_FILE"
) &
# Show confirmation
echo "Reminder set for $TRIGGER_TIME: $MESSAGE"
-echo "[$TRIGGER_TIME] $MESSAGE" >> "$REMINDER_FILE"
+echo "[$TRIGGER_TIME] $MESSAGE" >>"$REMINDER_FILE"
diff --git a/modules/mixins/dotfiles/bin/screenshot b/modules/mixins/dotfiles/bin/screenshot
@@ -4,38 +4,38 @@ timestamp=$(date +%s)
screenshot_file="$HOME/misc/screenshots/${timestamp}.png"
take_screenshot() {
- local temp_file="$1"
+ local temp_file="$1"
- if [ -n "$WAYLAND_DISPLAY" ]; then
- area=$(slurp 2>/dev/null) || return 1
- grim -g "$area" "$temp_file" || return 1
- else
- selection=$(hacksaw -f "-i %i -g %g" 2>/dev/null) || return 1
- shotgun "$selection" "$temp_file" || return 1
- fi
+ if [ -n "$WAYLAND_DISPLAY" ]; then
+ area=$(slurp 2>/dev/null) || return 1
+ grim -g "$area" "$temp_file" || return 1
+ else
+ selection=$(hacksaw -f "-i %i -g %g" 2>/dev/null) || return 1
+ shotgun "$selection" "$temp_file" || return 1
+ fi
- return 0
+ return 0
}
copy_to_clipboard() {
- local file="$1"
+ local file="$1"
- if [ -n "$WAYLAND_DISPLAY" ]; then
- wl-copy < "$file"
- else
- xclip -t 'image/png' -selection clipboard < "$file"
- fi
+ if [ -n "$WAYLAND_DISPLAY" ]; then
+ wl-copy <"$file"
+ else
+ xclip -t 'image/png' -selection clipboard <"$file"
+ fi
}
if take_screenshot "$screenshot_file"; then
- if [ -f "$screenshot_file" ] && [ -s "$screenshot_file" ]; then
- copy_to_clipboard "$screenshot_file"
- else
- rm -f "$screenshot_file"
- echo "no content captured" >&2
- exit 1
- fi
+ if [ -f "$screenshot_file" ] && [ -s "$screenshot_file" ]; then
+ copy_to_clipboard "$screenshot_file"
+ else
+ rm -f "$screenshot_file"
+ echo "no content captured" >&2
+ exit 1
+ fi
else
- echo "screenshot cancelled or failed"
- exit 1
+ echo "screenshot cancelled or failed"
+ exit 1
fi
diff --git a/modules/mixins/dotfiles/bin/seek b/modules/mixins/dotfiles/bin/seek
@@ -1,46 +1,45 @@
#!/bin/bash
-
if [ $# -eq 0 ]; then
- echo "Usage: $0 <percentage>"
- echo "Example: $0 25 # seeks to 25% of current track"
- exit 1
+ echo "Usage: $0 <percentage>"
+ echo "Example: $0 25 # seeks to 25% of current track"
+ exit 1
fi
percentage=$1
-if ! [[ "$percentage" =~ ^[0-9]+(\.[0-9]+)?$ ]] || (( $(echo "$percentage > 100" | bc -l) )); then
- echo "Error: Please provide a valid percentage (0-100)"
- exit 1
+if ! [[ "$percentage" =~ ^[0-9]+(\.[0-9]+)?$ ]] || (($(echo "$percentage > 100" | bc -l))); then
+ echo "Error: Please provide a valid percentage (0-100)"
+ exit 1
fi
status=$(mpc status)
if ! echo "$status" | grep -q "playing\|paused"; then
- echo "Error: No track is currently loaded"
- exit 1
+ echo "Error: No track is currently loaded"
+ exit 1
fi
time_info=$(echo "$status" | grep -o '[0-9]*:[0-9]*/[0-9]*:[0-9]*')
if [ -z "$time_info" ]; then
- echo "Error: Could not get track duration information"
- exit 1
+ echo "Error: Could not get track duration information"
+ exit 1
fi
total_time=$(echo "$time_info" | cut -d'/' -f2)
# Convert total time to seconds
-IFS=':' read -ra time_parts <<< "$total_time"
+IFS=':' read -ra time_parts <<<"$total_time"
if [ ${#time_parts[@]} -eq 2 ]; then
- # Format is MM:SS
- total_seconds=$((${time_parts[0]} * 60 + ${time_parts[1]}))
+ # Format is MM:SS
+ total_seconds=$((${time_parts[0]} * 60 + ${time_parts[1]}))
elif [ ${#time_parts[@]} -eq 3 ]; then
- # Format is HH:MM:SS
- total_seconds=$((${time_parts[0]} * 3600 + ${time_parts[1]} * 60 + ${time_parts[2]}))
+ # Format is HH:MM:SS
+ total_seconds=$((${time_parts[0]} * 3600 + ${time_parts[1]} * 60 + ${time_parts[2]}))
else
- echo "Error: Could not parse time format"
- exit 1
+ echo "Error: Could not parse time format"
+ exit 1
fi
# Calculate target position in seconds
diff --git a/modules/mixins/dotfiles/bin/shirt b/modules/mixins/dotfiles/bin/shirt
Binary files differ.
diff --git a/modules/mixins/dotfiles/bin/sshrc b/modules/mixins/dotfiles/bin/sshrc
@@ -1,28 +1,28 @@
#!/usr/bin/env bash
function sshrc() {
- local SSHHOME=${SSHHOME:=~}
- if [ -f $SSHHOME/.sshrc ]; then
- local files=.sshrc
- if [ -d $SSHHOME/.sshrc.d ]; then
- files="$files .sshrc.d"
- fi
- SIZE=$(tar cfz - -h -C $SSHHOME $files | wc -c)
- if [ $SIZE -gt 65536 ]; then
- echo >&2 $'.sshrc.d and .sshrc files must be less than 64kb\ncurrent size: '$SIZE' bytes'
- exit 1
- fi
- if [ -z "$CMDARG" -a ! -e ~/.sshrc.d/.hushlogin ]; then
- WELCOME_MSG="
+ local SSHHOME=${SSHHOME:=~}
+ if [ -f $SSHHOME/.sshrc ]; then
+ local files=.sshrc
+ if [ -d $SSHHOME/.sshrc.d ]; then
+ files="$files .sshrc.d"
+ fi
+ SIZE=$(tar cfz - -h -C $SSHHOME $files | wc -c)
+ if [ $SIZE -gt 65536 ]; then
+ echo >&2 $'.sshrc.d and .sshrc files must be less than 64kb\ncurrent size: '$SIZE' bytes'
+ exit 1
+ fi
+ if [ -z "$CMDARG" -a ! -e ~/.sshrc.d/.hushlogin ]; then
+ WELCOME_MSG="
if [ ! -e ~/.hushlogin ]; then
if [ -e /etc/motd ]; then cat /etc/motd; fi
if [ -e /etc/update-motd.d ]; then run-parts /etc/update-motd.d/ 2>/dev/null; fi
last -F \$USER 2>/dev/null | grep -v 'still logged in' | head -n1 | awk '{print \"Last login:\",\$4,\$5,\$6,\$7,\$8,\"from\",\$3;}'
fi
"
- else
- WELCOME_MSG=""
- fi
- ssh -t "$DOMAIN" $SSHARGS "
+ else
+ WELCOME_MSG=""
+ fi
+ ssh -t "$DOMAIN" $SSHARGS "
command -v openssl >/dev/null 2>&1 || { echo >&2 \"sshrc requires openssl to be installed on the server, but it's not. Aborting.\"; exit 1; }
$WELCOME_MSG
export SSHHOME=\$(mktemp -d -t .$(whoami).sshrc.XXXX)
@@ -30,7 +30,8 @@ function sshrc() {
trap \"rm -rf \$SSHRCCLEANUP; exit\" 0
echo $'"$(cat "$0" | openssl enc -base64)"' | tr -s ' ' $'\n' | openssl enc -base64 -d > \$SSHHOME/sshrc
chmod +x \$SSHHOME/sshrc
- echo $'"$( cat << 'EOF' | openssl enc -base64
+ echo $'"$(
+ cat <<'EOF' | openssl enc -base64
if [ -r /etc/profile ]; then source /etc/profile; fi
if [ -r ~/.bash_profile ]; then source ~/.bash_profile
elif [ -r ~/.bash_login ]; then source ~/.bash_login
@@ -39,8 +40,9 @@ function sshrc() {
export PATH=$PATH:$SSHHOME
source $SSHHOME/.sshrc;
EOF
- )"' | tr -s ' ' $'\n' | openssl enc -base64 -d > \$SSHHOME/sshrc.bashrc
- echo $'"$( cat << 'EOF' | openssl enc -base64
+ )"' | tr -s ' ' $'\n' | openssl enc -base64 -d > \$SSHHOME/sshrc.bashrc
+ echo $'"$(
+ cat <<'EOF' | openssl enc -base64
#!/usr/bin/env bash
exec bash --rcfile <(echo '
[ -r /etc/profile ] && source /etc/profile
@@ -52,41 +54,48 @@ EOF
export PATH=$PATH:'$SSHHOME'
') ${@:+"$@"}
EOF
- )"' | tr -s ' ' $'\n' | openssl enc -base64 -d > \$SSHHOME/bashsshrc
+ )"' | tr -s ' ' $'\n' | openssl enc -base64 -d > \$SSHHOME/bashsshrc
chmod +x \$SSHHOME/bashsshrc
echo $'"$(tar czf - -h -C $SSHHOME $files | openssl enc -base64)"' | tr -s ' ' $'\n' | openssl enc -base64 -d | tar mxzf - -C \$SSHHOME
export SSHHOME=\$SSHHOME
echo \"$CMDARG\" >> \$SSHHOME/sshrc.bashrc
bash --rcfile \$SSHHOME/sshrc.bashrc
"
- else
- echo "No such file: $SSHHOME/.sshrc" >&2
- exit 1
- fi
+ else
+ echo "No such file: $SSHHOME/.sshrc" >&2
+ exit 1
+ fi
}
function sshrc_parse() {
- while [[ -n $1 ]]; do
- case $1 in
- -b | -c | -D | -E | -e | -F | -I | -i | -J | -L | -l | -m | -O | -o | -p | -Q | -R | -S | -W | -w )
- SSHARGS="$SSHARGS $1 $2"; shift ;;
- -* )
- SSHARGS="$SSHARGS $1" ;;
- *)
- if [ -z "$DOMAIN" ]; then
- DOMAIN="$1"
- else
- local SEMICOLON=$([[ "$@" = *[![:space:]]* ]] && echo '; ')
- CMDARG="$@$SEMICOLON exit"
- return;
- fi
- ;;
- esac
- shift
- done
- if [ -z $DOMAIN ]; then
- ssh $SSHARGS; exit 1;
- fi
+ while [[ -n $1 ]]; do
+ case $1 in
+ -b | -c | -D | -E | -e | -F | -I | -i | -J | -L | -l | -m | -O | -o | -p | -Q | -R | -S | -W | -w)
+ SSHARGS="$SSHARGS $1 $2"
+ shift
+ ;;
+ -*)
+ SSHARGS="$SSHARGS $1"
+ ;;
+ *)
+ if [ -z "$DOMAIN" ]; then
+ DOMAIN="$1"
+ else
+ local SEMICOLON=$([[ "$@" = *[![:space:]]* ]] && echo '; ')
+ CMDARG="$@$SEMICOLON exit"
+ return
+ fi
+ ;;
+ esac
+ shift
+ done
+ if [ -z $DOMAIN ]; then
+ ssh $SSHARGS
+ exit 1
+ fi
+}
+command -v openssl >/dev/null 2>&1 || {
+ echo >&2 "sshrc requires openssl to be installed locally, but it's not. Aborting."
+ exit 1
}
-command -v openssl >/dev/null 2>&1 || { echo >&2 "sshrc requires openssl to be installed locally, but it's not. Aborting."; exit 1; }
sshrc_parse "$@"
sshrc
diff --git a/modules/mixins/dotfiles/bin/tempmenu b/modules/mixins/dotfiles/bin/tempmenu
@@ -1,24 +1,27 @@
#!/bin/bash
set -euo pipefail
-choices=$(echo "off"; seq 6000 -500 1000)
+choices=$(
+ echo "off"
+ seq 6000 -500 1000
+)
chosen=$(printf '%s\n' "$choices" | dmenu "$@")
[ -z "$chosen" ] && exit 0
if [ "$chosen" != "off" ] && ! [[ "$chosen" =~ ^[0-9]+$ ]]; then
- echo "Error: Invalid temperature '$chosen'" >&2
- exit 1
+ echo "Error: Invalid temperature '$chosen'" >&2
+ exit 1
fi
if [ -n "${WAYLAND_DISPLAY:-}" ]; then
- pkill gammastep || true
- if [ "$chosen" != "off" ]; then
- gammastep -O "$chosen" &
- fi
+ pkill gammastep || true
+ if [ "$chosen" != "off" ]; then
+ gammastep -O "$chosen" &
+ fi
else
- if [ "$chosen" = "off" ]; then
- redshift -x
- else
- redshift -O "$chosen"
- fi
+ if [ "$chosen" = "off" ]; then
+ redshift -x
+ else
+ redshift -O "$chosen"
+ fi
fi
diff --git a/modules/mixins/dotfiles/bin/todo-notify b/modules/mixins/dotfiles/bin/todo-notify
@@ -4,11 +4,11 @@ TODO_FILE="$HOME/misc/notes/nota/todo.txt"
current_date=""
while IFS= read -r line || [[ -n "$line" ]]; do
- if [[ "$line" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2} ]]; then
- current_date="$line"
- elif [[ "$line" =~ ^todo:\ (.*)$ ]]; then
- todo_message="${BASH_REMATCH[1]}"
- notify-send "$current_date" "$todo_message"
- wait
- fi
-done < "$TODO_FILE"
+ if [[ "$line" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2} ]]; then
+ current_date="$line"
+ elif [[ "$line" =~ ^todo:\ (.*)$ ]]; then
+ todo_message="${BASH_REMATCH[1]}"
+ notify-send "$current_date" "$todo_message"
+ wait
+ fi
+done <"$TODO_FILE"
diff --git a/modules/mixins/dotfiles/bin/wl-color-picker b/modules/mixins/dotfiles/bin/wl-color-picker
@@ -13,43 +13,43 @@
#
showhelp() {
- echo "A basic wlroots compatible color picker script."
- echo ""
- echo "Usage:"
- echo " wl-color-picker [command] [options]"
- echo ""
- echo "Commands:"
- echo " clipboard Copy color to clipboard without dialog"
- echo " --no-notify Don't show a system notification of copied color"
+ echo "A basic wlroots compatible color picker script."
+ echo ""
+ echo "Usage:"
+ echo " wl-color-picker [command] [options]"
+ echo ""
+ echo "Commands:"
+ echo " clipboard Copy color to clipboard without dialog"
+ echo " --no-notify Don't show a system notification of copied color"
}
CLIPBOARD=0
NO_NOTIFY=0
while [ "$1" ]; do
- case $1 in
- '-h' | '--help' | 'help' | '?' )
- showhelp
- exit
- ;;
- 'clipboard' )
- CLIPBOARD=1
- ;;
- '--no-notify' )
- NO_NOTIFY=1
- ;;
- esac
+ case $1 in
+ '-h' | '--help' | 'help' | '?')
+ showhelp
+ exit
+ ;;
+ 'clipboard')
+ CLIPBOARD=1
+ ;;
+ '--no-notify')
+ NO_NOTIFY=1
+ ;;
+ esac
- shift
+ shift
done
# Check if running under wayland.
if [ "$WAYLAND_DISPLAY" = "" ]; then
- zenity --error --width 400 \
- --title "No wayland session found." \
- --text "This color picker must be run under a valid wayland session."
+ zenity --error --width 400 \
+ --title "No wayland session found." \
+ --text "This color picker must be run under a valid wayland session."
- exit 1
+ exit 1
fi
# Get color position
@@ -60,43 +60,46 @@ position=$(slurp -b 00000000 -p)
sleep 1
# Store the hex color value using graphicsmagick or imagemagick.
-if command -v /usr/bin/gm &> /dev/null; then
- color=$(grim -g "$position" -t png - \
- | /usr/bin/gm convert - -format '%[pixel:p{0,0}]' txt:- \
- | tail -n 1 \
- | rev \
- | cut -d ' ' -f 1 \
- | rev
- )
+if command -v /usr/bin/gm &>/dev/null; then
+ color=$(
+ grim -g "$position" -t png - |
+ /usr/bin/gm convert - -format '%[pixel:p{0,0}]' txt:- |
+ tail -n 1 |
+ rev |
+ cut -d ' ' -f 1 |
+ rev
+ )
else
- color=$(grim -g "$position" -t png - \
- | convert - -format '%[pixel:p{0,0}]' txt:- \
- | tail -n 1 \
- | cut -d ' ' -f 4
- )
+ color=$(
+ grim -g "$position" -t png - |
+ convert - -format '%[pixel:p{0,0}]' txt:- |
+ tail -n 1 |
+ cut -d ' ' -f 4
+ )
fi
if [ $CLIPBOARD -eq 1 ]; then
- echo $color | wl-copy -n
- if [ $NO_NOTIFY -ne 1 ]; then
- notify-send "Color copied to clipboard." $color
- fi
+ echo $color | wl-copy -n
+ if [ $NO_NOTIFY -ne 1 ]; then
+ notify-send "Color copied to clipboard." $color
+ fi
else
- # Display a color picker and store the returned rgb color
- rgb_color=$(zenity --color-selection \
- --title="Copy color to Clipboard" \
- --color="${color}"
- )
+ # Display a color picker and store the returned rgb color
+ rgb_color=$(
+ zenity --color-selection \
+ --title="Copy color to Clipboard" \
+ --color="${color}"
+ )
- # Execute if user didn't click cancel
- if [ "$rgb_color" != "" ]; then
- # Convert rgb color to hex
- hex_color="#"
- for value in $(echo "${rgb_color}" | grep -E -o -m1 '[0-9]+'); do
- hex_color="$hex_color$(printf "%.2x" $value)"
- done
+ # Execute if user didn't click cancel
+ if [ "$rgb_color" != "" ]; then
+ # Convert rgb color to hex
+ hex_color="#"
+ for value in $(echo "${rgb_color}" | grep -E -o -m1 '[0-9]+'); do
+ hex_color="$hex_color$(printf "%.2x" $value)"
+ done
- # Copy user selection to clipboard
- echo $hex_color | wl-copy -n
- fi
+ # Copy user selection to clipboard
+ echo $hex_color | wl-copy -n
+ fi
fi