FreeBSD-on-Lenovo-x260/usr/local/sbin/acpi_oem_exec.sh

83 lines
2.2 KiB
Bash
Raw Permalink Normal View History

2023-09-03 16:26:02 +02:00
#!/bin/sh
#
if [ "$1" = "" -o "$2" = "" ]
then
echo "usage: $0 notify oem_name"
exit 1
fi
NOTIFY=`echo $1`
LOGGER="logger"
CALC="bc"
BC_PRECOMMANDS="scale=2"
ECHO="echo"
CUT="cut"
MAX_LCD_BRIGHTNESS=7
MAX_VOLUME=14
OEM=$2
DISPLAY_PIPE=/tmp/acpi_${OEM}_display
case ${NOTIFY} in
# 0x05)
# LEVEL=`sysctl -n dev.acpi_${OEM}.0.bluetooth`
# if [ "$LEVEL" = "1" ]
# then
# sysctl dev.acpi_${OEM}.0.bluetooth=0
# MESSAGE="bluetooth disabled"
# else
# sysctl dev.acpi_${OEM}.0.bluetooth=1
# MESSAGE="bluetooth enabled"
# fi
# ;;
0x11|0x10)
LEVEL=`sysctl -n dev.acpi_${OEM}.0.lcd_brightness`
PERCENT=`${ECHO} "${BC_PRECOMMANDS} ; \
${LEVEL} / ${MAX_LCD_BRIGHTNESS} * 100" |\
${CALC} | ${CUT} -d . -f 1`
MESSAGE="brightness level ${PERCENT}%"
;;
# 0x12)
# LEVEL=`sysctl -n dev.acpi_${OEM}.0.thinklight`
# if [ "$LEVEL" = "1" ]
# then
# MESSAGE="thinklight enabled"
# else
# MESSAGE="thinklight disabled"
# fi
# ;;
0x03|0x02)
LEVEL=`sysctl -n dev.acpi_${OEM}.0.volume`
PERCENT=`${ECHO} "${BC_PRECOMMANDS} ; \
${LEVEL} / ${MAX_VOLUME} * 100" | \
${CALC} | ${CUT} -d . -f 1`
MESSAGE="volume level ${PERCENT}%"
;;
0x01)
LEVEL=`sysctl -n dev.acpi_${OEM}.0.mute`
if [ "$LEVEL" = "1" ]
then
MESSAGE="volume muted"
else
MESSAGE="volume unmuted"
fi
;;
0x04)
LEVEL=`sysctl -n dev.acpi_ibm.0.mic_led`
if [ $LEVEL -eq 0 ]; then
sysctl dev.acpi_ibm.0.mic_led=1
mixer rec 0
fi
if [ $LEVEL -eq 1 ]; then
sysctl dev.acpi_ibm.0.mic_led=0
mixer rec 30
fi
;;
*)
;;
esac
${LOGGER} ${MESSAGE}
if [ -p ${DISPLAY_PIPE} ]
then
${ECHO} ${MESSAGE} >> ${DISPLAY_PIPE} &
fi
exit 0