个人工具

UbuntuHelp:Fluxbox

来自Ubuntu中文

跳转至: 导航, 搜索


What is Fluxbox?

Fluxbox is a lightweight and responsive window manager for GNU/Linux. It is not nearly as elaborate as GNOME or KDE, but it uses considerably fewer system resources. This makes it uniquely suited for situations where system resources, especially RAM, are very limited. Its menu and configuration is done by simple files located in the user directory under the name ~/.fluxbox. Fluxbox is fast and light window manager for the X Window System based on Blackbox and compatible with it. Fluxbox looks like blackbox and handles styles, colors, window placement and similar things exactly like blackbox. It has support for KDE (see Kubuntu), Xfce and Gnome applications. However, it does not depend on any other window manager. The basic interface has only a taskbar and a menu accessible by right-clicking on the desktop. Fluxbox also supports user created keyboard shortcuts. Fluxbox has a slick tabbing mechanism for windows. You can combine multiple windows into one window with tabs across the top by simply middle-clicking the tab of one window (and holding it down) and dragging and dropping on the tab of another window. This is very nice for cleaning up a desktop without exiting applications to other virtual desktops (it has those too). Another nice feature is Fluxbox's support for docking applications (dockapps). Basically a dockapp runs as sort of an icon with minature display or controls. But not like an icon, more like small controls on a walkman (for example) as opposed to a big dial face of a home stereo. It aims to be lightweight and highly customizable, with only minimal support for graphical icons, and only basic interface style capabilities. In accordance with Fluxbox's goal of simplicity, the main menu, the keyboard shortcuts and the basic configuration are all changed by editing text files. Fluxbox's themes are 100% compatible with those of blackbox. Colors, gradients, borders, and several other basic appearance attributes can be specified; recent versions of Fluxbox support rounded corners and graphical elements. Fluxbox also has several features which blackbox lack, including tabbed windows, a feature familiar from PWM, and configurable titlebar.

Why use Fluxbox?

