You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.3 KiB

3 months ago
#!/bin/sh
# FreeBSD version
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