GNU/Linux / Desktop

From WhyNotWiki
< GNU/Linux
Revision as of 21:46, 15 April 2008 by Tyler (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

GNU/Linux / Desktop  edit   (Category  edit)

Aliases: GNU/Linux / Desktop environment, GNU/Linux / X Windowing System, GNU/Linux / Graphical environment,

This information will be about Ubuntu and GNOME unless specified otherwise.


GNU/Linux / Desktop / Keyboard shortcuts

GNU/Linux / Desktop / Keyboard shortcuts edit Retrieved on 2007-05-11 11:18.

One of the reasons that I prefer using Vim to a word processor or GUI application is that my hands rarely need to leave the keyboard. I can do all my copying and pasting using Vim keybindings. When it comes to my window manager, I try to do the same thing -- work with tools that let me use the keyboard to navigate as much as possible without having to use the mouse. [...] ...

Context Function Default My preference Easiest way to change
Global Opens a Run Application window... Alt+F2 F1 GNOME Keyboard Shortcuts app
Global Show the panel menu ("start menu") Alt+F1 (in Windows this was Ctrl+Esc or Windows key) Alt+F1 GNOME Keyboard Shortcuts app
Global Open a terminal window (disabled) SuperR GNOME Keyboard Shortcuts app
Global Home folder (opens Nautilus to ~) (disabled) The "Files" button on my Logitech keyboard (0xc6) GNOME Keyboard Shortcuts app
Global Switch to workspace on the left Ctrl+Alt+Left GNOME Keyboard Shortcuts app
Many apps, including Firefox, gnome-terminal Toggle full-screen mode (disabled) Alt+Enter GNOME Keyboard Shortcuts app
Global Minimize all windows and focus the desktop Ctrl+Alt+D Super+D gconf-editor: /apps/metacity/global_keybindings/show_desktop = <Super>d
gnome-terminal Paste from primary clipboard Ctrl+Shift+V (Ctrl+V is simply sent on to the terminal) Ctrl+Shift+V gnome-terminal: menu: Edit -> Keyboard Shortcuts
Global Paste from selection clipboard - Ctrl+Shift+V (See section on this page)
Most apps Copy to primary clipboard Ctrl+C LeftSuper (See section on this page)
Most apps Paste from primary clipboard Ctrl+V CapsLock (See section on this page)

Template loop detected: Template:Include section

How I mapped Ctrl+Shift+V to be middle button (paste from selection clipboard)

Attempt 1: simulating a middle button click using xmacroplay Retrieved on 2007-05-11 11:18.


I like to use a keyboard shortcut (for example, Ctrl+Shift+V) instead of middle_mouse_button in X to paste the selected text. How to bind it? In the terminal window like rxvt i can use Shift+Insert, but it doesn't work in Mozilla address bar. Ctrl+V inserts the text from clipboard but how to place the text selected in rxvt into clipboard?

Dances With Crows,

xbindkeys -k
(press Ctrl-Shift-V, the following is displayed in your konsole
  m:0x5 + c:55
  Control+Shift + v, in your ~/.xbindkeysrc , add the lines

"echo -e 'ButtonPress 2\nButtonRelease 2' | xmacroplay :0 &"
  m:0x5 + c:55

....and the command that starts with 'echo' above will be executed whenever you press Ctrl-Shift-V. This simulates a button 2 event, which is what I think you want here.

This is what I ended up putting in my ~/.xbindkeysrc:

"echo -e 'ButtonPress 2\nButtonRelease 2' | xmacroplay :0 &"
    control+shift + v

Problem: This behaves erratically

I had selected this text in some other window:

Line 1
Line 2

When I pressed Ctrl+Shift+V to paste it, though, this is what was output (notice the extra > characters and the extra newline):

> Line 1
> Line 2

What's even more strange is that sometimes it won't even paste the text at the insertion point/cursor; instead it will move some seemingly random number of lines/characters up or down (usually about 5 lines) and paste there! Weird!

But when I simply use Middle click (which is precisely what this keyboard shortcut should be perfectly emulating) it behaves normally, sanely, intuitively, as-expected-ly.

What's making the difference??

I'm guessing part of it (the part where it moves to a "random" place on the page before pasting) might be simply that the ButtonPress event happens when the mouse is positioned in the "wrong spot". (And I certainly don't know how to generate a MotionNotify event that moves it to just the right place.) Still, how does that explain the mysterious insertion of ">" characters??

Attempt 1.5

"echo -n 'String '`xclip -o` | xmacroplay :0 &"
    control+shift + v

Attempt 2: using xclip to read the clipboard and xmacroplay to replay those characters using the keyboard only (no mouse simulation)


# Paste from "selection clipboard"
    control+shift + v

# Some applications already have Ctrl+Shift+V mapped as a shortcut for something else, so we're not able to use that for pasting from selection buffer without
# conflicting with that shortcut. That is why I have defined an alternate shortcut (Super+V) to access the same command. Apps that already use Ctrl+Shift+V:
# * gnome-terminal maps it to "paste from primary [the other kind of] clipboard"
# * thunderbird maps it to "paste from primary clipboard as quotation"
    Mod2+Mod4 + v

The scripts used were this:


echo -n 'String '
xclip -o


sleep 0.2
~/public/x_windows/bin/simulate_typing_contents_of_middle_click_buffer_2 | xmacroplay :0

At first, while I was testing, I actually had this command mapped to Super+A and I got a wide variety of different results, one of them correct but most of them not. Here are all the different outputs I got after selecting the text abc and then pressing Super+A:


Now that I've thought about it, though, this seems reasonable. Here's my best guess at an explanation: When I press Super+a, it invokes my script, which simulates the pressing of the keys a,b, and c, pressed in fairly rapid succession, but with, I believe, some delay between each one. The only problem with this is, if I'm still holding down the Super key at the instant that it simulates an 'a' keypress, the resulting key combination will actually be Super+a again, which explains why some of the time I got repeated characters (and since the two processes were running independently at the same time, I can see how letters could get out of order, like 'abacbc' instead of simply 'abcabc' (which is what you'd get if you output 'abc' followed by 'abc' sequentially rather than simultaneously)).

Now to explain why some of the time letters were missing: if I was still holding down Super by the time it got to a letter other than a, such as b, then it will actually be pressing Super+B. And since there is no keyboard shortcut assigned to Super+B, the normal behavior of that is to output nothing at all.

