Openbox
De Wiki do Arch Linux Brasil
Predefinição:I18n links start Predefinição:I18n entry Predefinição:I18n entry Predefinição:I18n links end
Tabela de conteúdo |
Introdução
Openbox é um gerenciador de janelas altamente configuravel. Suas características são bem documentadas no site oficial. Este artigo demonstra a usar o Openbox sob Arch Linux.
Instalação
Openbox está disponível no repositório "extra":
# pacman -S openbox
Após a instalação, pacman orientará a copiar os arquivos de configuração menu.xml & rc.xml para ~/.config/openbox/, por exemplo:
$ mkdir -p ~/.config/openbox/
$ cp /etc/xdg/openbox/rc.xml ~/.config/openbox/rc.xml $ cp /etc/xdg/openbox/menu.xml ~/.config/openbox/menu.xml $ cp /etc/xdg/openbox/autostart.sh ~/.config/openbox/autostart.sh
Note: faça isso como usuario comun, e não como root.
O rc.xml é o arquivo base de configuração do Openbox.É usado para controlar atalhos de teclado, temas, desktops virtuais e outras caraterísticas.
O menu.xml controla o menu de applicações que aparece quando você aperta o botão direito do mouse na área de trabalho. Os itens por defeito são escassos e inúteis. Mas e muito fácil mudar a estrutura do menu, Veja a seção do menu abaixo para mais detalhes, ou visite Openbox.
O aquivo autostart.sh controla quais programas carregam quando você inicia a sessão openbox.
Getting Started
Usando Openbox
Para iniciar Openbox basta digitar no ~/.xinitrc:
exec openbox-session
Usando Openbox com GNOME
- Se você usa GDM, escolha "GNOME/Openbox" como opção de login
- Se você usa startx, adicione exec openbox-gnome-session no ~/.xinitrc
Usando Openbox com KDE
- Se você usa KDM, escolha "KDE/Openbox" como opção de login
- Se você usa startx, digite exec openbox-kde-session no ~/.xinitrc
Using Openbox with Xfce4
Log into a normal Xfce4 session. From your terminal of choice, do:
killall xfwm4 ; openbox & exit
This will kill xfwm4, run Openbox, and close the terminal.
Log out, making sure to check the "Save session for future logins" checkbox.
On next login, Xfce4 will use Openbox as its WM.
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"> <action name="Exit"/> </item>
and change it to:
<item label="Exit">
<action name="Execute">
<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.)
Configuration
Preferences
Currently, there are two options for configuring the core Openbox preferences; manually edit the rc.xml, or use the ObConf tool.
Setting Preferences Manually
To configure Openbox manually, simply edit ~/.config/openbox/rc.xml with your favourite text editor.
Setting Preferences with ObConf
ObConf is GUI-based Openbox configuration tool, which can be used to set most preferences including themes, virtual desktops, window properties and desktop margins.
To install ObConf, run:
# pacman -S obconf
Currently, ObConf cannot be used to manage keyboard shortcuts and a few other advanced features. For these modifications, the user must resort to editing the rc.xml manually.
Menu Management
The default Openbox menu is pretty basic and if you don't have any of the listed programs installed, it is downright useless. There are a number of ways to customize your menu.
MenuMaker
MenuMaker is a powerful tool that creates XML-based menus for a variety of Window Managers, including Openbox. MenuMaker will search your computer for executable programs and create an XML menu based on the results. It can be configured to exclude Legacy X, GNOME, KDE, or Xfce applications if the user desires.
MenuMaker is available from the AUR.
Once installed, you can generate a complete menu by running:
$ 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
To see a full list of options, run mmaker --help
This will give you a pretty thorough menu. Now you can modify the menu.xml by hand, or simply regenerate the list whenever you install new software.
Obmenu
Obmenu is a GUI-based menu editor for Openbox. For those who don't enjoy mucking about in XML source code, this is probably the best option for you.
It's available in the standard repositories:
# 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.
Startup Programs
Openbox 3.4+ features support for running programs at startup. This is provided by the "openbox-session" command.
There are two ways to enable autostart:
- If you use startx to log into your X session, change the line that executes openbox to execute openbox-session instead.
- If you log in with GDM/KDM, then select the Openbox session and it will automatically use autostart.
Startup programs are managed in ~/.config/openbox/autostart.sh. Full instructions and best practices for how to do this are available at the Openbox website.
Theming and Appearance
Aside from the Openbox Themes, the following section is intended for users who have configured Openbox to run as a standalone desktop, without the assistance of GNOME or KDE.
Openbox Themes
Openbox themes control the appearance of window borders, including the titlebar and titlebar buttons.
Additional themes are available from the standard repositories:
# pacman -S openbox-themes
This package is by no means definitive. box-look.org is another great resource for Openbox themes.
Downloaded themes should be extracted to ~/.themes and can be installed or selected with the ObConf tool.
Creating new themes is fairly easy and again well-documented.
Desktop Wallpaper
Openbox itself does not include a way to change the wallpaper. This can be done easily with programs like Feh or Nitrogen. Other options include ImageMagick, hsetroot and xsetbg.
GTK Themes
GTK2 themes can be managed easily with gtk-chtheme:
# pacman -S gtk-chtheme
Simply run gtk-chtheme and set the desired theme.
For legacy GTK1 themes, install the gtk-theme-switch package and run switch.
GTK Fonts
If you want to change the type and size of your fonts, add the following to ~/.gtkrc.mine:
style "user-font"
{
font_name = "[font-name] [size]"
}
widget_class "*" style "user-font"
gtk-font-name = "[font-name] [size]"
where [font-name] [size] is the desired font and point size. For example:
style "user-font"
{
font_name = "DejaVu Sans 8"
}
widget_class "*" style "user-font"
gtk-font-name = "DejaVu Sans 8"
Both font_name and gtk-font-name fields are required for backwards compatibility.
GTK Icons
Extract the desired icon theme to /usr/share/icons (system-wide access) or ~/.icons (local user access).
Add the following to ~/.gtkrc.mine:
gtk-icon-theme-name = "[name-of-icon-theme]"
where [name-of-icon-theme] is the name of the icon theme directory. For example:
gtk-icon-theme-name = "Tango"
Mouse cursor themes
Extract the desired Xcursor theme to either /usr/share/icons (system-wide access) or ~/.icons (local user access).
Add this to ~/.Xdefaults:
Xcursor.theme: [name-of-cursor-theme]
where [name-of-cursor-theme] is the name of the cursor theme directory. For example:
Xcursor.theme: Vanilla-DMZ-AA
Desktop Icons
Openbox does not provide a means to display icons on the desktop. ROX, iDesk, or even Nautilus (and the gnome-settings-daemon) can provide this function.
ROX has the additional advantage of being a lightweight file manager.
Tips & Tricks
Recommended Programs
Login Managers
SLiM provides a lightweight and elegant graphical login solution for standalone Openbox configurations. Refer to Arch's SLiM wiki for detailed instructions.
Composite Desktop
Xcompmgr is a lightweight composite manager capable of rendering drop shadows, fading and simple window transparency within Openbox and other window managers.
Application Launchers
dmenu
dmenu is a fast and lightweight dynamic menu for X:
pacman -S dmenu
Setting up dmenu under Openbox is a two-part process. First we create a bash script with our desired dmenu preferences, and then we run that script with a keyboard shortcut.
The following script presents some common defaults:
#!/bin/sh `dmenu_path | dmenu -fn '-*-terminus-*-r-normal-*-*-120-*-*-*-*-iso8859-*' -nb '#000000' -nf '#FFFFFF' -sb '#0066ff'` && eval "exec $exe"
Save the script somewhere (~/bin is a good choice) and make it executable.
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>
Gerenciadores de Arquivos
Existem muitas possibilidades, mas os gerenciadores de arquivos leves mais populares são:
- Thunar (Suporta auto-mount features e outros plugins)
- ROX (ROX também provê desktop ícones)
- PCMan (pcmanfm)
Para opções mais leves, considere Gentoo ou emelFM, ambos são familiar para quem usa 'Midnight Commander' painel de layout, (Estes dois nescessitam GTK 1.2.x)
É óbvio que você também pode usar o Nautilus do Gnome. No entanto é mais pesado que as soluções anteriores, o que tem uma vantagem adicional para VFS suporte ( e.g SSH remoto, FTP e Conexões Samba).
Panels, Trays, and Pagers
There are quite a lot of utilities available that provide a panel (taskbar), system tray, and pager to Openbox. The most common are:
Panels
Trays
Pagers
Faça a sua escolha e adicione ao arquivo de inicialização.
Configurações Pessoais
O Openbox tem configurações pessoais desde o openbox 3.3 Estas configurações podem ser feitas em ~/.config/openbox/rc.xml criando um novo elemento XML dentro chamado <openbox_config> , o qual conterá informações sobre as configurações. Dentro de <appcications> você precisará de <application name""> o que conterá o nome do aplicativo que as suas configurações irão afetar. As maneiras de se determinar uma aplicação são nome, classe e regras, eg.
<application class="Firefox-bin">
A classe e nome também podem ser encontradas rodando
xprop | grep WM_CLASS
Quando você clica no aplicativo que você quer configurar, irá retornar algo como
WM_CLASS(STRING) = "Gecko", "Thunderbird-bin"
The first one is what you put inside name="" and the latter one is for class="", you can use either one, but I prefer the one which doesn't get mixed with anything. After this you need to set the settings you want, available settings are
decor - whether window has borders, titlebar and so on, values yes or no, on or off shade - whether the window is shaded to the titlebar or not (doesn't work with decorations off), values yes, no, on, off and so on position - position of the window when started needs subsection <x>pos</x> - position on pixels reading from top left corner <y>pos</y> - center as value and such work too, you can also leave x or y out if you only want to adjust one value. focus - whether the window gets focused when starting it (not sure about this), values yes no and so on desktop - desktop (workspace) the application starts, value desktop number reading from 0 (if its opened to another desktop, it doesn't get focused) monitor - xinerama head the application starts (useful when you have 2 monitors and want the application to open in another, eg nvidia twinview uses xinerama), values 0 1 screennumber and such layer - layer the application starts on, values Bottom, Normal and Top iconic - whether the application is to be launched iconic, values yes, no, on, off and so on skip_pager - application skips pager, values yes, no, on, off and so on skip_taskbar - same as above, just taskbar, values yes, no, on, off and so on fullscreen - whether app should be started fullscreen, values yes, no, on, off and so on maximized - type of maximization, values Horizontal, Vertical, yes, no, on, off and so on.
Example config showing firefox opening 30 pixels from top centered with horizontal maximization
<applications>
<application class="Firefox-bin">
<position>
<x>center</x>
<y>30</y>
</position>
<maximized>Horizontal</maximized>
</application>
</applications>
Linking the menu to a command
Some people would want to link the Openbox main menu, or any other, to a command. This is useful for creating a menu button in a panel, for example. Although Openbox doesn't supprt this, a very simple script , xdotool, can simulate a keypress by running a command. Xdotool is available on AUR here. To use it, simply add the following code to the <keyboard> section of your rc.xml:
<keybind key="A-C-q">
<action name="ShowMenu">
<menu>root-menu</menu>
</action>
</keybind>
Restart/reconfigure Openbox. You can now magically summon your menu at your cursor position by running the following command:
# xdotool key ctrl+alt+q
Of course, you can change the shortcup to your liking.
Additional Resources
- Openbox Website - The official website
- Planet Openbox - Openbox news portal
- Box-Look.org - A good resource for themes and related artwork
- Application recommendations