summaryrefslogtreecommitdiff
path: root/.local/bin/setbg
blob: bfde81ed8aafd827ec7c3522f432627a55d5b6cb (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=$(xrandr | grep " connected" | sed 's/^\([a-Z,0-9,-]*\).*/\1/')

# 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