dominic revised this gist . Go to revision
1 file changed, 62 insertions
xbl-freebsd.sh(file created)
@@ -0,0 +1,62 @@ | |||
1 | + | #! /bin/sh | |
2 | + | # FreeBSD version | |
3 | + | # | |
4 | + | # Author: Dominic Reich <quick.hat4396@qtztsjosmprqmgtunjyf.com> | |
5 | + | ||
6 | + | print_usage () { | |
7 | + | echo >&2 "usage: $(basename ${0}) [0..100]" | |
8 | + | exit 1 | |
9 | + | } | |
10 | + | ||
11 | + | # check if argument given or not (list or set value) | |
12 | + | if [ $# -eq 1 ] | |
13 | + | then | |
14 | + | # set value (select between ac or bat mode) | |
15 | + | # check if argument is integer between 0,100 | |
16 | + | if [ "$1" -eq "$1" ] 2>/dev/null | |
17 | + | then | |
18 | + | if [ "$1" -ge 0 ] && [ "$1" -le 100 ] 2>/dev/null | |
19 | + | then | |
20 | + | # argument given and between 0,100 | |
21 | + | case $( sysctl -n hw.acpi.acline ) in | |
22 | + | ||
23 | + | (0) # BATTERY | |
24 | + | echo "$1" > ${HOME}/.backlight-bat | |
25 | + | ;; | |
26 | + | ||
27 | + | (1) # AC | |
28 | + | echo "$1" > ${HOME}/.backlight-ac | |
29 | + | ;; | |
30 | + | ||
31 | + | esac | |
32 | + | backlight "$1" | |
33 | + | else | |
34 | + | # arg not between 0 and 100 | |
35 | + | print_usage | |
36 | + | fi | |
37 | + | else | |
38 | + | # arg not an integer | |
39 | + | print_usage | |
40 | + | fi | |
41 | + | else | |
42 | + | # no args given, only list values | |
43 | + | case $( sysctl -n hw.acpi.acline ) in | |
44 | + | (0) # BATTERY | |
45 | + | current=bat | |
46 | + | ;; | |
47 | + | (1) # AC | |
48 | + | current=ac | |
49 | + | ;; | |
50 | + | esac | |
51 | + | ||
52 | + | for status in ac bat | |
53 | + | do | |
54 | + | if [ "${status}" = "${current}" ] | |
55 | + | then | |
56 | + | echo -e "${status}: ★ \t$( cat ${HOME}/.backlight-${status} )" | tr "[:lower:]" "[:upper:]" | |
57 | + | else | |
58 | + | echo -e "${status}:\t$( cat ${HOME}/.backlight-${status} )" | tr "[:lower:]" "[:upper:]" | |
59 | + | fi | |
60 | + | done | |
61 | + | echo -e "CUR:\t$(backlight | awk '{ print $2 }')" | |
62 | + | fi |
Newer
Older