Openbox的一些配置

开始用ArchLinux,我就决定要一切从简。于是Desktop Environment没有Gnome,而是直接用了Openbox。这样速度是快,不过还是有问题的:

  • 第一,重启/关机的时候必须用命令行调用 sudo
  • 第二,设备的自动挂载相当麻烦,还是得依靠 sudo mount 来解决

记得以前用gnome的时候这些都是自动就支持的,但是由于比较懒,也就一直忍受着这样的环境,每次都勤勤恳恳地打 sudo 来解决问题。不过,终于有一天我发现,貌似把系统配好才比较符合我的懒人习惯的哈 = =||| 于是开始找资料,瞎捣鼓,终于在牛年末体验上了便捷的开发环境 orz

主要的修改是更改dbus的配置文件,为相应的消息增加权限。

<!-- /etc/dbus-1/system.d/hal.conf -->
<policy group="power">
  <allow send_destination="org.freedesktop.Hal"
          send_interface="org.freedesktop.Hal.Device.SystemPowerManagement"/>
  <allow send_destination="org.freedesktop.Hal"
          send_interface="org.freedesktop.Hal.Device.LaptopPanel"/>
</policy>

<policy group="storage">
  <allow send_destination="org.freedesktop.Hal"
          send_interface="org.freedesktop.Hal.Device.Volume"/>
  <allow send_destination="org.freedesktop.Hal"
          send_interface="org.freedesktop.Hal.Device.Volume.Crypto"/>
  <allow send_destination="org.freedesktop.Hal"
          send_interface="org.freedesktop.Hal.Device.Storage.Removable"/>
</policy>

这样为power组和storage组加上了相应的权限,然后,把自己的id加入到对应的组去。

$ sudo gpasswd -a jay storage
$ sudo gpasswd -a jay power

OK,现在重启一下hal

$ sudo /etc/rc.d/hal restart

这时候打开pcmanfm,就能直接挂载分区了,告别烦人的没有权限的对话框,撒花~~

接下来再配置一下Openbox让其支持关机和重启的菜单项。

<!-- ~/.config/openbox/menu.xml -->
<item label="Shutdown">
  <action name="Execute">
    <execute>
      dbus-send --system --print-reply --dest="org.freedesktop.Hal" /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown
    </execute>
  </action>
</item>
<item label="Reboot">
  <action name="Execute">
    <execute>
      dbus-send --system --print-reply --dest="org.freedesktop.Hal" /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Reboot
    </execute>
  </action>
</item>

嗯,编辑完成,调用如下命令刷新Openbox的设置:

$ openbox --restart

这下就可以看到菜单中出现了重启和关机的选项了,好,大功告成。

BTW: 在这儿我要感谢Awesome,是它让我知道了存在不用logout而刷新配置的功能。YY了一下openbox之后,man了一下果然有这开关,便是这 --restart 。一经启用,神清气爽,步履轻盈,效果非凡哪。强力推荐,嗯~

发表评论

评论备注:

  1. 留言时的头像是Gravatar提供的服务。
  2. By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution. So, you don't fully own your words, so to speak.