Showing posts with label metacity. Show all posts
Showing posts with label metacity. Show all posts

Friday, January 20, 2006

Brown paper Fluxboxes tied up with string

Fluxbox is a window manager for X. Its chief advantage over Metacity—the window manager with which you'll be familiar if you use GNOME—is its streamlined design; it runs much faster. For this reason, distros like DSL use it as their default window manager. It can also be customized by editing a few text files. Users often set up impressive Fluxbox themes (see below). Unfortunately it didn't "just work" on my Debian system.

Several FAQs on setting up Fluxbox mention an executable called fluxbox-generate_menu. When run, it's supposed to take an inventory of your applications and generate corresponding items in the Fluxbox menu, which initially lists nothing but a launcher for xterm and the options to restart Fluxbox or logout. It isn't the best tool; it tends to clutter your menu with items you never actually use and omit ones you do. But I consider it more efficient to run it and then adjust the menu accordingly, rather than track down every application and add them to ~/.fluxbox/menu. There was one problem: installing the fluxbox package didn't seem to install fluxbox-generate_menu as promised. I had to search for a while before I found the solution.

It's kind of dopey. Apparently there's a bug in the package, and consequently the archive containing fluxbox-generate_menu doesn't get decompressed and copied to /usr/bin during the installation. So we have to do it manually. It's not tough.

# cd /usr/share/doc/fluxbox
# gunzip fluxbox-generate_menu.gz
# cp fluxbox-generate_menu /usr/bin
# chmod a+x /usr/bin/fluxbox-generate_menu


Let's go line by line. The cd command changes your working directory. Then the gunzip command decompresses or "unzips" the archive. You could alternately use gzip -d here. We use the cp command to copy the executable to the appropriate directory. The chmod a+x command gives all users permission to run it; otherwise only the root user could. It can be used with other options for different effects.

These commands should all be run as the root user. You can become root by entering sudo su at the command line or by logging in with user name "root" and the root password (not your user password, which may be different).

I'm still having a problem with fluxbox-generate_menu, but that's a discussion for another day.

Thursday, August 11, 2005

amixer is afriend

For whatever reason, I have to adjust the PCM track in order to change volume in GNOME; the Master track does nothing. I suspect it's something specific to my sound card. It isn't especially inconvenient as long as I want to use the volume control built into the GNOME panel. I just right-clicked on the speaker icon, selected Preferences and told it to control the PCM track. Unfortunately adjusting the volume using multimedia keys has proven more difficult.

GNOME 2 provides a utility to bind an action to a key or keys. It can be accessed from the terminal with the command gnome-keybinding-properties or from the GNOME Desktop (System -> Preferences -> Keyboard Shortcuts). However, if you want to perform an unlisted action, you'll have to use the Configuration Editor. In my case, I wanted to adjust the PCM track volume.

The GNOME Configuration Editor can run from the terminal with the command gconf-editor or from the GNOME Desktop (Applications -> System Tools -> Configuration Editor). I used it to set key bindings for Metacity.

Using Xev and Editing Xmodmap

Before I could begin I needed to know if the keys to which I wanted to bind actions already had keysyms—symbolic names for keys on the keyboard—assigned to them. I opened the terminal and entered xev.

Xev prints the contents of X events. According to its manual, "Xev creates a window and then asks the X server to send it events whenever anything happens to the window…" This includes typing. So pressing a multimedia key should return something like this.

KeyPress event, serial 29, synthetic NO, window 0x3000001,
root 0x8e, subw 0x0, time 412303, (-458,206), root:(527,303),
state 0x10, keycode 160 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False


We're interested in the third line. "NoSymbol" indicates that there isn't a keysym assigned to keycode 160. Therefore I had to add them to my X keyboard map. First I exported the existing map to a file in my home directory (/home/josh on my system).

xmodmap -pke > xmodmap.conf

I added the missing keysyms for the corresponding keycodes. There's a specific set of names you must use, listed in /usr/lib/X11/XKeysymDB. I saved and closed the file. Then I applied the changes.

xmodmap xmodmap.conf

At this point, you could actually read ahead and bind actions to the keysyms to see if they work. Of course, the new keyboard map isn't just for this session. We want to load it when X starts. Following the advice of Corey Burger, I added it to the PostLogin script of gdm.

sudo cp xmodmap.conf /etc/xmodmap.conf
cd /etc/X11/gdm/PostLogin
sudo cp Default.sample Default
sudo gedit Default


We need to add the line xmodmap /etc/xmodmap.conf to the end of the file. Now we're ready to use the Configuration Editor.

GNOME Configuration Editor

Run the Configuration Editor and navigate to /apps/metacity/global_keybindings. There should be 12 keys with "run_command" in their names. Right-click on any of them and select "Edit Key…" from the popup menu. Enter the keysym of the desired multimedia key in the "Value" field. Repeat these steps for each multimedia key you want to use. Next we'll tell Metacity which command to run when these keys are pressed.



The ALSA mixer can be controlled from the command line with amixer. To mute/unmute the PCM track, you would enter amixer -q sset PCM,0 toggle. To lower or raise the PCM track volume by 10 percent, you would enter amixer -q sset PCM,0 10%-,10%- unmute or amixer -q sset PCM,0 10%+,10%+ unmute respectively. These commands become the values for the appropriate keys. The changes take effect immediately, so you can verify that the commands work as expected before you close the Configuration Editor. If you used the values I did, you should now be able to control the PCM track volume from your keyboard.