哪里有这么麻烦。。。。 现在只要是一个正经的操作系统,都会对按一下电源键的动作做响应。
Linux默认在没有gnome-power-manager的情况下,
会执行shutdown -h now ,自动就正常关机了。
/etc/acpi/events/power.conf
----------------------------
# ACPID config to power down machine if powerbutton is pressed, but only if
# no gnome-power-manager is running
event=button/power.*
action=/etc/acpi/actions/power.sh
/etc/acpi/actions/power.sh
----------------------------------------
#!/bin/sh
PATH=/sbin:/bin:/usr/bin
# Get the ID of the first active X11 session:
uid_session=$(
ck-list-sessions | \
awk '
/^Session[0-9]+:$/ { uid = active = x11 = "" ; next }
{ gsub(/'\''/, "", $3) }
$1 == "unix-user" { uid = $3 }
$1 == "active" { active = $3 }
$1 == "x11-display" { x11 = $3 }
active == "TRUE" && x11 != "" {
print uid
exit
}')
# Check that there is a power manager, otherwise shut down.
[ "$uid_session" ] &&
ps axo uid,cmd | \
awk '
$1 == '$uid_session' &&
($2 ~ /gnome-power-manager/ || $2 ~ /kpowersave/ ||
$2 ~ /kded4/ || $3 ~ /guidance-power-manager/) \
{ found = 1; exit }
END { exit !found }
' ||
shutdown -h now
所以,在你的任务都正常退出的情况下,按一下电源键就行了。