#!/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