| 1 | #!/bin/sh |
| 2 | # Set the wallpaper through aurora. aurora owns the wallpaper: it draws it itself (mono dots, colour dots or photo, |
| 3 | # see its settings), records it in hyprpaper.conf and runs matugen (colours). This is just the CLI front-end for its IPC. |
| 4 | # |
| 5 | # setwall random wallpaper from the folder selected in aurora's picker |
| 6 | # setwall -m open (toggle) aurora's wallpaper picker |
| 7 | # setwall [-p] FILE set FILE as the wallpaper |
| 8 | |
| 9 | usage() { |
| 10 | echo "Usage: setwall [-m] [[-p] /path/to/image]" >&2 |
| 11 | exit 1 |
| 12 | } |
| 13 | |
| 14 | # `qs ipc call` exits 0 even when it fails, but void calls print nothing on success |
| 15 | ipc() { |
| 16 | out=$(qs -c aurora ipc call shell "$@" 2>&1) && [ -z "$out" ] && return |
| 17 | echo "setwall: aurora: ${out:-not running}" >&2 |
| 18 | echo " (is it running? systemctl --user start aurora)" >&2 |
| 19 | exit 1 |
| 20 | } |
| 21 | |
| 22 | case "$1" in |
| 23 | "") ipc wallrandom ;; |
| 24 | -m) ipc wall ;; |
| 25 | -p) [ -n "$2" ] || usage; file="$2" ;; |
| 26 | -h|-*) usage ;; |
| 27 | *) file="$1" ;; |
| 28 | esac |
| 29 | |
| 30 | if [ -n "$file" ]; then |
| 31 | if [ ! -f "$file" ]; then |
| 32 | echo "setwall: file not found -> $file" >&2 |
| 33 | exit 1 |
| 34 | fi |
| 35 | ipc wallset "$(realpath "$file")" |
| 36 | fi |