As mentioned above, Fluxbox runs very happily on very few system resources. As such, it is ideal for use on older hardware. (For this reason, it is the default window-manager of the very aptly-named DamnSmallLinux distribution. Fluxbox's minimalist aesthetic makes for a very efficient working environment; moreover, its window-tabbing feature is an excellent way to minimize clutter and maximize screen real estate. It is easily configurable by editing simple, uncluttered text files. Fluxbox allows users to set their own desktop guidelines, degrees of functionality, and styles. For these reasons, a lot of people use Fluxbox regardless of their system's resources. Fluxbox can be installed to run in an alternative session to other desktop managers (like Gnome/metacity or KDE). You can have many alternative window managers available from the log-on screen.

Installing Fluxbox

(N.B. The following installation instructions assume you are installing Fluxbox on a default Ubuntu installation, which uses GDM. Users wishing to install the absolute minimum should first consult the Installation/LowMemorySystems wikipage for instructions more particularly directed to minimal installations.) To install fluxbox you need to install the fluxbox package from the Universe Repository Restarting the Xsession by logging out, or typing sudo /etc/init.d/gdm restart would bring up GDM, and Fluxbox would then appear on the sessions menu. However, I would NOT restart the Xsession at this point. Why not? For some reason, the Fluxbox packages in Ubuntu's universe repositories create non-standard (at least for Fluxbox) xsession files, which means the ~/.fluxbox/startup configuration file is not automatically generated the first time Fluxbox runs. (!) This appears to have been fixed as of version 0.9.14, but you should check anyway. Before we run Fluxbox, we must correct this oversight. You need to open up /usr/share/xsessions/fluxbox.desktop in the terminal and edit it. When you see the following text:

exec=fluxbox

replace that line with

exec=startfluxbox

Once you have finished editing /usr/share/xsessions/fluxbox.desktop , restart the X server and log into fluxbox. On some machines, Fluxbox seems to load very slowly. This can easily be fixed by adding the following line into your ~/.fluxbox/startup, right before exec fluxbox:

export LC_ALL=C

Using Fluxbox

As you might have gathered by now, Fluxbox does things a little differently from GNOME/KDE/XFCE.

Getting the Menu and Running Programs

Unlike GNOME, KDE, and XFCE, Fluxbox has no "start" button. To get to the menu, simply right-click anywhere on the desktop. Submenus will expand if you simply mouse over them. To run a program, highlight its entry in the menu and click on it.

Workplace Switching

Turning the mousehweel over any unoccupied space on the desktop will page through the available workspaces. This can be a quick way of flipping from one workspace to the next.

Window Tabbing

Window tabbing is a good way of conserving screen real-estate and reducing clutter. It is a behavior unique to Fluxbox, and part of its appeal as a working environment. Middle-click on a window's title bar; keep holding the middle button down and drag onto another window. The two windows will appear to merge into a single window, with two title tabs. You can now view each tab within the newly-joined window by clicking on its respective title bar. This is particularly useful if you are running an application from a terminal. By tabbing the application with its corresponding terminal window, it is easy to flip back and forth from the debug output in the terminal to the application.

Configuration & Customization

The base Fluxbox install is quite bare. You only have a little taskbar/systray/clock combo at the bottom and the very cool right click menu. But how the heck to you start doing stuff? You've heard that Fluxbox is very customizable right? Well, here comes the meat and potatoes of it. You should be very familiar with the terminal because you will be using it a lot to do various things. Also be familiar with your favorite text editor, because all of Fluxbox's fun configuration is controlled by text files in ~/.fluxbox. ("~" is a shortcut for the current user's home directory) Oh and unless I tell you, you won't need sudo for anything because you will be working in your home directory.

Menu Customization

The first file up is ~/.fluxbox/menu. This file controls the right click menu. This may be a hidden file. If you are browsing for it in Nautilus, select "Show Hidden Files" in the View menu to make it visible. Very simple syntax really. Note that if you are installing Fluxbox from a normal Ubuntu/Kubuntu/Xubuntu install (ie, you already have a Window Manager), then all your apps are in the menu already and your menu file will look something like this

[begin] (fluxbox)
[include] (/etc/X11/fluxbox/fluxbox-menu)
[end]

Or at least it SHOULD. The first and last lines define the beginning and end of the menu file, so everything goes between them. That include thing pulls in the file generated in /etc/fluxbox. Its generated by the Debian Menu package (for which you need the menu package) and if thats installed before Fluxbox is, it will automatically be put in the menufile. Case in point, on my laptop I did a barebones install and installed Fluxbox before the menu package and it didn't show up (but is in the same place in /etc) but on my desktop (which has run GNOME, XFCE, and now Flux in the same install) the menu package was around long before Flux was and thus the include is there. No biggie if it isn't, you'll see how to make your own now! So the basic syntax for an executable (normal program entry) is thus

[exec] (Name you want to show up in the menu) {command} <path to icon>

The exec says this is an executable entry. The () is the name you want to show up in the menu. Now command is what you'd type in the terminal to run this. Its also practice to use the absolute path. How do you find this? With the which command

kyral@NebulaPeace:~$ which gaim
/usr/bin/gaim

Works for any command (almost...) If there is an icon to go along with it, then put that in the <>, but its optional. Oh this all goes on one line and ends with a newline (basically hit return) Now what about submenus? Right now any exec entry is going to be in the main menu. Its easy really

[submenu]  (Name of submenu) {}
stuff like execs and other submenus
[end]

Again submenu tells it that you are making a submenu, the name is in (). The {} is just a null command and is included by convention. You can put anything you want in the submenu, just when you are done defining it close it out with the end. Now thats the basics about the Menu. Fluxbox generated all the config stuff for itself when it was installed, so its already there and you don't have to worry about it. Oh yes, you CAN have duplicate menu entries. Here is the menu file from my laptop

[begin] (Fluxbox) {}
   [exec] (Gaim) {/usr/bin/gaim}
   [exec] (Firefox) {/usr/bin/firefox}
   [exec] (Irssi) { x-terminal-emulator -T "irssi-text" -e /usr/bin/irssi-text}
   [exec] (Bash) { x-terminal-emulator -T "Bash" -e /bin/bash --login}
   [exec] (BMP) {/usr/bin/beep-media-player}
   [exec] (VLC) {/usr/bin/vlc}
   [exec] (F-Spot) {/usr/bin/f-spot}
   [exec] (Acrobat Reader) {/usr/bin/acroread}
   [submenu] (Apps) {}
        [submenu] (Editors) {}
            [exec] (Emacs) {/usr/bin/emacs21}
            [exec] (Nano) { x-terminal-emulator -T "Nano" -e /bin/nano}
        [end]
        [submenu] (Net) {}

            [exec] (Telnet) { x-terminal-emulator -T "Telnet" -e /usr/bin/telnet}
            [exec] (w3m) { x-terminal-emulator -T "w3m" -e /usr/bin/w3m /usr/share/doc/w3m/MANUAL.html}
        [end]
        [submenu] (Programming) {}
            [exec] (Python) { x-terminal-emulator -T "Python (v2.4)" -e /usr/bin/python2.4}
        [end]
        [submenu] (Shells) {}

            [exec] (Dash) { x-terminal-emulator -T "Dash" -e /bin/dash -i}
            [exec] (Sh) { x-terminal-emulator -T "Sh" -e /bin/sh --login}
        [end]
        [submenu] (System) {}
            [exec] (gkrellm) { /usr/bin/gkrellm }
            [submenu] (Admin) {}
                [exec] (alsaconf) { x-terminal-emulator -T "alsaconf" -e /usr/sbin/su-to-root -p root -c /usr/sbin/alsaconf}
                [exec] (pppconfig) { x-terminal-emulator -T "pppconfig" -e /usr/sbin/su-to-root -p root -c /usr/sbin/pppconfig}
            [end]
            [exec] (aptitude) { x-terminal-emulator -T "aptitude" -e /usr/bin/aptitude}
            [exec] (DSL/PPPoE configuration tool) { x-terminal-emulator -T "DSL/PPPoE configuration tool" -e /usr/sbin/pppoeconf}
            [exec] (GDM flexiserver) {gdmflexiserver}
            [exec] (GDM flexiserver in Xnest) {gdmflexiserver -n}
            [exec] (GDM Photo Setup) {gdmphotosetup}
            [exec] (GDM Setup) {gksu gdmsetup}
            [exec] (pstree) { x-terminal-emulator -T "pstree" -e /usr/bin/pstree.x11}
            [exec] (reportbug) { x-terminal-emulator -T "reportbug" -e /usr/bin/reportbug --exit-prompt}
            [exec] (Run as different user) {/usr/bin/gksuexec}
            [exec] (Top) { x-terminal-emulator -T "Top" -e /usr/bin/top}
            [exec] (X-Terminal as root) {/usr/bin/gksu -u root /usr/bin/x-terminal-emulator}
        [end]
    [end]
    [submenu] (Help) {}
        [exec] (Info) { x-terminal-emulator -T "Info" -e info}
    [end]
    [submenu] (WindowManagers) {}
        [restart] (FluxBox) {/usr/bin/fluxbox}
    [end]
    [config] (Configuration) {}
    [submenu] (Styles) {}
        [stylesdir] (/usr/share/fluxbox/styles) {}
        [stylesdir] (~/.fluxbox/styles) {}
    [end]
    [workspaces] (Workspaces) {}
    [reconfig] (Reconfigure) {}
    [restart] (Restart) {}
    [exit] (Exit) {}
[end]

And the one from my Desktop

[begin] (fluxbox)
        [exec] (Evolution) {/usr/bin/evolution}
        [exec] (GAIM) {/usr/bin/gaim}
        [exec] (Bash) { x-terminal-emulator -T "Bash" -e /bin/bash --login}
        [exec] (Epiphany) {/usr/bin/epiphany}
        [exec] (BMP) {/usr/bin/beep-media-player}
        [exec] (Xine) {/usr/bin/xine}
[include] (/etc/X11/fluxbox/fluxbox-menu)
[end]

You can see the difference. My Desktop had the Debian Menus before I installed Fluxbox, hence the include came into play For further examples of what you can do with a Fluxbox menu, see this page in the Fluxbox documentation.

Traditional Menu Generation

If you would prefer to create a menu using the traditional method for more of a standard look, then you should follow the basic process that is outlined below. Fist extract the needed file and copy it to /usr/bin.

 # cd /usr/share/doc/fluxbox
 # gzip -d fluxbox-generate_menu.gz
 # cp fluxbox-generate_menu /usr/bin

Now, make the file executable:

 # chmod a+x /usr/bin/fluxbox-generate_menu

Next, it's time to generate the menu. Issue the command below as a user.

 $ cd /home/username
 $ fluxbox-generate_menu

This will also create a ~/.fluxbox/menuconfig file that can be customized to your preferences. You can, for example, add GNOME or kde support to the menu, or change the default browser, terminal, etc. Finally, you need to edit the init file & change the menuFile path. Change the 'session.menuFile' entry to reflect the desired user name by editing the /home/username//.fluxbox/init

session.menuFile:    /home/username/.fluxbox/menu

Log back in and enjoy your new menu.

Keyboard Shortcuts

Keyboard shortcuts are awesome to say the least. Why reach for the mouse when you can just hit a key combo and be done? The keyboard shortcut definitions are all stored in ~/.fluxbox/keys Fluxbox comes with a few shortcuts preset, namely the familier Alt-TAB and mapping Alt+F1 through F12 to the 12 workspaces (If you have all of them enabled. By default Flux has 4 active). But we want to make our own don't we? Yup! Easy enough. Follow the syntax (again 1 per line)

<key combo> :ACTION

Now some things need explaining. One the key names. Alt is referred to as Mod1, CTRL as Control, and the Windows key is Mod4. Most of the other keys are what you expect. However if you want to be sure, there is a tool called xev . Call it on the command line and start hitting keys. A LOT of gibberish will come up, like this

KeyPress event, serial 30, synthetic NO, window 0x1800001,
    root 0x3e, subw 0x0, time 3967824504, (728,435), root:(799,525),
    state 0x0, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False

Now most of that is gibberish that we don't need. What we want is the part in keycode <something> (keysym <something>, Shift_L) That last part (Shift_L) is what X sees the key as, thus its name. So use it (note the rules above about naming overrule this, so Alt is still Mod1, etc) So now we have the key names. The format for the key combo is simple. Just put down the combo! So Alt+F1 would be Mod1 F1 . Easy! Now the part after : is what the combo does. There are many options, but I am going to go through the ones I think will be most useful.

Action Description
Close Closes out the current window
Minimize Minimizes the current window
MaximizeWindow Maximizes the window
ShowDesktop Minimize all windows
Restart Restart Fluxbox
Quit Quit Fluxbox and return to the login screen
ExecCommand Run the specified command. Either give the command or the absolute path to the program (think what you did for the menu file)

Again we have an example file from my desktop

Mod1 Tab :NextWindow
Mod1 Shift Tab :PrevWindow
Mod1 F1 :Workspace 1
Mod1 F2 :ExecCommand fbrun ;not the default for fluxbox, but this behaves like KDE/Gnome
Mod1 F3 :Workspace 3
Mod1 F4 :Workspace 4
Mod1 F5 :Workspace 5
Mod1 F6 :Workspace 6
Mod1 F7 :Workspace 7
Mod1 F8 :Workspace 8
Mod1 F9 :Workspace 9
Mod1 F10 :Workspace 10
Mod1 F11 :Workspace 11
Mod1 F12 :Workspace 12
Mod4 F1 :ExecCommand /usr/bin/evolution
Mod4 F5 :ExecCommand x-terminal-emulator -T "Bash" -e /bin/bash --login
Mod4 F2 :ExecCommand /usr/bin/epiphany
Mod4 F3 :ExecCommand /usr/bin/xine
Mod4 F4 :ExecCommand /usr/bin/best --no-tray

Setting the Background

Now playing around with menus and keybinds is all well and good, but you want to set a background right? Easy!

fbsetbg -f /path/to/image_file

Tip: "fbsetbg -l" sets the last used wallpaper as the desktop and could be added to ~.fluxbox/init as: session.screen0.rootCommand: fbsetbg -l Note: fbsetbg is just a wrapper for other things that set wallpapers, such as Esetroot and feh. If you have one of those installed fbsetbg will determine the best one to use and use it. To find out what fbsetbg is using run fbsetbg -i Feh can be found in the feh package. Esetroot comes with ETerm, which can be found in the eterm package.

Styles

You can set the background just fine, but what about the theme. Well there is good news and bad news. The good news is that Fluxbox ships with a lot of themes (called Styles) by default. The bad news is that they only affect the windows themselves, not the "interior". That means if you are running GTK apps, then they will use the default grayish theme. Now thats good on its own, but it can really mess up a colorscheme. You can change it though, but first how to install and use Styles themselves. Changing Styles is quite easy. Just to go the Styles submenu and click on it. Be warned though, some styles will override your background with their own, so you will have to change it back. Now what if you want to install a new style? Well first you have to know where to FIND them. Here are some websites to get themes from:

Tenner's site is the site for fluxbox styles. You will find of 500 styles there available for individual download --or-- you can download his nightly build tarball containing ALL styles. This site also provides tutorials and specifications for fluxbox theme design. Once you find one you like, download the tarball to ~/.fluxbox and extract it. One of two things will happen. It will be a good tarball and just put its files into ~/.fluxbox/styles, or it will put them someplace else in ~/.fluxbox. If the former occurs, then you are all set, the theme is in the Styles menu now. In the case of the latter you will have to find its style directory and move the file in it to ~/.fluxbox/styles. Fortunately 99% of the time it will make its own directory and the style dir will be in that (this is why we extracted in ~/.fluxbox, there aren't many dirs in there to begin with so its obvious when a new one is made). Now thats all well and good, but I mentioned being able to apply GTK Themes. Yes you can. Install GTK Theme Switch with gtk-theme-switch and run it with switch2 . A little dialog will pop up with a dropdown of all the GTK Themes installed. Just select and apply. Keep in mind that the Style will still be in control of the Window Decorations (Titlebar, window borders, etc), so if the GTK Theme normally sets those, it won't, but the rest of it will work. A good source of GTK Themes is GNOME-Look. Stay away from the Metacity themes though. Those flat out won't work. Also if you need to install a new GTK theme, just download the tarball to ~/.themes and extract it. Suppose you want to ensure that the background you set last stays there even after you reboot, just go find the *.cfg file for your theme. Look around for a line that goes like this; rootCommand: ## Simply edit that line to read as follows; rootCommand: fbsetbg -l or you can plainly edit the ~/.fluxbox/init file and place the following line there; session.screen0.rootCommand: fbsetbg -l

The ~/.fluxbox/startup File

You've heard of ~/.fluxbox/startup, now learn how to use the thing. Like all good scripts, this one is nicely commented out with quick instructions.

Setting the Background

To set the background (overriding the style!) uncomment the fbsetbg line and place the location of the image as the argument to fbsetbg. Then comment out the part about setting a black background.

Loading Programs when Fluxbox Starts

Near the bottom of ~/.fluxbox/startup you will find a section that reads:

# Applications you want to run with fluxbox.
# MAKE SURE THAT APPS THAT KEEP RUNNING HAVE AN ''&'' AT THE END.

Here put all the programs you want to load with Fluxbox. Some things to consider. XScreensaver (which controls the screensaver and screen locking) is not loaded Fluxbox by default, so you might want to add it to the startup script with xscreensaver & . The trailing ampersand (&) tells it to run in the background , like it should). This goes the same for other programs like the Beagle daemon, beagled & . For other programs, like GAIM, GKrellm (which is a REALLY good complement to Fluxbox), and anything else you want starting just put the command.