So it only output the expected 'abc' if I released Super at the exact right time (as immediately after pressing Super+A as possible). Once I figured that out, I was able to consciously do that and able to get the desired behavior with some consistency. Still, that was very much less than ideal.

So that was just a side-effect of using a modifier key. If I map it to a "normal" key, like F1, that shouldn't happen.

What about if I map it to Ctrl+Shift+v like I said I was going to do?

Well, that suffers from the same problem that Super+a did: if I don't release Ctrl and Shift immediately, it will inadvertently cause Ctrl+Shift+(some arbitrary character) to be pressed instead of simply (some arbitrary character). Since Ctrl+Shift+(some arbitrary character) could very easily be mapped to some command in whatever program we're using (in gnome-terminal, for example Ctrl+Shift+T opens a new tab), this is a dangerous mapping / keyboard shortcut to use.

But, it's also the most intuitive to me, so I want to use it.

What workaround could we use?

How about putting in a delay, to give the user time to release any modifier keys (like Ctrl, Shift, or Super)?

sleep 0.2 seems to do the trick for me.


sleep 0.2
~/public/x_windows/bin/simulate_typing_contents_of_middle_click_buffer_2 | xmacroplay :0

The next problem was that it didn't work for text longer than 1024 characters or with multiple lines. Those need to be broken up into chunks.

Here is my final version:


sleep 0.2
~/public/x_windows/bin/simulate_typing_contents_of_middle_click_buffer_2 | xmacroplay :0


#!/usr/bin/env ruby

max_per_line = 10

contents = `xclip -o`
contents.each_line do |line|
  while (chunk = line.slice!(0..max_per_line)) != '' do
    puts "String #{chunk}"
  puts "KeyStrPress Return"
  puts "KeyStrRelease Return"

This is working great for me.

My only complaint is that it is kind of slow at typing everything out, since there is a delay between each keypress. It's not like middle-clicking, which pastes everything instantly. It's a slower process, that replays the keystrokes very quickly -- faster than I can type -- but slow enough that you can see the words and lines being "typed" out. On the plus side, it's kind of fun to watch your computer "type" things for you...

Ahah! It turns out you can configure that delay. Just use something like this: xmacroplay -d 3 :0.

How I mapped the left Super key to be Ctrl+C and CapsLock key to be Ctrl+V

Optionally, download these:

Then set up your .xbindkeysrc like so:


# Super_L -> Ctrl+C
"sleep 0.2; echo -e 'KeyStrPress Control_L\nKeyStrPress c\nKeyStrRelease c\nKeyStrRelease Control_L' | xmacroplay -d 0 :0 &"

# Shift+Super_L -> Ctrl+X
"sleep 0.1; echo -e 'KeyStrPress Control_L\nKeyStrPress x\nKeyStrRelease x\nKeyStrRelease Control_L' | xmacroplay -d 0 :0 &"
    Shift + Super_L

# Caps_Lock -> Ctrl+V
"sleep 0.1; echo -e 'KeyStrPress Control_L\nKeyStrPress v\nKeyStrRelease v\nKeyStrRelease Control_L' | xmacroplay -d 0 :0 &"

I again had the problem of things not working right unless I added a delay. Apparently the playback by xmacroplay gets messed up if Super_L and Caps_Lock are still being held down at the time it begins the playback. Any way to work around that??

Having Shift+Super_L behave differently from Super_L is difficult (impossible?)

So it seems that there is no short-circuiting of bindings when it comes to bindings via xbindkeys: in other words, if there's a binding for A and a binding for Super+A, then if you press Super+A, it will execute both of those bindings, not just the "most specific" of the two.

How should it behave? Should it only execute the first matching combination in order, the combination with the most matching components/modifiers/keys, all matching bindings, ... what??

If it executes all of them, then there should be a way to say "only execute this if Super is not being held down right now".

Does it behave any differently if I use metacity's global_keybindings feature?

No, it didn't seem to. Here's what I had:

  • global_keybindings
    • run_command_1 = Super_L
    • run_command_2 = <Shift>Super_L
  • keybinding_commands
    • command_1 = /home/tyler/public/x_windows/bin/simulate_ctrl_c
    • command_2 = /home/tyler/public/x_windows/bin/simulate_ctrl_x

Workaround 1: "Overlap" bindings; make sure they're "safe" to use together; use delays so that the last one "wins out"

Yuck. Yeah, it's yucky, but this is how I'm currently doing it... Can someone suggest a better way??

  1. Super_L -> Ctrl+C

"sleep 0.1; echo -e 'KeyStrPress Control_L\nKeyStrPress c\nKeyStrRelease c\nKeyStrRelease Control_L' | xmacroplay -d 0 :0 &"

  1. Shift+Super_L -> Ctrl+X

"sleep 0.1; echo -e 'KeyStrPress Control_L\nKeyStrPress x\nKeyStrRelease x\nKeyStrRelease Control_L' | xmacroplay -d 0 :0 &"

   Shift + Super_L

The Super_L command gets executed even when I press Shift+Super_L. But that's not a problem: it's okay to press Ctrl+C before pressing Ctrl+X because a Ctrl+X is essentially a Ctrl+C followed by a Delete anyway...

With this setup, however, Shift+Super only works if you press it and then let go really quickly -- otherwise, it will only do the Ctrl+C (actually, it doesn't appear to even do that successfully -- must be the Shift key being held down interfering again with the xmacroplay playback).

I found that I can make }the tolerance for holding it down longer} greater simply be adjusting the sleep for the Shift+Super_L to a higher delay -- something like 1 second, for instance. But that makes it less usable, so I settled for just keeping them the same and just resigning myself to always being really quick whenever I press Shift+Super_L.

Conclusion: AutoHotKey was better for this

It worked a lot more reliably, and didn't suffer from these problems. Unfortunately, AutoHotKey is only for Windows.

How to prevent the original key from passing through

For example, if you want to map Ctrl+Shift+Q to be some command of your choosing but gnome-terminal already has that mapped to Quit, then how do you make it so Ctrl+Shift+Q will only run your new command and will not quit the terminal when it has the focus?

It seems like you'd need some way to not only intercept the keystroke event before any other applications receive it but also a way to remove it from the event queue, to block/prevent it from being sent to other apps.

