JD4的电源按键是怎么调用的?
目前在用的UBUNTU20。04固件,官方固件,上电即启动,按电源按键,系统直接关机,进入poweroff,请教各位大牛,这个文件系统是怎么调用电源按键的event的?固件的内核已集成gpio-key功能,已设定power按键,配合18。04的UBUNTU文件系统,按电源键时是可以调出关机注销挂起等的对话框的,不会直接关机,但这个20.04的文件系统是直接关机断电,好生迷惑。
看了一般的UBUNTU,是有PM功能或ACPI的,这个官方固件没有,查了很久也没有找着调用入口,哪位高手指点一下!!
系统etc下有Powermanager文件夹,也有相应的脚本
下面是sh代码
#!/bin/sh
EVENT=${1:-short-press}
TIMEOUT=3 # s
PIDFILE="/tmp/$(basename $0).pid"
LOCKFILE=/tmp/.power_key
short_press()
{
logger -t $(basename $0) "[$$]: Power key short press..."
if type pm-suspend &>/dev/null; then
SUSPEND_CMD="pm-suspend"
else
SUSPEND_CMD="echo -n mem > /sys/power/state"
fi
if [ ! -f $LOCKFILE ]; then
logger -t $(basename $0) "[$$]: Prepare to suspend..."
touch $LOCKFILE
sh -c "$SUSPEND_CMD"
{ sleep 2 && rm $LOCKFILE; }&
fi
}
long_press()
{
logger -t $(basename $0) "[$$]: Power key long press (${TIMEOUT}s)..."
logger -t $(basename $0) "[$$]: Prepare to power off..."
poweroff
}
logger -t $(basename $0) "[$$]: Received power key event: $@..."
case "$EVENT" in
press)
# Lock it
exec 3<$0
flock -x 3
start-stop-daemon -K -q -p $PIDFILE || true
start-stop-daemon -S -q -b -m -p $PIDFILE -x /bin/sh -- \
-c "sleep $TIMEOUT; $0 long-press"
# Unlock
flock -u 3
;;
release)
# Avoid race with press event
sleep .5
start-stop-daemon -K -q -p $PIDFILE && short_press
;;
short-press)
short_press
;;
long-press)
long_press
;;
esac
——————————————————————————————
很奇怪的是一直没有得到调用。
你现在是想实现什么。18和20对按键事件输入处理不一样,你现在是想直接关机是吗 # support power management
if [ -e "/usr/sbin/pm-suspend" -a -e /etc/Powermanager ] ;
then
mv /etc/Powermanager/power-key.sh /usr/bin/
mv /etc/Powermanager/power-key.conf /etc/triggerhappy/triggers.d/
if [[ "$CHIPNAME" == "rk3399pro" ]];
then
mv /etc/Powermanager/01npu /usr/lib/pm-utils/sleep.d/
mv /etc/Powermanager/02npu /lib/systemd/system-sleep/
fi
mv /etc/Powermanager/triggerhappy /etc/init.d/triggerhappy
rm /etc/Powermanager -rf
service triggerhappy restart
fi
页:
[1]