Skip to Main Content
Linux Desktop Hacks
book

Linux Desktop Hacks

by Nicholas Petreley, Jono Bacon
March 2005
Beginner to intermediate content levelBeginner to intermediate
342 pages
15h 55m
English
O'Reilly Media, Inc.
Content preview from Linux Desktop Hacks
36
|
Chapter 2, Console
#11 Energize Your Console with Macro Music Magic
HACK
HACK
#11
Energize Your Console
with Macro Music Magic Hack #11
Redefine keys to issue commands at the command line.
You can exploit the power of the preceding keyboard customization tech-
nique to a much greater degree than just redefining the action of a key. You
can actually define keys to send strings of characters, which, at the console,
means issuing commands.
In this example, you’re going to redefine keys to control your CD-ROM as a
CD player. Even if you have a plain keyboard, you can simply use unusual
key combinations such as Ctrl-Alt-Right Arrow to perform the kind of magic
you’re about to explore. If you can determine the keycodes generated by any
special keys you have on your Internet or multimedia keyboard, you can use
those keys instead.
Defining the Magic
First, you want to create a file called /etc/mykeys, or add to your existing /etc/
mykeys file if you are combining this hack with “Redefine Keyboard
Actions”
[Hack #10]. You will place in /etc/mykeys string definitions that repre-
sent commands. The
cdtool program is really handy for controlling a CD
player at the command line without a bothersome user interface. You can
use another tool if you prefer, but you’ll have to substitute your tool’s com-
mands for the ones defined by
cdtool.
Assume you are using
cdtool to define commands to play a CD, stop play-
ing it,
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Server Hacks, Volume Two

Linux Server Hacks, Volume Two

William von Hagen, Brian K. Jones
Introducing Linux Distros

Introducing Linux Distros

Jose Dieguez Castro

Publisher Resources

ISBN: 0596009119Supplemental ContentCatalog PageErrata