diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2024-01-20 03:41:29 -0500 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2024-01-20 03:41:29 -0500 |
commit | d49c79933e7b85a24238f6f373261de1d71d7072 (patch) | |
tree | 677bebe3b68c1c31125be064ba1a746f44c7a52f /.local/bin/setbg | |
parent | 06185bde8c8beadecab629eaff51835244ff748a (diff) |
Wallpapers from lf + fix shortcutgen
Diffstat (limited to '.local/bin/setbg')
-rwxr-xr-x | .local/bin/setbg | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/.local/bin/setbg b/.local/bin/setbg new file mode 100755 index 0000000..6608d7a --- /dev/null +++ b/.local/bin/setbg @@ -0,0 +1,28 @@ +#!/bin/sh + +# Make sure given file is an image +[ -z "$1" ] && exit +[ ! -f "$1" ] && exit +[ -z "$(file "$1" | grep -o 'image data')" ] && exit + +displays=$(xrandr | grep " connected" | sed 's/^\([a-Z,0-9,-]*\).*/\1/') + +# selected="$(echo "$displays" | dmenu -w "$(xdotool getactivewindow)" -p " Select monitor:")" + +# Same as above but use dmenu only if there are multiple displays +if [ "$(echo "$displays" | wc -l)" -gt 1 ]; then + selected="$(echo "$displays" | dmenu -w "$(xdotool getactivewindow)" -p " Select monitor:")" +else + selected="$displays" +fi + +[ -z "$selected" ] && exit + +src="$1" +extension="${1##*.}" +dest="$XDG_CONFIG_HOME/wallpapers/${selected}.$extension" + +ln -sf "$src" "$dest" && notify-send -a "Wallpaper" -i "$src" "Changed monitor: $selected" + +# Re-render all wallpapers +makewall |