~charles/dotfiles

ref: 96e433ac2baea26da79d1e4bc1dce52644c19aab dotfiles/overlay/bin/configure-dpms -rwxr-xr-x 1.4 KiB
96e433acCharles Daniels fix compatibility with xubuntu 2 years ago
                                                                                
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
59
60
61
62
63
#!/bin/sh

# .SCRIPTDOC

# Set appropriet DPMS settings for the current dock state given by
# ~/.dspool/dock_status, or by a user-provided override.

# .SYNTAX

# $1 . . . (optional) specify DPMS configuration, one of [docked, undocked,
#          nosleep]

# .LICENSE

# Copyright 2018, Charles A. Daniels
# This software is distributed under the BSD 3-clause license. The full text
# of this software's license may be retrieved from this URL:
# https://github.com/charlesdaniels/dotfiles/blob/master/LICENSE

# .ENDOC

DOCK_STATUS="$(cat ~/.dspool/dock_status)"
if [ "$DOCK_STATUS" = "DOCKED" ] ; then
	CONFIGURATION="docked"
else
	CONFIGURATION="undocked"
fi

# this can interfere with our settings
killall mate-screensaver > /dev/null 2>&1 || true

# if the user provided a directive, use that instead of the inferred one
if [ $# -ge 1 ] ; then
	CONFIGURATION="$1"
fi
echo "Setting DPMS configuration to $CONFIGURATION"

# not sure this does much on modern systems, but in theory it turns of the
# bell, whatever that is.
xset b off

case "$CONFIGURATION" in
	docked)
		# 15 * 60 = 900
		# 30 * 60 = 1800
		# 45 * 60 = 2700
		xset dpms 900 1800 2700
		;;
	undocked)
		# 3 * 60 = 180
		# 6 * 60 = 360
		# 9 * 60 = 540
		xset dpms 180 360 540
		;;
	nosleep)
		echo "monitor will never sleep, remember to re-enable sleep when you are done"
		xset dpms 0 0 0
		;;
	*)
		echo "Invalid DPMS configuration '$CONFIGURATION'"
		exit 1
		;;
esac