How to remap keys / Change keyboard shortcuts

Master Your Linux Keyboard (And Fix Caps Lock Forever): XBindKeys For Launching Applications ( Retrieved on 2007-05-11 11:18.

KDE and GNOME, window managers like IceWM and Fluxbox, and many applications come with their own set of prefab keybindings. You should investigate these before going on a customization spree, or you run the risk of creating conflicts. We're going to learn how to use XBindKeys. XBindKeys is not dependent on any particular desktop or window manager, and should run on pretty much any Linux or Unix system." Retrieved on 2007-05-11 11:18.

I live and die by xbindkeys and xautomation. They allow me to easily map and remap the 9 extra buttons on my mouse, something that I couldn't figure out how to do in Windows. I'm almost always using my laptop while in bed, so I like to be able to do everything with one hand. I even have profiles saved and automatically change depending on the situation, so click-wheel left and right scroll through tabs in Firefox and Konqueror, change the page in KPDF and skip -/+ 10 seconds in VLC. Very useful stuff.

How to remap keys with xmodmap Retrieved on 2007-05-11 11:18.

Unlike Windows, all the infrastructure to remap the keyboard is already embedded in the X11 server. The program to modify key and button mapping in X11 is called “xmodmap”, and comes pre-installed.




First, you need to map the keys to X keysyms. There are in-depth instructions on the linux-thinkpad mailing list, but all you need to do is add these two lines to ~/.Xmodmap:

keycode 234 = F19
keycode 233 = F20


Fire up your favorite text editor and open the content/browser/browser.xul file.


<key id="goBackKb"  keycode="VK_F19"
<key id="goForwardKb"  keycode="VK_F20"
     command="Browser:Forward"/> Retrieved on 2007-05-11 11:18.

To get the windows key to be interpreted as one key, do this: Make a task that starts with the session (I don't know how you do this in GNOME) by creating a new link to application in your ~/.kde/Autostart directory. Make it so that it runs the following command: xmodmap ~/.xmodmap Now we need to create a plain text file in your home folder called .xmodmap and make sure it says the following in it:

keycode 115 = F13 keycode 116 = F14

The second line is only needed if your keyboard has two windows keys. Essentially, this maps these keys to the two imaginary keys F13 and F14, so you don't need to worry about the Win + something problem anymore. 115 and 116 are the keycodes that I've seen most, if not all, keyboards give for the winkeys. Check by running xev if it is the same for you. I got this from somewhere else long ago, so don't give the credit to me for it.

I don't think that's actually necessary (any more?). Using Ubuntu's "Keyboard Shortcuts" app, I was able to map "Super R" (the right Linux key) to a desired command, without doing all that stuff e mentioned. Retrieved on 2007-05-11 11:18.

... The secret's in the built-in Configuration Editor, a Windows registry-like application where you can edit global key bindings and add custom ones to particular scripts and executables. ...

I've found that attempting certain key combinations won't work well through the Configuration Editor. It seems to do odd things with the Win Key (Super or Mod4 for me). Plus, you're somewhat limited in the number of commands you can have. I've been using xbindkeys (and xbindkeys-config) and while the the version in the Ubuntu repository is old, and the interface is ugly, it works quite simply.

How to make a keyboard shortcut for an arbitrary command


gconf-editor Retrieved on 2007-05-11 11:18.

It took a bit of digging to figure how to add keyboard shortcuts to run arbitrary commands. Here are the steps in case someone else needs them:

  • start the GConf Editor: Applications / System Tools / Configuration Editor
  • go to /apps/metacity/keybinding_commands
  • edit command_1, set it to some command, like kdocker -f
  • go to /apps/metacity/global_keybindings
  • edit run_command_1, set it to a key combination, like <Super>z or <Shift>F1

You can accomplish that with xbindkeys also. I prefer that way, because you can keep the same shortcuts between desktop environments/window managers. You just have to be sure that xbindkeys is running on startup.

$ echo 'String echo hello world' | xmacroplay :0 >/dev/null 2>/dev/null; echo
echo hello world
$ echo hello world


I've found you can get yourself in trouble if you leave an old instance of xbindkeys running and then try to start another one.

This should be the first thing you check if, for instance, you find that you're unable to remove a particular mapping. If you've removed it from ~/.xbindkeysrc and then started xbindkeys but it still seems to be mapped, then you may have an old instance of xbindkeys still running.

This is the command line I use to restart xbindkeys:

pkill xbindkeys; xbindkeys; ps ux|grep xbindkeys

(or kill `pidof kbindkeys`; xbindkeys)

Somebody please let me know if there is a better way.

How to make a keyboard shortcut invoke another keyboard shortcut (key combination) Retrieved on 2007-05-11 11:18.

This is my .xbindkeysrc:

# Backward and Forward buttons
# "xvkbd -text "\A\[Left]"" # freezes firefox and makes mouse cursor jump
"echo -e 'KeyStrPress Alt_L\nKeyStrPress Left\nKeyStrRelease Left\nKeyStrRelease Alt_L' | xmacroplay :0 &" #better
  m:0x10 + b:8"
#"xvkbd -text "\A\[Right]""
"echo -e 'KeyStrPress Alt_L\nKeyStrPress Right\nKeyStrRelease Right\nKeyStrRelease Alt_L' | xmacroplay :0 &"
  m:0x10 + b:9

See more at #xmacroplay


Have used: Yes
Rating: star_full.gif star_full.gif star_empty.gif

Download from:

Readiness: Seems pretty stable for the most part; even though the latest release was "pre0.3 Notes (2001-06-12 04:31)"

In Windows, the API provides the SendKeys function, which many scripting/automation/macro techniques take advantage. Would would the equivalent be in GNU/Linux/X?

Looks like it would be xmacroplay! Retrieved on 2007-05-11 11:18.

It sends events to the whole server, not a specific app, so you'd need to do something to force focus. Possible wmctrl or something like it could help. Retrieved on 2007-05-11 11:18.

$ sudo apt-get install xmacro
$ xmacrorec2 > my.macro
{Press [Scroll Lock] key. Type your keystrokes and do your optional
mouse events that you want to record. Press [Scroll Lock] key again to
stop the recording.}
$ vi my.macro
{Edit this file and remove out any lines that you don't want or need.}
$ cat my.macro | xmacroplay ":0.0"

Question: What's the difference between xmacrorec and xmacrorec2?

Do you mean other than the surface difference that xmacrorec requires you to specify remote_display and xmacrorec2 doesn't?

$ xmacrorec -h
xmacrorec 0.3
Usage: xmacrorec [options] remote_display
  -d  DELAY   delay in milliseconds for events sent to remote display.
              Default: 10ms.
  -s  FACTOR  scalefactor for coordinates. Default: 1.0.
  -k  KEYCODE the keycode for the key used for quitting.
  -v          show version. 
  -h          this help. 

$ xmacrorec2 -h
xmacrorec2 0.3
Usage: xmacrorec2 [options] 
  -s  FACTOR  scalefactor for coordinates. Default: 1.0.
  -k  KEYCODE the keycode for the key used for quitting.
  -v          show version. 
  -h          this help. 

I'm not sure!!

Troubleshooting: "Unknown tag: _" with xmacroplay

I get this almost every time I use xmacroplay from the command line (I don't "get it" when I have it mapped to a shortcut key with xbindkeys because I don't see any output then...).

Even with input generated by its sister command xmacrorec (which surely, it could be argued, ought not to generate as output anything that is not valid input to xmacroplay!)...

Even with the simplest examples...

 echo -e 'KeyStr a' | xmacroplay :0
XTest for server ":0.0" is version 2.2.

KeyStr: a
Unknown tag: a
axmacroplay: pointer and keyboard released. 

It gives that warning, as if something were the matter -- yet it still seems to function properly... gives abysmally few results.

The only search result that seemed relevant (but very relevant it does seem!) was this one:

diff -urN xmacro-pre0.3-20000911.orig/xmacroplay.cpp xmacro-pre0.3-20000911/xmacroplay.cpp
--- xmacro-pre0.3-20000911.orig/xmacroplay.cpp  2000-09-11 20:25:11.000000000 +0200
+++ xmacro-pre0.3-20000911/xmacroplay.cpp       2003-05-19 01:24:58.000000000 +0200
@@ -335,6 +335,7 @@
   while ( !cin.eof() ) {
        cin >> ev;
+       if (cin.eof()) break;
        if (ev[0]=='#')
          cout << "Comment: " << ev << endl;

So someone else noticed this warning, noticed that it shouldn't be outputting a warning (if the filename, 01-suppress-false-unknown-tag-message.patch, is any indication), and wrote a patch to suppress it... sweet! Too bad nobody has incorporated it into the trunk yet (that I've noticed).

System -> Preferences -> Keyboard Shortcuts

It looks like the equivalent in gconf-editor is /apps/metacity/global_keybindings.

The "Windows"/Super keys

... is the "super" key in Linux. Or, I suppose, the "Linux" key.

How to use combinations involving the Super key in .xbindkeysrc

$ xbindkeys -k
[I pressed Super+V]
    m:0x50 + c:60
    Mod2+Mod4 + v

How to use the Super keys as modifier keys rather than stand-alone keys

When I try click on an action in the Keyboard Shortcuts window and then press, say, Super+D as my new keyboard shortcut for that action, it stops as soon as I've pressed Super and says "Super L".

How do I get around that?

Maybe edit those settings directly using "gconf-editor" and put "<Super>d" as the shortcut key for that action...? Yes, I have confirmed that that works!

How to disable the capslock key (keep it from toggling the capslock state of your keyboard) Retrieved on 2007-05-11 11:18.

Kill capslock I hate the capslock I never use the Caps Lock button. Never. The only time I "use" it is when I accidently press it and start typing things in UPPERCASE. To disable it in Linux all you have to do is enter this on the command line:

$ xmodmap -e "remove lock = Caps_Lock"

To set this permanently, just stick the above line in your ~/.bashrc file (or /etc/bash.bashrc if you're root) so that it looks something like this:

if [ "$PS1" ]; then
# Disables the bloody CapsLock button
xmodmap -e "remove lock = Caps_Lock"
fi Retrieved on 2007-05-11 11:18.

Want to get rid of the evil caps lock key without mutilating your keyboard? Want to give those silly Windows keys useful jobs, or put all those extra multi-media keys to work? Want to become a powerhouse keyboarding commando? Then come along and join the fun, because Linux has all kinds of good tools for taming wayward keyboards and increasing your efficiency. In this two-part series we're going to use xmodmap, XBindKeys, and KeyTouch to create custom keybindings for launching applications and running commands. The placement of the caps lock key is a demonstration of malicious cunning. It's above the shift key and it's usually oversized, so it's way too easy to hit it when you don't want to, which for me is all the time. On a case-sensitive operating system it's not all that useful anyway. Unhappy users often resort to remedies like prying it off entirely or covering it with duct tape. You can do this if you're careful, but elite geeks resort to more sophisticated measures that do not mangle their nice keyboards. It's not the fault of the keyboards that manufacturers have giant Windows-sized blind spots, and as always, Linux makes lemonade out of lemons and provides useful alternatives.

Xmodmap (or how I hate Caps Lock) ( Retrieved on 2007-05-11 11:18.

The caps lock key belongs on the back of the monitor,

In a safe,
At the bottom of the ocean...
On Venus.

—P-Pomes, Nov 1993

Question: Can you still use the capslock key for other things once you've "disabled" it? Yes! By all means! Map it to something useful, like Control [1] or Escape or Ctrl-C ... anything but capslock!

Now how do I undisable it?


xmodmap -e "add lock = Caps_Lock"

"Special" keys, "Multimedia keys" Retrieved on 2007-05-11 11:18.

        atkbd.c: Unknown key pressed (translated set 2, code 0x9e on isa0060/serio0).
        atkbd.c: Use 'setkeycodes e01e <keycode>' to make it known.


A little background note: When you hit a key on your keyboard, the linux kernel generates a raw scancode for it (if it's assigned). Each scancode can be mapped to a keycode. This is at kernel level. X has a (quasi) total independent way of mapping keys: X reads the kernel keycode table at startup, then map the keycode to its independent keycode table (it's the same as the kernel keycodes but different :)). Then each keycode can be mapped to a keysym, i.e. a string which represent a key or suggest an action. Thus to have our keys fully functional, they need a kernel scancode/keycode plus a X keycode/keysym. It could seem weird, and it is, but X developers have their reason to keep a separate keyboard mapping from the kernel. It's not difficult at all, it's only a quite tedious procedure. Retrieved on 2007-05-11 11:18.

If your keyboard is not supported by Xkb, then you want to find the keycodes for your multimedia keys. If it is supported, then you may want to find out to which keysym names the keys are mapped. This can both be done with the same tool: xev. Open a terminal, and just do:

$ xev






Selecting text copies it to the middle-click buffer

[Differences from Windows (category)]

I like!

At first I didn't think I liked this, having two different clipboard buffers... But I think the benefits outweigh the drawbacks here: It is so convenient to be able to select text and have it automatically copied to the clipboard and then be able to paste to another application with only a single click, without ever touching the keyboard!.

I used to have it set up to be almost as convenient on Windows: I just had to select the text, press the Windows key (mapped to copy), switch to the other app, and press CapsLock (paste).

Question: Paste via keyboard shortcut?

On the other hand, ... I'm more of a keyboard-lover than a mouse-lover, and I don't know of any way to access the middle-click buffer from the keyboard. Does anyone else know a way?

Not only is a keyboard shortcut necessary for those of us who simply don't want to use the mouse much in general; it also has a specific advantage sometimes for mouse users too: With the mouse middle button, you have to actually aim the pointer where you want the text to go -- even if the insertion point in your text editor is already at the right place! This seems silly and like a waste of effort. If there were a keyboard shortcut, you would not only be able to cut out the clicking (middle button) in this case, but you'd also be able to cut out the (error-prone, tedious) step of aiming the mouse pointer to the right coordinates corresponding to the insertion point that's already at the right place...

[I've sort of found an answer to this, described elsewhere on this page. But it's still not ideal.]

Problem: Can't select and then paste or it will wipe out what you meant to paste

This is a common (frequent!) scenario for me: I select some source text, copy it to the clipboard. Then I select some text in a target document and (want to) either delete it, paste over top of it, or drag-and-drop it to somewhere else out of the way.

But with the existing behavior, just selecting the text in the target document wipes out your source text.

In other words, using the middle-click buffer, it's apparently impossible to paste "over top of" (replace) another selection. You would have to delete the text from target document first, then select the source text from source document, then paste into target document.

Workaround: Use the other (Ctrl-C, not middle-click) clipboard buffer.

[GNU/Linux / Desktop / Taking a screenshot (category)] lists a great number of ways to take a screenshot. Retrieved on 2007-05-11 11:18.

[...] Almost all linux distros comes with key binding on print screen button on your keyboard. For the case of gnome when you hit the print screen button, gnome will load up gnome-panel-screenshot (gnome-screenshot), display a small screen preview and ask for a filename to save. That is convenience, it does the simply way of taking a snapshot of “entire screen”. And it also allow you to set the delay.

gnome-screenshot --delay=5

The command line above will delay for 5 seconds before taking the real screenshot.

When I want take a screenshot of an application, let's say gaim. I ll do gnome-screenshot first and then load up gimp to cut the portion I want out. No! I don’t do that anymore [now that I know about] imagemagick’s import.

import allows you to take a snapshot on anything in the X. Not limit to entire screen, but it is flexible enough for you to specified your range on any portion of your screen.

Let say, I want to take a snapshot of gaim, I will run this:

import gaim.png

When I run this, my mouse cursor turns into a cross. With that cross, i can click and drag my mouse to select the portion of the screen I wanted to snapshot, or simply just click on the gaim application itself.

In case you want to import entire screen, you can specified the root window

import -window root screenshot.png

With help of zenity, you can even create a simple dialog to ask for a filename to save.

timestamp=`date +%d%m%y_%H%M%S`;
filename=`zenity --entry --title "Screenshot Filename" 
--text "Enter the filename for screenshot." 
--entry-text "screenshot_$timestamp.png"`; 
import $filename;

There are more ways to do screenshot in Ubuntu Linux, check it out How to Take a Screenshot in Linux (Ubuntu).

Micah,February 3rd, 2007 at 11:45 am

Anyone on linux should use Ksnapshot. Ksnapshot has a nice GUI (, selectable regions to capture, and can print from within the app itself. I don’t know why anyone would want to use the clunky gnome-snapshot at all!

Annoyances / Open problems

Sometimes you can't click a button until you move away from it and come back

It's almost as if the button is waiting for a "mouse has entered this region" message before it starts listening for "mouse click" messages... which seems pretty silly to me.

You can't Alt-Tab while you are dragging something

I used to do this frequently under Windows: I would start a drag from one window and then switch focus to another window which wasn't visible before by pressing Alt-Tab. But Alt-Tab seems to be disabled while you are dragging.

Workaround: Drag to the desired window on the taskbar, hover until that window gains the focus, and then drop into that window.

Whose problem is this?

  • Metacity/GDM?
  • Nautilus?
  • X? doesn't handle the middle-click-buffer paste the same way as other apps

[OpenOffice (category)]

Perhaps it catches the middle click event and handles it specially rather than letting GNOME/etc. handle it...??

From external app

If I select text while in some other app (say, Firefox) and then middle click in OpenOffice, nothing happens. That's right, nothing.

Update: Oops, never mind, it seems to be working now. I could have sworn that it wasn't working before though.

Within OpenOffice

It seems to only paste things that are currently selected. So if you select something, you can right click somewhere else and it will duplicate that text. But if you then click or use the arrow keys to move the insertion point (and cause your selection to stop being selected), and then middle click ... nothing happens.

Double-click/alt-arrow-key word selection is unintelligent and unintuitive

Double-clicking whitespace selects the word to the right of the whitespace

On Windows, it only selected the whitespace, which is what I'm used to and which is the behavior I like better now that I've experienced both.

Can we fix this??

Also, double-clicking a word that is beside some punctuation marks (-, =, ", . -- anything I've tried) also selects the punctuation marks -- which is not what I want.

Example: Double-clicking on there in "Hi there." causes there." to be selected.

Even if you have an XML tag or something following or preceding a word--that will get picked up and selected too.

Can we fix this??

(Alt-Left and Alt-Right apparently use the same word-selection behavior/code.)

[Firefox (category)]: Drag and drop of the address bar only gives URL

[Differences from Windows (category)]

When you drag the address bar (or the icon beside it) to another app (a textarea in another browser window), I'm used to having it insert the URL as well as the title. In X / Gnome, it looks like it only inserts the URL. (Oh well. At least it's usually pretty easy to copy and paste the title of the page using the middle button...)

Can't take a screenshot (through the usual way) when you have any menus open

[GNU/Linux / Desktop / Taking a screenshot (category)]

The usual way would be to press PrintScreen or Alt + PrintScreen. Normally, when you do that, the gnome-screenshot app pops up and lets you accomplish that which you were trying to accomplish.

However, if you have any menus open in your apps (either normal menus or context menus), gnome-screenshot will just silently not pop up ... for no apparent reason.


(Found with Retrieved on 2007-05-11 11:18.

... [...] As I am not a screenshot guru, the fact that there is no direct way to capture an image of an object, like a menu, suprised me. I expected that such a capability would exist in a flexible graphical toolkit like GTK. Also, I should mention that it was impossible to screen capture the menu by using the Print Screen keyboard button or the Alt-Print Screen button combination. Moreover, I didn’t find a way to accomplish the task with the GIMP’s acquire feature, even by using the “delay” functionality. The menu would not be visible! Anyway, the method I used was the following: First, I issued the following command in a terminal:

$ gnome-screenshot --delay=10

This takes a screenshot of the whole desktop after waiting for 10 seconds. In the meantime I had raised Epiphany’s window and kept the mouse cursor over the menu I wanted to take a screenshot of.

After the 10 seconds had passed, the image was ready and the menu was visible. So, I loaded it in GIMP, cropped it and finally saved it.

stavrosg,February 28th, 2007 at 5:31 pm

I’ve hit the same wall a couple of times in the past, and my solution was essentially the same, but with scrot instead of gnome-screenshot:

$ scrot -d 5

Then make the neccesary arrangements and wait for the shoot.

(Open) Questions / "How do I...?"

How do I insert a special character?

Like an emdash, for example... In Windows, there's the Alt-number shortcut (Alt+0151 for an emdash, for example). Does Linux have an equivalent??

[Differences from Windows (category)]

Somewhat advanced stuff

How do you disable certain keystrokes in X?

For example, if you want to create a kiosk app so that users can only use a certain app and not be able to switch out if it...

[3] explains how to disable Ctrl+Alt+Fn and Ctrl+Alt+Backspace:

"man xorg.conf", the DontZap and DontVTSwitch options.

But there are bound to be other things you'd want to lock down if you wanted to create a truly robust (well, "locked down") kiosk.

Changing what gets started when X starts up

System -> Preferences -> Sessions

This gives you a GUI frontend to add applications that should always be started...

You can also remove programs from the list or simply disable them.

Startup scripts

[Open problems/questions (category)] How do you start a GUI app from the command line without making it dependent on the terminal process

What I mean is, I don't want this to happen:

  • I type update-manager (or xbindkeys-config, or pretty much any other app) in the terminal
  • The update-manager window comes up
  • I close the terminal
  • The update-manager window closes

Yes, I know I can type command& to start the app in the background so that I can keep typing. But that doesn't solve this problem.

The problem appears to be that the new process is a child process of my CLI shell (bash), which is a child process of my terminal emulator (gnome-terminal):

> ps uxf
tyler    18976  0.0  1.1  82772 36600 ?        Sl   14:29   0:02 gnome-terminal
tyler    18979  0.0  0.0   2660   744 ?        S    14:29   0:00  \_ gnome-pty-helper
tyler    18980  0.0  0.1   6056  3532 pts/1    Ss+  14:29   0:00  \_ bash
tyler    23640  0.0  0.1   5904  3352 pts/0    Ss   16:00   0:00  \_ bash
tyler    24567  0.0  0.0   5216  2884 pts/0    S+   16:19   0:00  |   \_ xbindkeys-config
tyler    26851  0.0  0.1   5904  3324 pts/2    Ss+  17:18   0:00  \_ bash
tyler    28540  0.8  0.1   5904  3320 pts/3    Ss   18:00   0:00  \_ bash
tyler    28556 29.4  2.4 109940 74256 pts/3    S    18:00   0:02      \_ /usr/bin/python2.5 /usr/bin/update-manager
tyler    28576  0.0  0.0   2600   980 pts/3    R+   18:00   0:00      \_ ps uf uxf

So when I exit that gnome-terminal window, it exits the bash process (28540), which causes all child processes (28556: update-manager) to be killed as well.


Possible solution: Custom wrapper script for each

It looks like this is how Firefox does it...

$ which firefox

$ file /usr/bin/firefox 
/usr/bin/firefox: symbolic link to `../lib/firefox/firefox'

$ file /usr/lib/firefox/firefox
/usr/lib/firefox/firefox: POSIX shell script text executable

$ cat /usr/lib/firefox/firefox
if [ $debugging = 1 ]
  echo $dist_bin/ $script_args $dist_bin/$MOZILLA_BIN "$@"
"$dist_bin/" $script_args "$dist_bin/$MOZILLA_BIN" "$@"

In my case, "$dist_bin/" $script_args "$dist_bin/$MOZILLA_BIN" "$@" evaluates to: /usr/lib/firefox/ -g /usr/lib/firefox/firefox-bin


if [ $moz_debug -eq 1 ]
    moz_debug_program ${1+"$@"}
    moz_run_program ${1+"$@"}

exit $exitcode

Possible solution: A command, sort of like gksu, that you can prefix any GUI app command with

Windows has the "start" command when on the command line. Don't tell me GNU/Linux has no analog!


man gksu:

       gksu - GTK+ frontend for su and sudo


       gksu [-u <user>] [options] <command>

       gksudo [-u <user>] [options] <command>

       gksu is a frontend to su and gksudo is a frontend to sudo.  Their primary purpose is to run graphical commands that need root without the need to run an X terminal
       emulator and using su directly.

       Notice that all the magic is done by the underlying library, libgksu. Also notice that the library will decide if it should use su or sudo  as  backend  using  the
       /apps/gksu/sudo-mode  gconf  key,  if  you  call the gksu command. You can force the backend by using the gksudo command, or by using the --sudo-mode and --su-mode

       If no command is given, the gksu program will display a small window that allows you to type in a command to be run, and to select what user the program should  be
       run as. The other options are disregarded, right now, in this mode. Retrieved on 2007-05-11 11:18.

For launching graphical applications with rootly powers, or as any other user, you need gksu or kdesu. Using one of these gives you a graphical login window, like Figure 2. gksu is a graphical front-end to both su and sudo. Just to add to the fun and confusion, so is gksudo. Making it even more fun is Ubuntu makes gksu behave like gksudo. So let's talk about this first. Retrieved on 2007-05-11 11:18.

Because Ubuntu makes gksu and gksudo both behave like sudo, how do you configure xbindkeys to run a command as "real" root? Use the -w switch, like this:

$ gksu -w kate

You can cancel the sudo timeout with this command:

$ sudo -k

This is helpful when you're testing your commands and they get stuck in sudo mode.

Differences from Windows

Category Differences from Windows not found

Drag a URL/location from Firefox and drop in an another app

target app in Windows on GNU/Linux
gvim nothing happens it inserts the URL!

[GNU/Linux / Desktop / File managers (category)]

pcmanfm -- with tabbed-browsing Retrieved on 2007-05-11 11:18.

I like nautilus file manager as it allows me to access samba drive, ftp site etc, but when it comes to file manipulations, especially when I need to open multiple folders, I wish I could have it all in tabs like firefox. ...

[Nautilus (category)]

Customizing the context menu





umask / default file permissions

Multiple desktops Retrieved on 2007-05-11 11:18.

I think you should use desktops more. You can group windows by activities - one desktop for messaging stuff, one for music, one for web browsing, use the pager or the window list (which is on the top right in a gnome setup) to move between desktops. I typically use six desktops, and there is no need for minimizing windows. The taskbar isn't needed anymore.

I've never understood the use of taskbars in a system with virtual desktops. It makes sense in the Other OS, but I've never seen the point in GNOME. My browser is always in desktop 3; my terminal is always in #1, my music is always in #4, etc. Having an omnipresent widget just to tell me which apps are open seems like a bad use of screen real estate; I know exactly where my apps are without even thinking about it. Learning to be consistent in which programs you open on which desktops really pays off. Then again, maybe it just works well for me since I am a web developer, and I have a predictable set of programs open at all time with little variance.


Trying to get the taskbar (window list) to take 2 rows instead of one

Date/time preferences

How to change your date format

On the command line

Not sure how far-reaching this change is, but here's what I did:


$ date
Mon Aug 13 10:07:49 PDT 2007


$ date '+%Y-%m-%d %k:%M:%S'
2007-08-13 10:07:49

This didn't appear to change the behavior of anything in GNOME, however, so it might only change it for the current terminal session. (What if I put that in my startup script though?)

In Nautilus's preferences

In Configuration Editor apps/nautilus/preferences, I have an entry for "date_format" which shows "locale".

I changed mine to yyyy-mm-dd.

In Thunderbird Retrieved on 2007-05-11 11:18.

In "configuration editor apps>nautilus>preferences" I have an entry for "date_format" which shows "locale". I've changed it to "yyyy/mm/dd" but Mozilla Thunderbird still shows dates as "mm/dd/yyyy". F-Spot also shows in the "mm/dd/yyyy" format.

For Thunderbird, see this: Mozilla & Thunderbird date display format There is also an extension to config the date format in Thunderbird: Retrieved on 2007-05-11 11:18.

user_pref("", 2); With the above line inserted into user.js, messages received or sent during the current day will be displayed with both the date and time. The date will be in your operating system's current short date format (which is typically a numeric format).

I edited my /home/tyler/.mozilla-thunderbird/ProfileName/prefs.js, added

user_pref("", 1);

, and restarted. No change. Also tried:

user_pref("", 2);


Haven't tried this yet... Hoping that I don't need to...

Using LC_TIME environment variable Retrieved on 2007-05-11 11:18.

International standard is to format dates like “2005-12-11 18:13”. However, the popular email client Mozilla Thunderbird uses an obsolete and backwards date format by default. This article explains how to enable international ISO-8601 dates on Thunderbird. Only time is changed, so you can have both English language user interface and correct dates. I will concentrate on Ubuntu Linux and Debian Linux, but pointers for fixing this on other operating systems are given too.

Fix for Ubuntu

$ export LC_TIME=en_DK.utf8
$ mozilla-thunderbird

To fix this permanently, put the line in your $HOME/.bashrc, $HOME/.profile or create a shell script thunderdates and put the export in that.

Tested with Ubuntu Breezy Badger 5.10 and Mozilla Thunderbird 1.0.7 on 2005-12-11.


Most of the world has already ridden itself of obsoleted units, such as inches and feet. I hope that soon all programs could have sensible defaults, for example units from the SI-system (metric system) and iso-8601. Retrieved on 2007-05-11 11:18.

In Linux, these settings are based on your locale. If the environment variable "LANG" is set to "en_US", for example, Thunderbird will show the date in "MM/DD/YYYY" format. To override the locale only for showing dates, set the "LC_TIME" environment variable (for example, "LC_TIME=en_GB"). If you want the ISO 8601 date format (YYYY-MM-DD), use the "en_DK" locale.

On my system:

$ locale

Have added this to ~/.bashrc now:

export LC_TIME=en_DK.utf8

Okay, well that works fine now if I start up a terminal and then type thunderbird from the command line.

But what if I want to start it from the menu instead?

I went to the menu editor and edited the properties for the "Mozilla Thunderbird Mail/News" item.

The Command used to be: thunderbird %u

I tried changing it to this:

export LC_TIME=en_DK.utf8; thunderbird %u

but it said "Could not launch menu item. Failed to execute child process "export" (No such file or directory)

So I tried changing it to this:

sh -c 'export LC_TIME=en_DK.utf8; thunderbird %u'

That worked!!

It's kind of ugly... but it's better than having to create a shell script file that contains those commands.

I'm not sure what the %u is for, but I retained it.

Sound and video


I used EasyUbuntu to get the codecs, but there are probably other ways.

Utilities Retrieved on 2007-05-11 11:18.

  1. XFree86 distribution contains a few useful command line utilities:
* Xnest, xgamma, xev, xwininfo, xprop, xlsclients, xlsatoms, xdpyinfo, xset, xrandr, xlsfonts, xkill
  1. Check out my GKrellM plugins:
* gkrellm-trayicons * gkrellm-xkb * gkrellm-gamma * gkrellm-fileread


Click a window to kill the process that owns that window.

GNOME Launch Box

Source code:

Description: Launch Box is generally an application launcher. It's very influenced by Quicksilver for Mac.

Error on call to Template:cite web: Parameter url must be specified. Retrieved on 2007-05-11 11:18.

Currently supported modules are:

  • Application starting and launch
  • Evolution contacts lookup and mail to
  • Recent files lookup and open
  • Files in your desktop and open
  • Firefox bookmarks lookup and opening



Description: Tilda is a Linux terminal taking after the likeness of many classic terminals from first person shooter games, Quake, Doom and Half-Life to name a few, where the terminal has no border and is hidden from the desktop till a key or keys is hit.


Download from: sudo apt-get install xmacro


Download from: sudo apt-get install zenity


Source code:

Description: XOSD displays text on your screen, sounds simple right? The difference is it is unmanaged and shaped, so it appears transparent. This gives the effect of an On Screen Display, like your TV/VCR etc. It's excellent for notifications.

Authors: Philipp Matthias Hahn

I built/compiled the files, but it didn't appear to produce a binary / command-line program, so apparently it's just a library...?



Download from: sudo apt-get install xclip

$ xclip -help
Usage: xclip [OPTION] [FILE]...
Access an X server selection for reading or writing.

  -i, -in          read text into X selection from standard input or files
  -o, -out         prints the selection to standard out (generally for
                   piping to a file or program)
  -l, -loops       number of selection requests to wait for before exiting
  -d, -display     X display to connect to (eg localhost:0")
  -h, -help        usage information
      -selection   selection to access ("primary", "secondary", "clipboard" or "buffer-cut")
      -version     version information
      -silent      errors only, run in background (default)
      -quiet       run in foreground, show what's happening
      -verbose     running commentary
$ xclip -o -sel clipboard; echo   # copy/paste (ctrl+c) clipboard

$ xclip -o -sel primary; echo     # "selection" clipboard

$ xclip -o -sel secondary; echo

$ xclip -o -sel buffer-cut; echo Retrieved on 2007-05-11 11:18.

Here are some ideas for things you can do with xclip:

        Copy your uptime into the selection for pasting:
        uptime | xclip

        Copy your password file for pasting:
        xclip /etc/passwd

        Save some text you have Edit | Copied in a web browser:
        xclip -o -sel clip > webpage.txt

        Open a URL selected in an email client
        mozilla `xclip -o`

        xclip -o | xclip -sel clip

        In command mode in vim, select some lines of text, then press shift-:
        for an ex prompt, and use this command to copy the selected lines of
        text to the primary X selection:
        !xclip -f

devilspie (Devil's Pie)

Source code:
Download from: sudo apt-get install devilspie

Description: A window-matching utility, inspired by Sawfish's "Matched Windows" option and the lack of the functionality in Metacity. Metacity lacking window matching is not a bad thing — Metacity is a lean window manager, and window matching does not have to be a window manager task.



Download from: sudo apt-get install xnee

Description: GNU Xnee is a suite of programs that can record, replay and distribute user actions under the X11 environment. Think of it as a robot that can imitate the job you just did.

Xnee can be used to

  • Automate tests - e.g nightly automatic regression tests
  • Demonstrate programs - e.g record and replay a user interaction with your system
  • Distribute actions - e.g teacher's actions can be sent to all student's desktops
  • Record and replay 'macro' - e.g Tie a key modifier combination (e.g using xkeymouse) to replay a recorded session. The macro is WM- and program independent.
  • Retype a file - e.g When testing an editor, Xnee can type in the content of a file. This can be compared with the original.


Source code:

Description: Has nice colored bars to tell you how much disk space is used by a given directory.



As listed in other directories:

Readiness: Hmm, hasn't been updated since 2004-05-13?

Good GNU/Linux desktop software

Good GNU/Linux desktop software edit

media player: Amarok

A lot like iTunes.

To-do lists



When the system stops "working"

Ctrl-Alt-Backspace to kill X (does it restart it automatically?)

Ctrl-Alt-Delete to restart the system (will unmount your drives safely first)

When everything else fails: [4]

Raising Skinny Elephants Is Utterly Borin

  • Left Alt + SysRq (printscreen key) + r
  • Left Alt + SysRq + s
  • Left Alt + SysRq + e
  • Left Alt + SysRq + i
  • Left Alt + SysRq + u
  • Left Alt + SysRq + b

News / Victories

Linux on the desktop. The last battle. Linux has already won the server war (IMHO). The last battle will be to get the casual home user, etc. to switch from Windows. The only question is, how long will that take? Retrieved on 2007-05-11 11:18.

Dell and Ubuntu fired the first shots. Together, they delivered the first mainstream consumer Linux desktops and laptops. Then, on Aug. 6, Novell and Lenovo blew open the business laptop market with the first regular listing of a Linux-powered business desktop, the T-series ThinkPads with SUSE Linux Enterprise Desktop. Then, just to underline the point that we're seeing a Linux desktop revolution, Dell announced that it too would be offering SLED on business systems. In Dell's case, the company will start by offering SLED in China. Anyone out there still think that the Linux desktop will never make it? If so, wake up and smell the coffee. Dell, let me remind you, didn't just release consumer Linux systems as a PR stunt, and then let them wither and die. Dell followed that release up with more Ubuntu-based systems. This time, Dell placed Ubuntu on its newest line of laptops: the Inspiron 1420. Oh, and by the way, Dell's now offering Ubuntu-powered systems in England, France, and Germany. ... Why is this finally happening? I could go on and on, but I think it's a combination of two major factors. The first is simply that the Linux desktop has gotten to the point where anyone or any business can use it to do useful work. The other is that Microsoft -- and I don't care what numbers people quote -- has a lemon in Vista. ... So, here we are. The Linux desktop was coming on strong and Vista, as I thought it might turn out, wasn't that good. And, thus it was that desktop Linux was finally given its chance to fight for its fair share of the desktop. ...

[Sources of information (category)] "We explain every GNU/Linux command by examples"

Facts about GNU/Linux / DesktopRDF feed
Description [Oops! No type defined for attribute]
Personal tools