Openbox (简体中文)
From ArchWiki
i18n |
---|
Česky |
English |
Español |
Français |
Italiano |
Nederlands |
Русский |
简体中文 |
Contents |
说明
Openbox 是一个轻量级、可高度定制以及支持大量标准的窗口管理器。它的功能在 官方网站 有详细的文档说明。这篇文章是关于在 Arch Linux 下 运行 Openbox。
安装
Openbox 可以从 Arch Linux 的仓库里得到:
# pacman -S openbox
一旦安装完毕, pacman 会指导你拷贝默认 menu.xml & rc.xml 配置文件到 ~/.config/openbox/ 目录下, 示例如下:
$ mkdir -p ~/.config/openbox/ $ cp /etc/xdg/openbox/rc.xml ~/.config/openbox/rc.xml $ cp /etc/xdg/openbox/menu.xml ~/.config/openbox/menu.xml
注意: 使用一般用户而不是 root 来做上述操作。
rc.xml 是 Openbox 的核心配置文件。它一般负责快捷键,主题,虚拟桌面和其他的作用。
menu.xml 控制 Openbox 的应用程序菜单,这个菜单在你点击桌面的时候会出现。默认情况下这个菜单相当简单,但是你可以很容易的修改它来达到你的要求。具体方法参见下面菜单一节,或者访问 官方网站.
让我们开始吧
使用 Openbox
要单独运行 Openbox, 只需要在 ~/.xinitrc 中加入下面一行:
exec openbox-session
在GNOME中使用Openbox
- 如果你使用GDM,请选择"GNOME/Openbox"登录选项
- 如果你使用startx,添加exec openbox-gnome-session 至 ~/.xinitrc中
- 在shell中:
xinit /usr/bin/openbox-gnome-session
在KDE中使用Openbox
- 如果你使用GDM,请选择"KDE/Openbox"登录选项
- 如果你使用startx,添加exec openbox-kde-session 至 ~/.xinitrc中
- 在shell中:
$ xinit /usr/bin/openbox-kde-session
在Xfce4中使用Openbox
登录到普通的 Xfce4 会话,在你选择的终端中输入:
$ killall xfwm4 ; openbox & exit
这样会终止 wfwm4,启动 Openbox,最后会关闭终端。 注销,确定选中了 "Save session for future logins" 选项 在下一次登录后,Xfce4 就会使用 Openbox 作为它的窗口管理器。
To be able to exit the session using xfce4-session, open your file ~/.config/openbox/menu.xml (if it isn't there, copy it from /etc/xdg/openbox/menu.xml).
Look for the entry:
<item label="Exit Openbox"> <action name="Exit"> <prompt>yes</prompt> </action> </item>
and change it to:
<item label="Exit Openbox"> <action name="Exit"> <prompt>yes</prompt> <command>xfce4-session-logout</command> </action> </item>
Otherwise, using the "Exit" entry of the root-menu will cause Openbox to terminate its execution, leaving you without a window manager.
If you have an issue changing between virtual desktops with the mouse wheel skipping over virtual desktops, open your ~/.config/openbox/rc.xml file and move the mouse binds with actions "DesktopPrevious" and "DesktopNext" from the context "Desktop" to the context "Root" (you may need to define the Root context).
If you want to use the Openbox root-menu instead of Xfce's, you may terminate Xfdesktop by running the following command in a terminal:
$ xfdesktop --quit
However, Xfdesktop manages the wallpaper and desktop icons, requiring you to use other utilities, such as ROX, for these functions.
(When terminating Xfdesktop, the above issue with the virtual desktops is no longer a problem.)
配置
偏好
目前, 有两种选择来配置OpenBox的核心参数; 手动编辑 rc.xml文件, 或者使用ObConf.
手动设定偏好
要手动配置OpenBox,使用你喜爱的文本编辑器简单的编辑 ~/.config/openbox/rc.xml 文件. 配置文件提供大量的注解信息, 而且在官方上可以找到完整的 帮助文档.
使用ObConf设定偏好
ObConf 是一个基于图形界面的Openbox配置工具, 它能设定包括主题、虚拟桌面、窗口属性和桌面边缘的大多数配置.
要安装ObConf,在终端运行:
# pacman -S obconf
注: ObConf不能用来设定键盘快捷键和其他一些高级功能。这些修改,您必须编辑rc.xml手动(见上文。 )
菜单管理
默认Openbox菜单包括各种不同的应用,以让您可以开始使用, 但你可能想自定义一些细节. 可以使用一下这些方法:
手动
类似于 rc.xml 文件, 你可以使用喜爱的文本编辑器编辑 ~/.config/openbox/menu.xml 文件. 虽然许多设定不需加以说明, 但最好还是看一下完整的帮助文件.
MenuMaker
MenuMaker MenuMaker是一个功能强大的工具,用来为各种窗口管理器创建基于XML的菜单,包括Openbox. MenuMaker将搜寻您电脑中的可执行程序,并在搜索结果的基础上建立一个XML菜单. 根据用户要求,它可以配置排除Legacy X, GNOME, KDE或Xfce的应用软件.
MenuMaker可以从AUR取得.
安装后, 你可以通过运行以下命令来创建一个完整的菜单:
$ mmaker -v OpenBox3
By default, MenuMaker will not overwrite an existing menu.xml. To do so, run it with the -f (force) argument:
$ mmaker -vf OpenBox3
要查看完整的选项列表,请运行 mmaker --help
这样你就会得到一个很完整的菜单. 现在你可以手动编辑 menu.xml文件, 或者在你安装新的软件时简单的生成一个新的菜单.
Obmenu
Obmenu is a GUI-based menu editor for Openbox. For those who don't enjoy editing XML source code, this is probably the best option for you.
It is available in the community repository:
# pacman -S obmenu
Once installed, simply run obmenu and add or remove the desired applications.
obm-xdg
obm-xdg is a command-line tool that comes with Obmenu. It can generate a categorized sub-menu of installed GTK/GNOME applications.
To use obm-xdg, add the following line to ~/.config/openbox/menu.xml:
<menu execute="obm-xdg" id="xdg-menu" label="xdg"/>
Then run openbox --reconfigure to refresh the Openbox menu. You should now see a sub-menu labeled xdg in your menu.
NOTE: If you do not have GNOME installed, then you need to install gnome-menus package for obm-xdg to work.
启动程序
Openbox features support for running programs at startup. This is provided by the "openbox-session" command.
有两种方法实现自启动:
- 如果想用 startx 命令登陆到 X 会话, 修改 executes openbox 为 execute openbox-session .
- 如果想用 GDM/KDM 登陆管理器登陆, 那么选择 Openbox 会话它会自动启动.
自动启动程序通过 ~/.config/openbox/autostart.sh来配置. 关于完整操作指南和如何最佳配置可以参考 Openbox 官方.
Per-application settings
Openbox features per-application settings, allowing you to define rules for your programs. For example, you can:
- load your web browser on a certain desktop
- load your terminal without a window border
- load your torrent client at a certain position on your screen
These are defined in ~/.config/openbox/rc.xml. As you might expect, the instructions are well-documented within the file itself. Full details can also be found here: http://icculus.org/openbox/index.php/Help:Applications
主题和外观
除了Openbox主题话题, 下面一部分的目的是为用户说明不在GNOME, KDE 或 Xfce的帮助下让你配置的Openbox作为一个独立的桌面运行.
Openbox 主题
Openbox主题的外观控制窗口边框,包括标题栏和标题栏按钮。他们还确定出现在应用程序的菜单和屏幕显示( OSD ).
更多的主题可以用以下命令从标准库得到:
# pacman -S openbox-themes
这个软件包并不是唯一的,你可以从以下网站获得更多的主题:
- box-look.org
- customize.org
- http://www.minuslab.net/themes/
- http://celo.wordpress.com/themes/
- http://vault.openmonkey.com/pages/openbox
- http://hewphoria.com/?p=submission&type=theme&cat=7
下载的主题可以通过释放到 ~/.themes 目录来安装或者通过使用ObConf工具来安装.
创建一个新的主题是相当容易的,并且可以从官方找到 详细说明.
桌面墙纸
Openbox本身并不包含一种方法来改变墙纸. 你可以通过 Feh或Nitrogen来简单做到. 其他选择包括 ImageMagick, hsetroot 和 xsetbg.
GTK 主题
GTK2/GTK+
基于GTK+主题可以通过 lxappearance, gtk-chtheme, 或 switch2 简单管理. 要安装这些软件, 在终端运行:
# pacman -S lxappearance
或者
# pacman -S gtk-chtheme
或者
# pacman -S gtk-theme-switch2
现在你可以简单的运行 lxappearance, gtk-chtheme 或 switch2 来设置你所需的主题.
GTK1
For legacy GTK1 themes, install the gtk-theme-switch package:
# pacman -S gtk-theme-switch
Then run switch to select a desired theme.
GTK 字体
手动编辑配置文件
如果你想改变你字体的类型和大小, 请把以下内容添加到 ~/.gtkrc.mine:
style "user-font" { font_name = "[font-name] [size]" } widget_class "*" style "user-font" gtk-font-name = "[font-name] [size]"
在 [font-name] [size] 处是你理想的字体和大小. 例如:
style "user-font" { font_name = "DejaVu Sans 8" } widget_class "*" style "user-font" gtk-font-name = "DejaVu Sans 8"
两者 font_name和gtk-font-name 值是必需的并向后兼容.
使用GUI工具
你可以使用 gtk-chtheme 或 lxappearance 来设置 GTK font settings. 请参阅上面部分.
GTK 图标
首先, 提取所需的图标主题到 /usr/share/icons (system-wide access) 或 ~/.icons (local user access), 然后:
手动编辑配置文件
将以下内容添加到 ~/.gtkrc.mine:
gtk-icon-theme-name = "[name-of-icon-theme]"
[name-of-icon-theme]的值是图标主题目录. 例如:
gtk-icon-theme-name = "Tango"
确保 ~/.gtkrc-2.0 是配置解析到 ~/.gtkrc.mine:
# ~/.gtkrc-2.0 # -- THEME AUTO-WRITTEN DO NOT EDIT include "/usr/share/themes/Rezlooks-Gilouche/gtk-2.0/gtkrc" include "/home/username/.gtkrc.mine" # -- THEME AUTO-WRITTEN DO NOT EDIT
使用图形界面工具
你可以使用 lxappearance 来选择GTK图标主题. 请参照上述部分.
鼠标光标主题
提取想要的鼠标主题到以下二者任何一个目录 /usr/share/icons (system-wide access) 或 ~/.icons (local user access).
把以下内容添加到 ~/.Xdefaults:
Xcursor.theme: [name-of-cursor-theme] [name-of-cursor-theme] 的值是鼠标主题目录. 例如: Xcursor.theme: Vanilla-DMZ-AA
改变大小:
Xcursor.size: [size]
桌面图标
Openbox 并不提供一种方法能在桌面上显示图标. 但PcmanFM, ROX, iDesk, 或 Nautilus (and the gnome-settings-daemon) 可以提供这样的功能.
ROX 和 PCmanFM 是提供额外功能的轻量级文件管理器.
提示 & 技巧
推荐程序
登录管理器
SLiM 为独立的Openbox提供一个轻便简洁的图形登陆界面. 对于SLiM,Arch Wiki提供了详细的说明.
Composite Desktop
Xcompmgr is a lightweight composite manager capable of rendering drop shadows, fading and simple window transparency within Openbox and other window managers.
应用程序启动器
dmenu
Set-up dmenu as described in the dmenu wiki article.
Then, add the following entry to the <keyboard> section ~/.config/openbox/rc.xml to enable a shortcut to launch dmenu:
<keybind key="W-p"> <action name="Execute"> <command>~/path/to/your/dmenu-script</command> </action> </keybind>
Gmrun
gmrun provides an excellent Run dialog box, similar to the Alt+F2 features found in Gnome and KDE:
pacman -S gmrun
Add the following entry to the <keyboard> section ~/.config/openbox/rc.xml to enable Alt+F2 functionality:
<keybind key="A-F2"> <action name="execute"><execute>gmrun</execute></action> </keybind>
文件管理器
文件管理器有很多的选择, 但最流行的轻量级文件管理器有:
- Thunar. Thunar支持插件和自动挂载功能.
pacman -S thunar
Thunar may be started in daemon mode for tighter desktop integration. For instance, inserting a USB pendrive will invoke a Thunar window to popup, with the drive contents listed in the window.
要以Daemon方式启动Thunar, 请编辑~/.config/openbox/autostart.sh文件并添加以下语句:
thunar --daemon &
- ROX (ROX 提供桌面图标)
pacman -S rox
- PCMan (pcmanfm 也提供桌面图标)
pacman -S pcmanfm
至于更轻量级的选择, 可以考虑 Gentoo 或 emelFM, 两者都是用流行的 'Midnight Commander' 双窗格布局 (这两个基于 gtk 1.2.x).
当然, 你也可以使用 GNOME 的 Nautilus. 虽然与上面的相比较慢, 但它具有更多优势,支持虚拟文件系统 (比如远程SSH, FTP 和 Samba 连接).
Clipboard Managers and copy/paste
你可能希望安装一个剪贴板管理器来丰富复制/粘贴功能. xfce4-clipman-plugin, parcellite, or glipper-old may be installed via pacman. Add your choice to autostart.sh. From the terminal, Ctrl+Insert as copy and Shift+Insert as paste generally works as well. 在终端中你也可以用Ctrl+Shift+C复制, 通过单击鼠标中键粘贴.
面板
- PyPanel
- bmpanel
- Tint2
- LXPanel
- fbpanel
- PerlPanel
- fspanel
- xfce4-panel
- gnome-panel
- avant-window-navigator
- cairo-dock
- wbar
托盘
虚拟桌面监视器
选择你需要的并添加到你的启动文件.
Get xprop values for per-app settings quickly
If you use per-application settings frequently, you might find this bash alias handy:
alias xp='xprop | grep "WM_WINDOW_ROLE\|WM_CLASS" && echo "WM_CLASS(STRING) = \"NAME\", \"CLASS\""'
To use, run xp and click on the running program that you'd like to define with per-app settings. The result will display only the info that Openbox requires, namely the WM_WINDOW_ROLE and WM_CLASS (name and class) values:
[thayer@dublin:~] $ xp WM_WINDOW_ROLE(STRING) = "roster" WM_CLASS(STRING) = "gajim.py", "Gajim.py" WM_CLASS(STRING) = "NAME", "CLASS"
Linking the menu to a command
一些人可能想将一些其它的命令链接到Openbox的主菜单. This is useful for creating a menu button in a panel, for example. 虽然 Openbox 不支持这一点, 但一个非常简单的脚本 xdotool 能模拟按键并运行命令. Xdotool 可以在 AUR中得到. 要使用它, 只需将下面的代码添加到rc.xml的<keyboard>部份:
<keybind key="A-C-q"> <action name="ShowMenu"> <menu>root-menu</menu> </action> </keybind>
重启或重新载入 Openbox. 现在你可以在光标位置通过以下命令魔法般调出你的菜单:
# xdotool key ctrl+alt+q
当然, 你也可以改变为你喜欢的快捷键.
Urxvt in the background
With Openbox, running a terminal as desktop background is easy. You won't need devilspie here.
首先你必须启用透明, 打开你的 .Xdefaults 文件 (如果它不存在, 在你的主文件夹创建它).
URxvt*transparent:true URxvt*scrollBar:false URxvt*geometry:124x24 #I don't use the whole screen, if you want a full screen term don't bother with this and see below. URxvt*borderLess:true URxvt*foreground:Black #Font color. My wallpaper is White, you may wish to change this to White.
然后修改你的 .config/openbox/rc.xml 文件 :
<application name="urxvt"> <decor>no</decor> <focus>yes</focus> <position> <x>center</x> <y>20</y> </position> <layer>below</layer> <desktop>all</desktop> <maximized>true</maximized> #Only if you want a full size terminal. </application>
The magic comes from the <layer>below</layer> line, which place the application under all others. Here Urxvt is displayed on all desktops, change it to your convenience.
附加资源
- Openbox Website - Openbox官方网站
- Planet Openbox - Openbox最新消息
- Box-Look.org - 全面的提供Box主题和相关资源的网站
- Application recommendations