Ubuntu Pastebin

Paste from emsid at Sun, 31 May 2015 13:47:07 +0000

Download as text
 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
#!/bin/bash

# script to process hotkeys for manipulating brightness setting via xrandr
min="0.25"
max="1.00"
increment="0.05"





# get current brightness
currentbrightness="$(xrandr --verbose | awk '/Brightness/ { print $2; exit }')"
#currentbrightness="0.25"

# process command line arguments

if [ "$1" == "increase" ]
then
	#echo "increase"
	newbrightness="$(echo "$currentbrightness"+"$increment" | bc)"
	#echo "old: $currentbrightness"
	#echo "new: $newbrightness"
	
	
	if awk "BEGIN {exit $newbrightness > $max ? 0 : 1}"
	then
	#	echo "new brightness higher than maximum of ${max}: $newbrightness"
		notify-send --icon="unity-display-panel" "Brightness" "100%"
		exit
	fi
	
	xrandr --output DVI-I-1 --brightness "$newbrightness"
	
elif [ "$1" == "decrease" ]
then
	#echo "decrease"
	newbrightness="$(echo "$currentbrightness"-"$increment" | bc)"
	#echo "old: $currentbrightness"
	#echo "new: $newbrightness"
	
	if awk "BEGIN {exit $newbrightness < $min ? 0 : 1}"
	then
	#	echo "new brightness lower than minimum of ${min}: $newbrightness"
		notify-send --icon="unity-display-panel" "Brightness" "25%"
		exit
	fi
	
	xrandr --output DVI-I-1 --brightness "$newbrightness"
	
else
	echo "$currentbrightness"
fi
Download as text