Krolyxon
Commit 129bacc

Branches

Refs →

aurora.localbinsetwall

36 lines · 1.1 KB · Bourne Again Shell (bash)

1#!/bin/sh
2# Set the wallpaper through aurora. aurora owns the wallpaper: it writes hyprpaper.conf,
3# switches hyprpaper live and runs pywal. 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
9usage() {
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
15ipc() {
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
22case "$1" in
23 "") ipc wallrandom ;;
24 -m) ipc wall ;;
25 -p) [ -n "$2" ] || usage; file="$2" ;;
26 -h|-*) usage ;;
27 *) file="$1" ;;
28esac
29
30if [ -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")"
36fi