dotfiles/scripts/sxiv-bkg
tavo-wasd fd69ecbbe6 init
2023-05-08 20:39:39 -06:00

25 lines
750 B
Bash
Executable file

#!/bin/sh
# Depends on sxiv, dmenu and hsetroot
# Will display background chooser
# and set it using hsetroot
img=$(find ~/Pictures/Backgrounds/* | shuf | sxiv -itoq | tail -1)
# Exit if none chosen
[ -z "$img" ] && exit
# Find previous startup background command
prev=$(grep hsetroot ~/.xinitrc)
# Define wether or not hsetroot should
# set per monitor or treat multiple monitors as one
option=$(printf "Set per monitor\nTreat multiple monitors as one" | dmenu -i -p "Layout:")
case "$option" in
"Set per monitor") new="hsetroot -cover $img" ;;
"Treat multiple monitors as one") new="hsetroot -root -cover $img" ;;
*) exit 1 ;;
esac
# Set background and change
# startup configuration with new one
$new && sed -i "s|$prev|$new|g" ~/.xinitrc