aboutsummaryrefslogtreecommitdiffstats
path: root/xorg-xrandr/resolution-changed
blob: 4e8856f4908c3f137fe9b123c22e7ed185a908ed (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
51
52
53
54
55
56
57
58
#!/bin/dash

reset_wallpaper_twice=0
hostname="$(hostname | tr 'A-Z' 'a-z')"

if ! test "${hostname}" = zenith; then ## TODO how about the other east,north,hades,hyperion?
	# 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
		if test -x /usr/lib/mate-settings-daemon/mate-settings-daemon; then
			msd=/usr/lib/mate-settings-daemon/mate-settings-daemon
		elif test -x /usr/bin/mate-settings-daemon; then
			msd=/usr/bin/mate-settings-daemon
		elif test -x /usr/libexec/mate-settings-daemon; then
			msd=/usr/libexec/mate-settings-daemon
		elif test -x /usr/libexec/mate-settings-daemon/mate-settings-daemon; then
			msd=/usr/libexec/mate-settings-daemon/mate-settings-daemon
		else
			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