summaryrefslogtreecommitdiff
path: root/.local/bin/setbg
blob: 942c4e6bc818a2d84af29fb8e402acd8b7d21010 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh

# Make sure given file is an image
[ -z "$1" ] && exit
[ ! -f "$1" ] && exit
[ -z "$(file "$1" | grep -o 'image data')" ] && exit

displays=$(wlr-randr --json | jq -r '.[] | select(.active) | .name')

# 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