nixos/home/scripts/randomwp.sh

39 lines
903 B
Bash
Raw Normal View History

2024-03-04 08:10:58 +00:00
#!/usr/bin/env bash
set -eo pipefail
if [ -z "${WALLPAPER_DIR}" ]; then
WALLPAPER_DIR="${HOME}/wallpapers"
fi
if ! [ -d "$WALLPAPER_DIR" ]; then
echo "Wallpaper dir is not a directory"
exit 1
fi
2024-04-21 09:46:33 +00:00
wallpaper_path=$(find "$WALLPAPER_DIR" -mindepth 1 | grep png| sort -R | tail -n 1)
2024-03-04 08:10:58 +00:00
if [ -z "$wallpaper_path" ]; then
echo "Unable to find wallpaper"
exit 1
fi
if ! command -v hyprpaper &> /dev/null; then
echo "Could not find hyprpaper command"
exit 1
fi
echo "setting $wallpaper_path as wallpaper"
hyprctl hyprpaper unload all
hyprctl hyprpaper preload "$wallpaper_path"
2024-04-21 09:46:33 +00:00
if command -v wal &> /dev/null; then
wal -i "$wallpaper_path"
fi
unlink "$WALLPAPER_DIR/current" || true
ln -s "$wallpaper_path" "$WALLPAPER_DIR/current"
2024-03-04 08:10:58 +00:00
for monitor in $(hyprctl monitors | grep 'Monitor' | awk '{ print $2 }'); do
hyprctl hyprpaper wallpaper "$monitor,$wallpaper_path"
done