aboutsummaryrefslogtreecommitdiffstats
path: root/xorg-xrandr/resolution-changed
blob: e1457ce94788affd3ece4866837847e4bae029e9 (plain) (blame)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/dash

reset_wallpaper_twice=0

if ! test "$(hostname | tr '[A-Z]' '[a-z]')" = zenith; then
	# Reset rat size in case DPI change modified scaling
	xsetroot -cursor_name left_ptr || :

	# Reset rat speed in case DPI changed
	if test "${DESKTOP_SESSION}" = xmonad && test ! "${NO_MATE}" = y; then
		msd=/usr/lib/mate-settings-daemon/mate-settings-daemon
		if ! test -x "$msd"; then
			msd=mate-settings-daemon
		fi
		(exec $msd --replace &) || :
		# mate-settings-daemon will change the keyboard layout
		(sleep 1; setkeys) &
		# mate-settings-daemon may change the wallpaper
		reset_wallpaper_twice=1
	fi
fi

# Reset background in case resolution change damaged it
for file in ~/.config/background.${SESSION_} \
            ~/.config/background.${SESSION} \
            ~/.config/background.${DESKTOP_SESSION} \
            ~/.config/background; do
	if test -r "$file"; then
		xwallpaper --zoom "$file"
		if test ${reset_wallpaper_twice} = 1; then
			# Again, with delay, in case mate-settings-daemon changes it
			(sleep 2 ; xwallpaper --zoom "$file") &
		fi
	fi
done

# Broadcast resolution change
if test -n "${XDG_RUNTIME_DIR}"; then
	if test -n "${DISPLAY}"; then
		mkdir -p -- "${XDG_RUNTIME_DIR}/x-display/${DISPLAY}/"
		printf -- '%ix%i%+i%+i\n' "$@" > "${XDG_RUNTIME_DIR}/x-display/${DISPLAY}/resolution~"
		mv -- "${XDG_RUNTIME_DIR}/x-display/${DISPLAY}/resolution~" "${XDG_RUNTIME_DIR}/x-display/${DISPLAY}/resolution"
	fi
	if test -z "${BUS_VIDEO}"; then
		BUS_VIDEO="${XDG_RUNTIME_DIR}/@bus/video"
	fi
fi
if test -n "${BUS_VIDEO}"; then
	bus broadcast "${BUS_VIDEO}" "resolution changed:$(printf -- ' %ix%i%+i%+i' "$@")"
fi