summaryrefslogtreecommitdiffhomepage
path: root/setWallpaper.sh
blob: 3ec4026ee90ad1f94b240fd7b3a9ff90ca00ed64 (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
#!/bin/bash

# changable config variables:
IMAGE_LOCATION="../tiles"
TEMP_LOCATION="../temp"
OS_LOGO="os.png"
#---
asdf=""
xrandr --listactivemonitors | grep -oE '[^ ]+$' | sed '1d' | while read -r line ; do
	RES=$(xrandr --query --verbose | grep $line | cut -d ' ' -f 3)
	if [ $RES == "primary" ]; then
		RES=$(xrandr --query --verbose | grep $line | cut -d ' ' -f 4 | cut -d '+' -f 1)
		echo $RES
	else
		RES=$(cut -d '+' -f 1 <<<$RES)
		echo $RES
	fi
	PIC=`ls -rt -d -1 $IMAGE_LOCATION/* | shuf -n 1`
	PICNAME=$(basename -- "$PIC")
	convert -size $RES tile:$PIC -gravity SouthEast -draw "image over 25,25 0,0 $OS_LOGO" $TEMP_LOCATION/temp$RES$PICNAME
	asdf="$asdf --output $line --center $TEMP_LOCATION/temp$RES$PICNAME"
	xwallpaper $asdf # this is done each loop, because the asdf var is lost upon exiting the loop
			 # the workarounds are kinda stinky and I dont want to do them
			 # http://mywiki.wooledge.org/BashFAQ/024
	echo "xwallpaper $asdf"
done
rm $TEMP_LOCATION/*