(Taken from: http://gav.brokentrain.net/blog/)
While I've always found the eject keyboard shortcut useful in gnome, one thing that has annoyed me is the inability to toggle between two states. (i.e. close it if its open, and vice versa.)
Fortunately, since eject 2.1.0 this ability as been added as a new -T option. (See changelog here.)
The following basic steps are needed to replace your old 'eject' with the new one:-
- Uninstall the old version of eject
sudo apt-get remove eject- Install the package provided here (Note: this is required, because despite 2.1.3's release on the above site the package seems to be unfortunately broken - which I've fixed by replacing a few missing files.)
sudo dpkg -i eject-2.1.3_i386.deb- Success!
Can be launched as usual using the eject -T flag which will now toggle your cdrom between states.
Further steps (adding to keyboard shortcut.)
This was a bit more tricky, since I found no way to edit gnomes “System -> Preferences -> Keyboard Shortcuts” list and had to be done via Configuration Edtior (gconf) in "Applications -> System Tools."
It's divided into two main steps as follows:-
Step 1
- Decide on the key you want to bind.
This might sound obvious, but on my Apple keyboard I wanted the specific to far right key labeled 'eject' to do this. This key is a multimedia one and had to be mapped specifically in order for this to work. (If you're just using an ordinary key, skip to step 2.)- Determine the multimedia keycode for this using 'xev'.
Launch the command 'xev' in a terminal and hit the key a few times noting the 'keycode' parameter when the string is output to console. e.g:
KeyRelease event, serial 29, synthetic NO, window 0x3200001,
root 0x76, subw 0x0, time 5996809, (190,33), root:(200,130),
state 0x0, keycode 204 (keysym 0xffc6, F9), same_screen YES,
XLookupString gives 0 bytes:- Create an ~/.xmodmap or /etc/xmodmap mapping this key.
Open a text editor and insert the line:
(where 204 is your key as above.)keycode 204 = XF86VendorHome- Restart X. (Ctrl-alt-backspace.)
Step 2
- Open “Applications -> System Tools -> Configuration Edtior”.
- Expand the “/apps/metacity/keybinding_commands/” section.
- For the key name “command_1” insert the value “eject -T”
- Switch to the “/apps/metacity/global_keybindings/” section.
- For the key name “run_command_1” place the desired keyboard key sequence, (or the xmodmap mapping if you are using some special multimedia key and did the above.) i.e. 'XF86VendorHome'
Success!
All going well, the key you have set should now be toggling your cdrom.
Bookmarks