关机脚本(Linux,依赖于ConsoleKit)
为了更方面地用 Awesome 作为主窗口管理器,于是参考了 Blingbling 模块的关机/重启按钮,写了两个小脚本。使用 ConsoleKit 来实现关机/重启操作,使用 zenity 图形化。
关机脚本(ck-shutdown,因为使用了ConsoleKit)
#!/bin/sh
if zenity --question \
--title "Reboot?" \
--text "Are you sure to reboot?";
then
dbus-send --system --print-reply \
--dest="org.freedesktop.ConsoleKit" \
/org/freedesktop/ConsoleKit/Manager \
org.freedesktop.ConsoleKit.Manager.Restart;
fi
重启脚本(ck-reboot):
#!/bin/sh
if zenity --question \
--title "Shutdown?" \
--text "Do you want to shutdown?";
then
dbus-send --system --print-reply \
--dest="org.freedesktop.ConsoleKit" \
/org/freedesktop/ConsoleKit/Manager \
org.freedesktop.ConsoleKit.Manager.Stop
fi
不过看到 freedesktop 上 ConsoleKit 项目的介绍,似乎 ConsoleKit 的开发并不活跃,可能被 Systemd 相关项目替代。不过至少现在可以正常在 Ubuntu 12.04 下使用……
评论 (0)