summaryrefslogtreecommitdiff
path: root/.local/bin/makewall
blob: 991fa1109907de2669ee1cb7ab2e431ad615aa8a (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
27
28
29
30
31
32
33
34
35
#!/bin/sh

wallDir="$XDG_CONFIG_HOME/wallpapers"

# Reset any existing wallpapers
killall swaybg

# Acquire the list of connected displays
displays="$(wlr-randr --json | jq -r '.[] | select(.enabled) | .name')"
echo "$displays"

# If there is a wallpaper with a filename matching the display
# name, set it as the wallpaper for that display.
# ex: DP-1.jpg and DP-1.png are both valid filenames
# Otherwise, set the wallpaper to the default wallpaper
# (default.png or default.jpg)
setDisplay() {
	case $(ls $wallDir) in
	*"$1"*)
		wall=$(ls $wallDir | grep "$1" | head -n 1)
		# xwallpaper --output $1 --zoom $wallDir/$wall
		;;
	*)
		wall=$(ls $wallDir | grep "default" | head -n 1)
		# xwallpaper --output $1 --zoom $wallDir/$wall
		;;
	esac
  swaybg --output $1 -m fill --image $wallDir/$wall &
}

# Set the wallpaper for each display
killall swaybg > /dev/null 2>&1
for display in $displays; do
	setDisplay $display
done