Files
dotfiles/.local/bin/station-bg-random

23 lines
686 B
Plaintext
Raw Normal View History

2026-03-08 19:37:53 +00:00
#!/bin/bash
# Picks and sets a random background
2026-03-30 19:40:32 +01:00
width=$(hyprctl monitors -j | jq 'map(.width) | add')
height=$(hyprctl monitors -j | jq '.[0].height')
BACKGROUNDS_PATH="$HOME/Tower/Library/Pictures/Wallpapers/${width}x${height}/"
2026-03-08 19:37:53 +00:00
mapfile -d '' -t BACKGROUNDS < <(find -L "$BACKGROUNDS_PATH" -maxdepth 1 -type f -print0 2>/dev/null | sort -z)
TOTAL=${#BACKGROUNDS[@]}
if (( TOTAL == 0 )); then
notify-send "No background was found" -t 2000
pkill -x swaybg
setsid uwsm-app -- swaybg --color '#000000' >/dev/null 2>&1 &
else
NEW_BACKGROUND=$(find "$BACKGROUNDS_PATH" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)
station-bg-set "$NEW_BACKGROUND"
fi