nixos/home/scripts/randomwp.sh
Torjus Håkestad e1049f0a16
Some checks failed
pre-commit / pre-commit (push) Failing after 23s
pre-commit / pre-commit (pull_request) Failing after 14m39s
Rice laptop
2024-04-21 11:46:33 +02:00

39 lines
903 B
Bash

#!/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
wallpaper_path=$(find "$WALLPAPER_DIR" -mindepth 1 | grep png| sort -R | tail -n 1)
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"
if command -v wal &> /dev/null; then
wal -i "$wallpaper_path"
fi
unlink "$WALLPAPER_DIR/current" || true
ln -s "$wallpaper_path" "$WALLPAPER_DIR/current"
for monitor in $(hyprctl monitors | grep 'Monitor' | awk '{ print $2 }'); do
hyprctl hyprpaper wallpaper "$monitor,$wallpaper_path"
done