summary refs log tree commit diff
path: root/bin/oguri-cycle
blob: 66e9b5cb04b307e837a8648e229c01f115aa2100 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
set -e
[ -n "$DEBUG" ] && set -x

# check requirements
for app in oguri ogurictl; do
	if ! command -v "$app" >/dev/null; then
		printf "%s: %s not installed but required\n" "$(basename "$0")" "$app" >&2
		exit 1
	fi
done

if ! pgrep oguri >/dev/null 2>&1; then
	printf "%s: oguri not running, aborting\n" "$(basename "$0")" >&2
	exit 1
fi

change_bg() {
	for o in "${OUTPUTS[@]}"; do
		idx=$((0 + RANDOM % ${#BGS[@]}))
		ogurictl output "${o}" --image "${BGS[${idx}]}" --filter best $@
	done
}

logger 'oguri-cycle: changing background(s)' || true

BGS_DIR=$HOME/Pictures/wallp/oguri-cycle

OUTPUTS=( $(swq list output | jq -r '..|select(.transform?=="normal")|.name') )
readarray -d '' BGS < <(find ${BGS_DIR}/horizontal/ -print0 2>/dev/null)
readarray -d '' BGS < <(find ${BGS_DIR}/landscape/ -print0 2>/dev/null)

change_bg

OUTPUTS=( $(swq list output | jq -r '..|select((.transform?=="270")or(.transform?=="90"))|.name') )
readarray -d '' BGS < <(find ${BGS_DIR}/vertical/ -print0 2>/dev/null)
readarray -d '' BGS < <(find ${BGS_DIR}/portrait/ -print0 2>/dev/null)

change_bg --anchor=left