-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdbacklight
More file actions
executable file
·47 lines (34 loc) · 862 Bytes
/
dbacklight
File metadata and controls
executable file
·47 lines (34 loc) · 862 Bytes
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
#!/bin/bash
#
# Script that sets backlight brightness to a percentage
#
BLDIR="/sys/class/backlight/intel_backlight"
# Set usage output
USAGE="[-h |--help] <percentage>"
LONGUSAGE="\t-h, --help\n\t\tPrint this help message
\t<percentage>\n\t\tPercentage of max to set"
# Standard functions
source ${SCRIPTS}/functions.sh
# Script name
ME=$(basename $0)
# Parse arguments
ARGS=`getopt -o h --long help -n "${ME}" -- "$@"`
if [ $? != 0 ] ; then
usage
fi
eval set -- "$ARGS"
while true ; do
case "$1" in
-h|--help) usage; shift ;;
--) shift ; break ;;
* ) usage "Invalid argument $1";;
esac
done
#Remaining arguments are in $1, $2, etc. as normal
PER=$1
if [ -z "${PER}" ]; then
die "Must give a percentage"
fi
MAX=$(cat "${BLDIR}/max_brightness")
TARGET=$((${MAX} * ${PER} / 100))
echo ${TARGET} | sudo tee "${BLDIR}/brightness" > /dev/null