linux长按三秒关机驱动,linux正确的关机姿势

哪里有这么麻烦。。。。 现在只要是一个正经的操作系统,都会对按一下电源键的动作做响应。

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

所以,在你的任务都正常退出的情况下,按一下电源键就行了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值