Dockapps and The Slit

Dockapps are small "dockable" applications which reside in a small "Dock" (which, in Fluxbox's terminology, is called "the slit") on one corner of your screen. They can be informative (clocks, calendars, system info), functional (volume controls, drive mounting utilities), convenient (controls for other applications), or even merely entertaining (minigames, fortune cookie displays, etc.). The vast majority of dockapps seem to have been originally developed for the WindowMaker and AfterStep window-managers, but work fine within Fluxbox. A good selection of them is available in the Ubuntu repositories (if you want to have a look, execute sudo apt-cache search dockapp in a terminal window), and many more can be found and compiled should you wish to do so. You can load your dockapps when Fluxbox starts up by including them in ~/.fluxbox/startup the same way you start any other program in the startup file: simply type the command, followed by a trailing ampersand (&). Some popular dockapps can be found in the Universe repositories and can be installed using apt-get or Synaptic:

wmxmms: used to control XMMS (play, pause, next, previous, volume, position)
wmcpuload: displays the CPU load in percentage
wmmemload: displays how much memory is used 
wmweather, wmweather+: displays the weather
wmclockmon: displays the date and time
docker: displays gnome-applets (like nm-applet and gnome-power-manager) without gnome panel
wmmount: mount/unmount/open volumes such as cdrom drives and harddisks
wmmatrix: shows the matrix screensaver just for fun
wmtop: shows the current running processes that use most resources at the moment

Gnome Support

Many people like to use Nautilus, Gnome themes, or even the Gnome panel in Fluxbox. In order for this to function smoothly, the following must be added to your startup script:

GSDPID=`pidof gnome-settings-daemon`
if [  "x$GSDPID" == "x" ]; then
gnome-settings-daemon &
fi

Starting Fluxbox

Right at the bottom is the command to start Fluxbox. Notice that here we are running /usr/bin/fluxbox WITHOUT a trailing ampersand (&).

Further Resources

  • Main Fluxbox site
  • The Fluxbox project's own Documentation pages are an invaluable resource. Printable documentation is available there for offline reading in PDF format. Translations are also available in many languages.
  • The Gentoo Wiki contains an excellent Fluxbox Howto, to which this document is also greatly indebted.
  • The Debian Wiki contains a lot of material very centric to this page.

For those who need Fluxbox for extremely lightweight installations, the following resources will be particularly useful:

  • The Installation/LowMemorySystems wikipage should be your first port of call. A (very) minimalistic fluxbox installation is described there.
  • This site has detailed instructions for a lightweight Fluxbox installation using XDM as a display manager.

( To do: xcompmgr and transparency howto )