aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-04-21 01:24:36 +0100
committerLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-04-21 01:24:36 +0100
commit2b0930fbdea2565e01f451843dddeceef8e9cd42 (patch)
tree29e03c038580d92943ce3977461d4b92d45fe852
parent4260b23f59752ca9e88161f649285da3cce82982 (diff)
downloaddotfiles-2b0930fbdea2565e01f451843dddeceef8e9cd42.tar.gz
dotfiles-2b0930fbdea2565e01f451843dddeceef8e9cd42.tar.bz2
dotfiles-2b0930fbdea2565e01f451843dddeceef8e9cd42.zip
style(shell): apply shfmt (-i 2 -ci -s)
-rwxr-xr-xbootstrap.sh53
-rwxr-xr-xdot_config/sway/executable_display-toggle.sh42
-rwxr-xr-xdot_local/bin/executable_create-efi19
-rwxr-xr-xdot_local/bin/executable_doasedit58
-rwxr-xr-xdot_local/bin/executable_linkhandler76
-rwxr-xr-xdot_local/bin/executable_record104
-rwxr-xr-xdot_local/bin/executable_togreta6
-rwxr-xr-xdot_local/bin/executable_tokodi18
-rwxr-xr-xdot_local/bin/executable_wqr6
9 files changed, 192 insertions, 190 deletions
diff --git a/bootstrap.sh b/bootstrap.sh
index dbe9495..cbd10a3 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -18,14 +18,17 @@ set -eu
log() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
warn() { printf '\033[1;33m==>\033[0m %s\n' "$*" >&2; }
-die() { printf '\033[1;31m==>\033[0m %s\n' "$*" >&2; exit 1; }
+die() {
+ printf '\033[1;31m==>\033[0m %s\n' "$*" >&2
+ exit 1
+}
# 0. refuse root — paru/makepkg won't run as root
[ "$(id -u)" -ne 0 ] || die "run this as your regular user, not root"
# 1. user must be in wheel (required so the sudoers rule we enable takes effect)
-id -nG "$USER" | tr ' ' '\n' | grep -qx wheel \
- || die "user '$USER' must be in the 'wheel' group"
+id -nG "$USER" | tr ' ' '\n' | grep -qx wheel ||
+ die "user '$USER' must be in the 'wheel' group"
# 2. install sudo + pacman prerequisites, enable wheel in sudoers.
# If sudo is absent we do this in a single su -c so the root password
@@ -34,33 +37,33 @@ PREREQS='sudo git base-devel chezmoi just efibootmgr'
SUDOERS_SED='s/^# *\(%wheel ALL=(ALL:ALL\(:ALL\)*) ALL\)/\1/'
if ! command -v sudo >/dev/null 2>&1; then
- log 'installing prerequisites (prompting for root password)'
- su -c "pacman -Syu --needed --noconfirm ${PREREQS} && \
+ log 'installing prerequisites (prompting for root password)'
+ su -c "pacman -Syu --needed --noconfirm ${PREREQS} && \
sed -i '${SUDOERS_SED}' /etc/sudoers"
else
- log 'installing prerequisites'
- # shellcheck disable=SC2086 # PREREQS is an intentional word list
- sudo pacman -Syu --needed --noconfirm ${PREREQS}
- sudo sed -i "${SUDOERS_SED}" /etc/sudoers
+ log 'installing prerequisites'
+ # shellcheck disable=SC2086 # PREREQS is an intentional word list
+ sudo pacman -Syu --needed --noconfirm ${PREREQS}
+ sudo sed -i "${SUDOERS_SED}" /etc/sudoers
fi
# 3. bootstrap paru-bin from AUR if missing
if ! command -v paru >/dev/null 2>&1; then
- log 'building paru-bin from AUR'
- tmp=$(mktemp -d)
- trap 'rm -rf "$tmp"' EXIT
- git clone --depth=1 https://aur.archlinux.org/paru-bin.git "$tmp/paru-bin"
- (cd "$tmp/paru-bin" && makepkg -si --noconfirm)
+ log 'building paru-bin from AUR'
+ tmp=$(mktemp -d)
+ trap 'rm -rf "$tmp"' EXIT
+ git clone --depth=1 https://aur.archlinux.org/paru-bin.git "$tmp/paru-bin"
+ (cd "$tmp/paru-bin" && makepkg -si --noconfirm)
fi
# 4. clone dotfiles
DOTFILES_DIR="${DOTFILES_DIR:-$HOME/dotfiles}"
REPO_URL="${DOTFILES_REPO:-https://github.com/sommerfelddev/dotfiles.git}"
if [ ! -d "$DOTFILES_DIR/.git" ]; then
- log "cloning $REPO_URL -> $DOTFILES_DIR"
- git clone "$REPO_URL" "$DOTFILES_DIR"
+ log "cloning $REPO_URL -> $DOTFILES_DIR"
+ git clone "$REPO_URL" "$DOTFILES_DIR"
else
- log "using existing clone at $DOTFILES_DIR"
+ log "using existing clone at $DOTFILES_DIR"
fi
# 5. run just init — this deploys chezmoi, installs the 'base' meta list
@@ -73,21 +76,21 @@ just init
# 6. refresh pacman mirrorlist once via reflector (config deployed by chezmoi)
log 'refreshing pacman mirrorlist via reflector'
sudo reflector @/etc/xdg/reflector/reflector.conf \
- --save /etc/pacman.d/mirrorlist \
- || warn 'reflector failed; keeping existing mirrorlist'
+ --save /etc/pacman.d/mirrorlist ||
+ warn 'reflector failed; keeping existing mirrorlist'
# 7. create XDG user directories (~/Documents, ~/Downloads, etc.)
if command -v xdg-user-dirs-update >/dev/null 2>&1; then
- log 'creating XDG user directories'
- xdg-user-dirs-update || warn 'xdg-user-dirs-update failed'
+ log 'creating XDG user directories'
+ xdg-user-dirs-update || warn 'xdg-user-dirs-update failed'
fi
# 8. optional: create an Arch EFI boot entry if none exists
if [ -d /sys/firmware/efi ]; then
- if ! sudo efibootmgr 2>/dev/null | grep -iq arch; then
- log 'no Arch Linux EFI boot entry found; launching create-efi'
- "$HOME/.local/bin/create-efi"
- fi
+ if ! sudo efibootmgr 2>/dev/null | grep -iq arch; then
+ log 'no Arch Linux EFI boot entry found; launching create-efi'
+ "$HOME/.local/bin/create-efi"
+ fi
fi
log 'done. Log out and back in (or reboot) to pick up shell and group changes.'
diff --git a/dot_config/sway/executable_display-toggle.sh b/dot_config/sway/executable_display-toggle.sh
index f39bf9b..b0e4d17 100755
--- a/dot_config/sway/executable_display-toggle.sh
+++ b/dot_config/sway/executable_display-toggle.sh
@@ -9,8 +9,8 @@ LAPTOP=$(echo "$OUTPUTS" | jq -r '[.[] | select(.name | test("^eDP")) | .name] |
EXTERNAL=$(echo "$OUTPUTS" | jq -r '[.[] | select(.name | test("^eDP") | not) | .name] | first // empty')
if [ -z "$EXTERNAL" ]; then
- [ -z "$1" ] && notify-send "Display" "No external display connected"
- exit 0
+ [ -z "$1" ] && notify-send "Display" "No external display connected"
+ exit 0
fi
[ -z "$LAPTOP" ] && exit 0
@@ -19,27 +19,27 @@ LAPTOP_WIDTH=$(echo "$OUTPUTS" | jq -r ".[] | select(.name == \"$LAPTOP\") | .cu
[ -z "$LAPTOP_WIDTH" ] && LAPTOP_WIDTH=1920
if [ "$1" = "init" ]; then
- NEXT="laptop-off"
+ NEXT="laptop-off"
else
- CURRENT=$(cat "$STATE_FILE" 2>/dev/null || echo "laptop-off")
- case "$CURRENT" in
- laptop-off) NEXT="side-by-side" ;;
- *) NEXT="laptop-off" ;;
- esac
+ CURRENT=$(cat "$STATE_FILE" 2>/dev/null || echo "laptop-off")
+ case "$CURRENT" in
+ laptop-off) NEXT="side-by-side" ;;
+ *) NEXT="laptop-off" ;;
+ esac
fi
case "$NEXT" in
- laptop-off)
- swaymsg output "$LAPTOP" disable || true
- swaymsg output "$EXTERNAL" enable || true
- swaymsg workspace number 1 || true
- echo "laptop-off" > "$STATE_FILE"
- [ -z "$1" ] && notify-send "Display" "Laptop screen off"
- ;;
- side-by-side)
- swaymsg output "$LAPTOP" enable pos 0 0 || true
- swaymsg output "$EXTERNAL" enable pos "$LAPTOP_WIDTH" 0 || true
- echo "side-by-side" > "$STATE_FILE"
- [ -z "$1" ] && notify-send "Display" "Side by side"
- ;;
+ laptop-off)
+ swaymsg output "$LAPTOP" disable || true
+ swaymsg output "$EXTERNAL" enable || true
+ swaymsg workspace number 1 || true
+ echo "laptop-off" >"$STATE_FILE"
+ [ -z "$1" ] && notify-send "Display" "Laptop screen off"
+ ;;
+ side-by-side)
+ swaymsg output "$LAPTOP" enable pos 0 0 || true
+ swaymsg output "$EXTERNAL" enable pos "$LAPTOP_WIDTH" 0 || true
+ echo "side-by-side" >"$STATE_FILE"
+ [ -z "$1" ] && notify-send "Display" "Side by side"
+ ;;
esac
diff --git a/dot_local/bin/executable_create-efi b/dot_local/bin/executable_create-efi
index 9a72263..70cf1cc 100755
--- a/dot_local/bin/executable_create-efi
+++ b/dot_local/bin/executable_create-efi
@@ -5,49 +5,48 @@ lsblk
printf "Boot disk [sda]: " && read -r boot_disk
if [ -z "$boot_disk" ]; then
- boot_disk='sda'
+ boot_disk='sda'
fi
printf "Boot partition number [1]: " && read -r boot_partition_number
if [ -z "$boot_partition_number" ]; then
- boot_partition_number='1'
+ boot_partition_number='1'
fi
printf "Root partition [sda2]: " && read -r root_partition
if [ -z "$root_partition" ]; then
- root_partition='sda2'
+ root_partition='sda2'
fi
root_uuid="UUID=$(blkid -s UUID -o value /dev/"$root_partition")"
printf "Kernel name [linux]: " && read -r kernel_name
if [ -z "$kernel_name" ]; then
- kernel_name='linux'
+ kernel_name='linux'
fi
printf "CPU vendor (intel/amd) [intel]: " && read -r cpu_vendor
if [ -z "$cpu_vendor" ]; then
- cpu_vendor='intel'
+ cpu_vendor='intel'
fi
printf "ESP (boot/efi) [boot]: " && read -r esp
if [ -z "$esp" ]; then
- esp='boot'
+ esp='boot'
fi
printf "extra kernel parameters (e.g. mitigations=off): " && read -r extra_kernel_params
printf "label [archlinux]: " && read -r label
if [ -z "$label" ]; then
- label='archlinux'
+ label='archlinux'
fi
rel_path=""
rel_path2=""
if [ "$esp" = "efi" ]; then
- rel_path="\\EFI\\arch"
- rel_path2="/EFI/arch"
+ rel_path='\EFI\arch'
+ rel_path2="/EFI/arch"
fi
-
unicode_arg="cryptdevice=$root_uuid:root root=/dev/mapper/root rw initrd=$rel_path\\$cpu_vendor-ucode.img initrd=$rel_path\\initramfs-$kernel_name.img quiet $extra_kernel_params"
set -x
diff --git a/dot_local/bin/executable_doasedit b/dot_local/bin/executable_doasedit
index a3bdb2d..e58b9f2 100755
--- a/dot_local/bin/executable_doasedit
+++ b/dot_local/bin/executable_doasedit
@@ -41,15 +41,15 @@ check_doas_conf() {
printf '(E)dit again, (O)verwrite anyway, (A)bort: [E/o/a]? '
read -r choice
case "$choice" in
- o | O)
- return 0
- ;;
- a | A)
- return 1
- ;;
- e | E | *)
- "$editor_cmd" "$tmpfile"
- ;;
+ o | O)
+ return 0
+ ;;
+ a | A)
+ return 1
+ ;;
+ e | E | *)
+ "$editor_cmd" "$tmpfile"
+ ;;
esac
done
fi
@@ -71,26 +71,26 @@ _exit() {
while [ "${#}" -ne 0 ]; do
case "${1}" in
- --)
- shift
- break
- ;;
- --help | -h)
- help
- exit 0
- ;;
- --version | -V)
- printf 'doasedit version 1.0.7\n'
- exit 0
- ;;
- -*)
- printf "doasedit: invalid option: '%s'\n" "${1}"
- help
- exit 1
- ;;
- *)
- break
- ;;
+ --)
+ shift
+ break
+ ;;
+ --help | -h)
+ help
+ exit 0
+ ;;
+ --version | -V)
+ printf 'doasedit version 1.0.7\n'
+ exit 0
+ ;;
+ -*)
+ printf "doasedit: invalid option: '%s'\n" "${1}"
+ help
+ exit 1
+ ;;
+ *)
+ break
+ ;;
esac
done
diff --git a/dot_local/bin/executable_linkhandler b/dot_local/bin/executable_linkhandler
index e91da50..ee63eed 100755
--- a/dot_local/bin/executable_linkhandler
+++ b/dot_local/bin/executable_linkhandler
@@ -1,49 +1,49 @@
#!/usr/bin/env sh
resolve_url() {
- if [ -f "$1" ]; then
- local_url="$1"
- else
- local_url="/tmp/$(echo "$1" | sed "s/.*\///")"
- curl -sL "$1" >"$local_url"
- fi
- printf "%s" "$local_url"
+ if [ -f "$1" ]; then
+ local_url="$1"
+ else
+ local_url="/tmp/$(echo "$1" | sed "s/.*\///")"
+ curl -sL "$1" >"$local_url"
+ fi
+ printf "%s" "$local_url"
}
if [ -z "$1" ]; then
- url=$(wl-paste)
+ url=$(wl-paste)
else
- url="$1"
+ url="$1"
fi
case "$url" in
-*.mkv* | *.webm* | *.mp4* | *.mp3* | *.ogg* | *.mov* | *.ts* | *.m3u8* | *.gif* | *.m4a* | *youtube.com/watch* | *youtube.com/playlist* | *youtu.be* | *twitch.tv* | *invidio.us* | *lbry* | *streamye.com* | *streamvi.com* | *streamwo.com* | *videos.lukesmith.xyz*)
- setsid mpv -quiet "$url" >/dev/null 2>&1 &
- ;;
-acestream://*)
- setsid acestream-launcher "$url" >/dev/null 2>&1 &
- ;;
-*.png | *.jpg | *.jpe | *.jpeg | *.PNG | *.JPG | *.JPE | *.JPEG)
- local_url="$(resolve_url "$url")"
- setsid imv "$local_url" >/dev/null 2>&1 &
- ;;
-*.pdf | *.ps | *.epub)
- local_url="$(resolve_url "$url")"
- setsid zathura "$local_url" >/dev/null 2>&1 &
- ;;
-*rss* | *feed* | http*.xml | http*.atom)
- setsid rssadd "$url" >/dev/null 2>&1 &
- ;;
-mailto:*)
- setsid aerc "$url" >/dev/null 2>&1 &
- ;;
-*.dot)
- setsid xdot "$url" >/dev/null 2>&1 &
- ;;
-http*)
- librewolf "$url" >/dev/null 2>&1 &
- ;;
-*)
- $TERMINAL -e "$EDITOR" "$1"
- ;;
+ *.mkv* | *.webm* | *.mp4* | *.mp3* | *.ogg* | *.mov* | *.ts* | *.m3u8* | *.gif* | *.m4a* | *youtube.com/watch* | *youtube.com/playlist* | *youtu.be* | *twitch.tv* | *invidio.us* | *lbry* | *streamye.com* | *streamvi.com* | *streamwo.com* | *videos.lukesmith.xyz*)
+ setsid mpv -quiet "$url" >/dev/null 2>&1 &
+ ;;
+ acestream://*)
+ setsid acestream-launcher "$url" >/dev/null 2>&1 &
+ ;;
+ *.png | *.jpg | *.jpe | *.jpeg | *.PNG | *.JPG | *.JPE | *.JPEG)
+ local_url="$(resolve_url "$url")"
+ setsid imv "$local_url" >/dev/null 2>&1 &
+ ;;
+ *.pdf | *.ps | *.epub)
+ local_url="$(resolve_url "$url")"
+ setsid zathura "$local_url" >/dev/null 2>&1 &
+ ;;
+ *rss* | *feed* | http*.xml | http*.atom)
+ setsid rssadd "$url" >/dev/null 2>&1 &
+ ;;
+ mailto:*)
+ setsid aerc "$url" >/dev/null 2>&1 &
+ ;;
+ *.dot)
+ setsid xdot "$url" >/dev/null 2>&1 &
+ ;;
+ http*)
+ librewolf "$url" >/dev/null 2>&1 &
+ ;;
+ *)
+ $TERMINAL -e "$EDITOR" "$1"
+ ;;
esac
diff --git a/dot_local/bin/executable_record b/dot_local/bin/executable_record
index 00ac367..ff57758 100755
--- a/dot_local/bin/executable_record
+++ b/dot_local/bin/executable_record
@@ -4,74 +4,74 @@ pid_file="/tmp/recordpid"
log_file="/tmp/record.log"
pid_exists() {
- test -r "$pid_file"
+ test -r "$pid_file"
}
is_running() {
- if pid_exists; then
- ps "$(cat "$pid_file")" >/dev/null 2>&1 || return 1
- else
- return 1
- fi
+ if pid_exists; then
+ ps "$(cat "$pid_file")" >/dev/null 2>&1 || return 1
+ else
+ return 1
+ fi
}
start() {
- notify-send -t 500 "Record started!" &
- sleep 0.5
+ notify-send -t 500 "Record started!" &
+ sleep 0.5
- wf-recorder -f "$HOME/vids/$(date '+%y%m%d-%H%M-%S').mkv" >"$log_file" 2>&1 &
- echo "$!" >"$pid_file"
+ wf-recorder -f "$HOME/vids/$(date '+%y%m%d-%H%M-%S').mkv" >"$log_file" 2>&1 &
+ echo "$!" >"$pid_file"
}
stop() {
- pid_exists || exit 1
- pid="$(cat "$pid_file")"
- # kill with SIGTERM, allowing finishing touches.
- kill "$pid"
- # even after SIGTERM, ffmpeg may still run, so SIGKILL it.
- sleep 3
- is_running && kill -9 "$pid"
- rm -f "$pid_file"
- notify-send "Record stopped!"
+ pid_exists || exit 1
+ pid="$(cat "$pid_file")"
+ # kill with SIGTERM, allowing finishing touches.
+ kill "$pid"
+ # even after SIGTERM, ffmpeg may still run, so SIGKILL it.
+ sleep 3
+ is_running && kill -9 "$pid"
+ rm -f "$pid_file"
+ notify-send "Record stopped!"
}
toggle() {
- if is_running; then
- echo "Stopping record"
- stop
- else
- echo "Starting record"
- start
- fi
- echo
- status
+ if is_running; then
+ echo "Stopping record"
+ stop
+ else
+ echo "Starting record"
+ start
+ fi
+ echo
+ status
}
status() {
- if is_running; then
- echo "Recording with PID $(cat "$pid_file")"
- echo "Check the logs at"
- echo
- echo "$log_file"
- echo
- else
- echo "Record inactive"
- fi
+ if is_running; then
+ echo "Recording with PID $(cat "$pid_file")"
+ echo "Check the logs at"
+ echo
+ echo "$log_file"
+ echo
+ else
+ echo "Record inactive"
+ fi
}
case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- toggle)
- toggle
- ;;
- status)
- status
- ;;
- *)
- toggle
- ;;
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ toggle)
+ toggle
+ ;;
+ status)
+ status
+ ;;
+ *)
+ toggle
+ ;;
esac
diff --git a/dot_local/bin/executable_togreta b/dot_local/bin/executable_togreta
index d452a2e..9a189f9 100755
--- a/dot_local/bin/executable_togreta
+++ b/dot_local/bin/executable_togreta
@@ -1,11 +1,11 @@
#!/usr/bin/env sh
if [ -z "$1" ]; then
- url=$(wl-paste)
+ url=$(wl-paste)
elif [ "$1" = "-" ]; then
- read -r url
+ read -r url
else
- url="$1"
+ url="$1"
fi
# shellcheck disable=SC2029
diff --git a/dot_local/bin/executable_tokodi b/dot_local/bin/executable_tokodi
index ce945de..aec226c 100755
--- a/dot_local/bin/executable_tokodi
+++ b/dot_local/bin/executable_tokodi
@@ -1,20 +1,20 @@
#!/usr/bin/env sh
if [ -z "$1" ]; then
- url=$(wl-paste)
+ url=$(wl-paste)
elif [ "$1" = "-" ]; then
- read -r url
+ read -r url
else
- url="$1"
+ url="$1"
fi
case "$url" in
-*.m3u8*)
- prefix=''
- ;;
-*)
- prefix='plugin://plugin.video.sendtokodi/?'
- ;;
+ *.m3u8*)
+ prefix=''
+ ;;
+ *)
+ prefix='plugin://plugin.video.sendtokodi/?'
+ ;;
esac
payload="$(printf '{"jsonrpc":"2.0", "id": 1, "method":"Player.Open","params": {"item": {"file":"%s%s"}}}' "$prefix" "$url")"
diff --git a/dot_local/bin/executable_wqr b/dot_local/bin/executable_wqr
index 254f992..f878fdf 100755
--- a/dot_local/bin/executable_wqr
+++ b/dot_local/bin/executable_wqr
@@ -1,11 +1,11 @@
#!/usr/bin/env sh
if [ -z "$1" ]; then
- text=$(wl-paste)
+ text=$(wl-paste)
elif [ "$1" = "-" ]; then
- read -r text
+ read -r text
else
- text="$1"
+ text="$1"
fi
printf '%s' "$text" | qrencode -t PNG -o - | imv -