22 lines
638 B
Plaintext
22 lines
638 B
Plaintext
|
|
#!/bin/bash
|
||
|
|
|
||
|
|
# Picks and sets a random background
|
||
|
|
|
||
|
|
BACKGROUNDS_PATH="$HOME/Tower/Library/Pictures/Wallpapers/3840x2160/"
|
||
|
|
CURRENT_BACKGROUND_LINK="$HOME/.local/state/station/background"
|
||
|
|
|
||
|
|
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
|
||
|
|
|