diff options
| author | Robert Günzler <r@gnzler.io> | 2024-06-18 09:11:26 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2024-06-18 09:11:26 +0200 |
| commit | 8f29be993dad465c1bb108462dc1bd63706649a5 (patch) | |
| tree | 340fcc5af3fbb02a55cc9958334e26cd0c4a0480 /bin/oguri-cycle | |
| parent | 3dbe74f2eef627e2dc19b79fe06753d5dc09003f (diff) | |
oguri-cycle with swww and wlr-randr
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to 'bin/oguri-cycle')
| -rwxr-xr-x | bin/oguri-cycle | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/bin/oguri-cycle b/bin/oguri-cycle index c09c712..900fbf8 100755 --- a/bin/oguri-cycle +++ b/bin/oguri-cycle @@ -3,51 +3,48 @@ set -e [ -n "$DEBUG" ] && set -x # check requirements -for app in oguri ogurictl; do +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 oguri >/dev/null 2>&1; then - printf "%s: oguri not running, aborting\n" "$(basename "$0")" >&2 +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() { - for o in "${OUTPUTS[@]}"; do - if [ ${#BGS} -gt 0 ]; then - idx=$((0 + RANDOM % ${#BGS[@]})) - ogurictl output "${o}" \ - --image "${BGS[${idx}]}" \ - --filter best \ - --scaling-mode fill \ - --anchor center - else - ogurictl output "${o}" \ - --image "$(grep image "${XDG_CONFIG_HOME}"/oguri/config | cut -d= -f2)" \ - --filter best \ - --scaling-mode tile \ - --anchor center - fi - done + 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/oguri-cycle +BGS_DIR=$HOME/pictures/wallp -# OUTPUTS=("$(swq list output | jq -r '..|select(.transform?=="normal")|.name')") -readarray OUTPUTS < <(wlr-randr | awk 'BEGIN{name=""} /^\S/{name=$1} /Transform: normal/{printf name}') +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) -change_bg +for o in "${OUTPUTS[@]}"; do change_bg "$o"; done -# OUTPUTS=("$(swq list output | jq -r '..|select((.transform?=="270")or(.transform?=="90"))|.name')") -readarray OUTPUTS < <(wlr-randr | awk 'BEGIN{name=""} /^\S/{name=$1} /Transform: 90/{printf name}') +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) -change_bg --anchor=left +for o in "${OUTPUTS[@]}"; do change_bg "$o"; done |