blob: 900fbf84b458aa5f767cde30d0fed66abb7a9101 (
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
40
41
42
43
44
45
46
47
48
49
50
|
#!/bin/bash
set -e
[ -n "$DEBUG" ] && set -x
# check requirements
for app in swww wlr-randr; 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 swww-daemon >/dev/null 2>&1; then
printf "%s: swww-daemon not running, aborting\n" "$(basename "$0")" >&2
exit 1
fi
change_bg() {
local OUTPUT=$1
export SWWW_TRANSITION=none SWWW_TRANSITION_FPS=60
if [ ${#BGS} -gt 0 ]; then
idx=$((0 + RANDOM % ${#BGS[@]}))
swww img \
--outputs "${OUTPUT}" \
"${BGS[${idx}]}"
else
swww img \
--outputs "${OUTPUT}" \
"$(grep image "${XDG_CONFIG_HOME}"/oguri/config | cut -d= -f2)"
fi
}
logger 'oguri-cycle: changing background(s)' || true
BGS_DIR=$HOME/pictures/wallp
readarray -t OUTPUTS < <(wlr-randr --json | jq -r '..|select(.transform?=="normal")|.name')
# readarray -t OUTPUTS < <(wlr-randr | awk 'BEGIN{name=""} /^\S/{name=$1} /Transform: normal/{print name}')
readarray -d '' BGS < <(find "${BGS_DIR}"/horizontal/ -print0 2>/dev/null)
readarray -d '' BGS < <(find "${BGS_DIR}"/landscape/ -print0 2>/dev/null)
for o in "${OUTPUTS[@]}"; do change_bg "$o"; done
readarray -t OUTPUTS < <(wlr-randr --json | jq -r '..|select((.transform?=="270")or(.transform?=="90"))|.name')
# readarray -t OUTPUTS < <(wlr-randr | awk 'BEGIN{name=""} /^\S/{name=$1} /Transform: 90/{print name}')
readarray -d '' BGS < <(find "${BGS_DIR}"/vertical/ -print0 2>/dev/null)
readarray -d '' BGS < <(find "${BGS_DIR}"/portrait/ -print0 2>/dev/null)
for o in "${OUTPUTS[@]}"; do change_bg "$o"; done
|