xbl-freebsd.sh
· 1.3 KiB · Bash
Raw
#! /bin/sh
# FreeBSD version
#
# Author: Dominic Reich <quick.hat4396@qtztsjosmprqmgtunjyf.com>
print_usage () {
echo >&2 "usage: $(basename ${0}) [0..100]"
exit 1
}
# check if argument given or not (list or set value)
if [ $# -eq 1 ]
then
# set value (select between ac or bat mode)
# check if argument is integer between 0,100
if [ "$1" -eq "$1" ] 2>/dev/null
then
if [ "$1" -ge 0 ] && [ "$1" -le 100 ] 2>/dev/null
then
# argument given and between 0,100
case $( sysctl -n hw.acpi.acline ) in
(0) # BATTERY
echo "$1" > ${HOME}/.backlight-bat
;;
(1) # AC
echo "$1" > ${HOME}/.backlight-ac
;;
esac
backlight "$1"
else
# arg not between 0 and 100
print_usage
fi
else
# arg not an integer
print_usage
fi
else
# no args given, only list values
case $( sysctl -n hw.acpi.acline ) in
(0) # BATTERY
current=bat
;;
(1) # AC
current=ac
;;
esac
for status in ac bat
do
if [ "${status}" = "${current}" ]
then
echo -e "${status}: ★ \t$( cat ${HOME}/.backlight-${status} )" | tr "[:lower:]" "[:upper:]"
else
echo -e "${status}:\t$( cat ${HOME}/.backlight-${status} )" | tr "[:lower:]" "[:upper:]"
fi
done
echo -e "CUR:\t$(backlight | awk '{ print $2 }')"
fi
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 |
63 |