UbuntuHelp:Openbox/zh
来自Ubuntu中文
![]() |
点击翻译: |
English • 中文 |
Openbox是一个使用freedesktop标准的轻量级窗口管理器。 它能或作为替换Gnome默认的窗口管理器被使用——Metacity——或作为一个独立的桌面环境。
Openbox是什么?
要回答那个问题,知道窗口管理器和桌面环境间的区别是重要的。
窗口管理器是一个在你的屏幕上绘出正在运行的程序的边框的程序。窗口管理器控制你的程序窗口怎样地工作、怎样的外观和如何地行动。它决定用什么装饰窗口并给你移动、隐藏、调整大小、最小化和关闭窗口的方法。它控制按下按钮要做的那些东西,按下键使得事情发生。
另一方面,桌面环境注重整个桌面。它提供任务栏,系统托盘,登录管理器,附加菜单或者可能屏幕保护和桌面图标。它也可能包含文件管理器,字档编辑器或其他辅助程序。
Openbox是一个窗口管理器,不是一个桌面环境。Openbox仅仅是负责维持你在屏幕上打开的窗口——没有别的。那意味着安装Openbox不会给你简单的菜单访问到壁纸选项,任务栏或系统面板,或者大多数的doo-dads。然而,它给你一个结构去建立吸收做那些事情的程序——并通常在风格和界面有着一个更大的自由度。
Openbox能被单独使用,不用一个桌面环境,或者能被用于替换在完整的桌面环境里的窗口管理器。两种方法都受欢迎。
特性和益处
- 最小化开支, 使它适用于轻量级系统、老机器或speed demons;
- 极少依赖,又一吸引轻量级或最小化系统的特性;
- 鼠标轮滚屏的桌面,快速访问多个工作区;
- 可制定的右键菜单与可制定的keybind被写入XML文件;
- 输送菜单,菜单脚本的输出输送进Openbox菜单使用(想像它的可能性!);
- 大量的主题,所有主题都能通过文本文件定制;
- 用C语言写成;
- 多头Xinerama支持双屏输出;
- 尤其是,速度。
缺点
- 分散,一些人感到有吸引力但其他人不喜欢;
- 它需要用一段时间设立,甚至一旦它设立,更换风格或主题会成为附加工作;
- 不处理鲜明的特性,像壁纸或任务栏;
- 依靠外部程序处理简单的任务;
- 需要保养,因为它不是自己设立的;
- 一些简单的操作,例如自动装载CDROM或绑定数码相机,会需要额外的步骤。
安装
Openbox在universe软件仓库里;在前进得更远之前确定你的软件仓库是开启的。 或在命令行里安装Openbox,
sudo aptitude install openbox obconf
或通过Synaptic套件管理程序;标记openbox与obconf包为安装和应用变化。
在Gnome上用Openbox
只有你想把一个现有的Gnome桌面改变为Openbox才用使用以下教程。
在Gnome里替换Metacity
欲在Gnome替换Metacity安装,在终端窗口里键入这命令:
openbox --replace
如果你想让Openbox保持为你默认的窗口管理器,只需在登出时保存你的会话。
选择会话
当你到达GDM登录窗口时,按下“会话”按钮应该会给你Openbox选项。单击,让你登录后启动Openbox。
用Openbox本身
使用Openbox本身是一个简单的工作。编辑你的~/.xinitrc文件并加入这行,让X启动时呼叫Openbox。
exec openbox-session
当然,不需要额外的程序与附件,在纯净的Openbox安装中很少事情要考虑。保持阅读为更多想法。
配置
Openbox使用两个主要的配置文件:rc.xml,用来设置快捷键、桌面名和窗口行为;和menu.xml,包含右键菜单指令。正如你可能已经猜到,两个文件都用XML写成并且能用任何字档编辑器编辑。如果你犯了错误并且你的文件不再是正确的XML,那么Openbox会回复默认的配置文件,于/etc/xdg/openbox/。 下面是一个menu.xml文件有什么内容的例子。
<item label="Program_Name"> <action name="Execute"> <execute> Program_Command </execute> </action> </item>
正如你能看到的,菜单是整齐的嵌套因此它们能被容易地追随。每个条目都有一个开始标签和关闭标签,并且每个是清楚易读的。rc.xml有一个类似的结构。 欲知更多关于如何手动编辑Openbox的XML文件的信息,参阅Openbox网站。
ObMenu
如果你不喜欢编辑XML文件,这里有ObMenu。这是一个非常小的Python程序,允许你用一个简单的GUI修改菜单,并且把结果保存在menul.xml文件。它快速、容易,你也不用为menu.xml文件的笔误操心。 要安装它,从这里下载ObMenu包并解压。然后安装它的依赖。
sudo aptitude install python2.5 python-glade2 python-gtk2
现在输入这行命令来安装程序:
sudo python setup.py install
如果一切顺利(它可能会),你应该能在终端输入obmenu命令来叫出ObMenu的界面。
定制
Openbox可能只是一个窗口管理器,但也有很多机会可以添加一些资质。
Obconf
Obconf是一个便利的用来制定Openbox的程序。它允许设置主题、一些窗口行为、桌面数目,还有dock。你能用这行命令启动Obconf:
obconf
留意:Edgy (Ubuntu 6.10)的用户应该知道Obconf里一个偏差可能会阻止它运行。你能用这些命令修正……
cd /usr/lib sudo ln libobparser.so.0.4.0 libobparser.so.1 sudo ln libobrender.so.0.4.0 libobrender.so.1
现在在一个X终端窗口进入obconf应该会激活Obconf对话框。
主题
默认主题的变种在仓库可用;你能用Synaptic套件管理程序安装,和通过一行终端命令:
sudo aptitude install openbox-themes
大量的第三方站点也提供经压缩的主题包。下载一个你喜欢的,然后解压至~/.themes文件夹。
tar -xzvf compressed-theme-package-that-you-downloaded.tar.gz -C ~/.themes/
Don't forget the trailing slash. Now you can use Obconf to select your theme.
修正主题
The better part of a theme package is contained in a text file called themerc inside some nested folders in ~/.themes. If you want to fine-tune a theme (such as, make the letters bigger, or change the width of a window handle, or pick a different color), find the correct file in your ~/.themes folder and edit it as you like. When you save it, you can reselect the theme with Obconf, and your changes will take effect.
壁纸
feh
A number of programs can handle the responsibility of showing a background image; the most common is a funny little program called feh. feh is actually a lightweight image viewer with a number of options, but perhaps the most popular is the ability to draw a desktop background. Pick a wallpaper image and try this command in a terminal.
feh --bg-scale /path/to/your/background/image.jpg
Feh can handle other file types than just jpg. Once you've picked a wallpaper, feh stores the name in a file called .fehbg. That means you can tell it to restore the wallpaper on the next boot by checking to see what's inside that file. Add this line to your ~/.xinitrc file.
eval `cat $HOME/.fehbg` &
Nitrogen
If you perfer a graphical method for choosing between many background images, perhaps nitrogen is a good option. Nitrogen allows you to choose from many background images from a preset directory, you should add any wallpapers you wish to choose from to this directory. To use nitrogen, you should add
nitrogen /path/to/backgroundfiles/
to your menu.xml file (or alternatively add it to your menu using obmenu.) Next you must add
nitrogen --restore
to your ~/.config/openbox/autostart.sh (You can create this file if it does not exist) Now you can use your nitrogen entry in your menu to change your wallpaper and the changes will be restored on login.
随机壁纸
One neat trick available with feh is a random wallpaper on each boot. Make a directory in your home folder called "wallpapers", then put a few background images in it. Then copy this text into a file called wallpaper.sh, and save it anywhere.
#!/bin/bash WALLPAPERS="$HOME/path_to_your_wallpapers" ALIST=( `ls -w1 $WALLPAPERS` ) RANGE=${#ALIST[*]} SHOW=$(( $RANDOM % $RANGE )) feh --bg-scale $WALLPAPERS/${ALIST[$SHOW]}
Next make the script executable.
chmod +x wallpaper.sh
Now add that program to your ~/.xinitrc file, like this.
./wallpaper.sh
When you log in, the script should be executed, and feh will pick a new wallpaper for your amusement.
其他选项
feh isn't the only program that can handle drawing a background image. Here are some others.
- xsetbg
- imagemagick
- nitrogen
Additionally, some file managers have the option of managing your wallpaper.
- rox-filer
- PCManFM
- Nautilus, if started without the --no-desktop option, will draw over the background image
桌面图标
iDesk
You can add customizable, clickable icons to your desktop with iDesk. iDesk is available in the Ubuntu repositories, and is installable from the command line with
sudo aptitude install idesk
Consult the iDesk wiki for instructions on how to configure and use iDesk. For icon sets, you may wish to search the repositories, or download them from third-party customization sites, such as Gnome-Look.org and similar locations.
Rox-Filer
Rox-filer is a file manager, but in addition to handling wallpaper, it also has a pinboard option, and can manage desktop icons. Install rox-filer with this command:
sudo aptitude install rox-filer
You can set up the pinboard through Rox's menus.
任务栏和页面切换
Some people prefer to use a taskbar or pager to keep track of running programs. Here's a list of applications you can add to your Openbox installation that will handle that task for you.
- bbpager
- pypanel (Note: For Ubuntu 6.10 users, the PyPanel included in the repositories is often reported as broken. Look here for a possible way to fix it.)
- gnome-panel
- fspanel
- fbpanel
- perlpanel
- xfce4-panel
系统监视器
If you're looking for a way to display system information, try these nifty programs.
- gkrellm, which has a number of floating or docked graphical meters and displays
- adesklets, for similar graphical displays
- conky, a highly configurable text and graphic output that draws directly to your desktop
If you're working on Openbox in conjunction with a Gnome installation, you might also look into gdesklets, which features some very polished monitors and meters for desktop display.
GTK主题
Program GUIs might look ugly if you're working on a pure Openbox system. Install gtk-theme-switch and the gtk2-engines package to give yourself a few more appealing options.
sudo aptitude install gtk-theme-switch gtk2-engines
Bring up the configuration menu with this command, from a terminal or the Openbox right-click menu.
switch2
Be sure to search the repositories for other engines that aren't included in the gtk2-engines package. You can also try installing a Gnome package that will manage some of the settings for you.
sudo aptitude install gnome-settings-daemon
If you prefere an XFCE look, try
sudo aptitude install xfce-mcs-manager
Both of those programs can be added to your Openbox menu, or started from a terminal.
自动挂载
To automount external volumes -- like CDs and USB drives -- you will need a volume manager. Here is the Gnome application that handles that:
sudo aptitude install gnome-volume-manager
Kubuntu and Xubuntu share the ivman application, which is installable with:
sudo aptitude install ivman
屏幕保护
If you're building an Openbox desktop with Gnome already installed, you'll probably already have gnome-screensaver in place. Pure Openbox fans might want to install xscreensaver, which is more customizable and has a wider variety of screensavers involved. Without K/X/Ubuntu in place, installing xscreensaver needs a couple of extra commands:
sudo mkdir /usr/share/backgrounds sudo aptitude install xscreensaver xscreensaver-gl-extra xscreensaver-data-extra
The first command sets up a default directory that xscreensaver will look for when it runs. If you don't create that directory, you'll get a string of error messages the first time you set the preferences. The second command installs xscreensaver and its optional files. xscreensaver in Ubuntu is packaged with several screensaver options enabled, but not installed. As a result, you might see brief error messages when the daemon picks an enabled screensaver that it can't find. Adding those packages puts the missing screensavers in place, which is easier than disabling the absent ones. Now add this command to your ~/.xinitrc file, to start the xscreensaver daemon on boot.
xscreensaver --no-splash
You can access the xscreensaver preferences panel by running xscreensaver-demo from the Openbox menu or from a terminal window.
运行会话框
Some people find it convenient to invoke a run dialogue program, which is usually triggered with ALT+F2. You'll need to change the keybinding in the rc.xml file in order to regain that function. If you are using XFCE components, changing rc.xml to point at xfrun4 might solve the problem. If not, consider installing the gmrun program.
sudo aptitude install gmrun
Change your rc.xml file to point to gmrun; you don't have to add it to your .xinitrc file, though.
其他轻量级窗口管理器
替换Metacity
As an alternative to Metacity, consider these window managers.
- xfwm4: This is the default window manager for the XFCE4 desktop environment, and is a very comprehensive substitute. Instructions on replacing Metacity with XFCE4 are found here.
- Fluxbox: Fluxbox is a very attractive, very lightweight window manager that is highly customizable and has a very strong following. To replace Metacity with Fluxbox, check this thread in the forums.
Standalone
Here are some alternatives to Openbox for standalone window managers and desktop environments.
- FVWM: FVWM is a traditional window manager with a long history in the Linux community. It is highly customizable, very flexible and has a very slim profile.
- FVWM-Crystal: FVWM is set of configuration files that sits atop of FVWM, and is installable as a complete desktop environment with integrated audio controls, screensaver options and wallpaper control. It's also one of the prettiest options available to older hardware.
- Fluxbox: Fluxbox is a window manager intended to be lightweight, fast and beautiful. It achieves all of those things, and more. If you find you enjoy working with Fluxbox, the Fluxbuntu project might be for you.
- IceWM: IceWM is likewise a clean and svelte window manager, but keeps a "traditional" desktop look that some users prefer.
- Blackbox: Blackbox served as the basis for Openbox, although Openbox has been completely rewritten in past years. Blackbox is still available, and still a popular option.
- XFCE: XFCE serves as the underpinnings for Xubuntu, a fully supported Ubuntu variant complete with an office suite, networking interfaces, e-mail clients, and more. The project began as an option to run Ubuntu on older hardware, but has matured into a complete system on par with Kubuntu or Ubuntu. Visit their home page for more information about the project.
外部连结
Openbox
- Openbox web site
- Openbox documentation wiki
- An Openbox howto on ubuntuforums.org
- XSession|Wiki page
- How to build an Oubuntu! desktop
Openbox主题
一个.xsession样品文件
其他程序
其他兴趣站点
-- I'm still of the mind that this page should be split out, with Openbox on Gnome taking the bulk of the previous material, and this staying closer to a "pure Openbox on Ubuntu" explanation. Edit: Scratch that. Openbox+Gnome material can shift to ReplaceMetacityWithOpenbox, and link to there from here. -- K.Mandla