diff --git a/.fehbg b/.fehbg new file mode 100755 index 0000000..b6d3727 --- /dev/null +++ b/.fehbg @@ -0,0 +1,13 @@ +#!/bin/bash +# Sets a random wallpaper on each monitor; with --keep, redraws the last ones picked instead. + +cache=${XDG_CACHE_HOME:-$HOME/.cache}/wallpapers + +if [[ $1 != --keep || ! -s $cache ]]; then + # One image per connected output, so --keep still has enough after an output was off + count=$(xrandr --query | grep -c ' connected') + shuf -n "$count" -e ~/.local/share/backgrounds/random/* > "$cache" +fi + +mapfile -t walls < "$cache" +exec /usr/bin/feh --no-fehbg --bg-fill "${walls[@]}" diff --git a/.local/bin/movie b/.local/bin/movie index 8be5852..b79d3cf 100755 --- a/.local/bin/movie +++ b/.local/bin/movie @@ -7,7 +7,7 @@ if ! xrandr --query | grep -q '^HDMI-1-0 connected'; then exec mpv "$@" fi -trap ~/.local/bin/screen-layout EXIT +trap '"$HOME"/.local/bin/screen-layout --keep-wallpaper' EXIT trap 'exit 130' INT TERM HUP xrandr --output eDP-1 --off diff --git a/.local/bin/screen-layout b/.local/bin/screen-layout index 3602ff5..bd4f277 100755 --- a/.local/bin/screen-layout +++ b/.local/bin/screen-layout @@ -1,6 +1,7 @@ #!/bin/bash # Sets up the outputs, wallpaper and trayer for whatever monitors are connected. # Called by xmonad at startup and on monitor (dis)connect, and by `movie` on exit. +# --keep-wallpaper redraws the current wallpaper instead of picking new random ones. if xrandr --query | grep -q '^HDMI-1-0 connected'; then xrandr --output HDMI-1-0 --preferred --primary --output eDP-1 --right-of HDMI-1-0 --preferred @@ -10,7 +11,11 @@ else tray=0 fi -~/.fehbg +if [[ $1 == --keep-wallpaper ]]; then + ~/.fehbg --keep +else + ~/.fehbg +fi # Replace any running trayer, so there's never more than one pkill -x trayer