[99]http://lwn.net/Articles/91371
____________________________________________________
Triggering one of several options with Juk and KHotkeys
Jimmy O'Regan ([100]The LG Answer Gang)
I posted a story on [101]http://dot.kde.org mentioning that LG has two
[102]KDE related articles this month, and someone asked how to have multiple
possible actions attached to a single key - launch Juk if it isn't running,
pause if playing and vice versa, and play if stopped. This script does that:
See attached [103]juk.bash.txt
[Ben] Intermediate-level shell tip for the above situation:
ps aux|grep '[j]uk'
Will ignore the 'grep' line every time. Why? Well...
ben@Fenrir:~$ find / [f]oo > /dev/null 2>&1 &
[1] 8099
ben@Fenrir:~$ ps --pid 8099
PID TTY TIME CMD
8099 pts/0 00:00:02 find / [f]oo
Note that 'ps' lists the command exactly as invoked - square brackets and
all. 'grep' itself, however, interprets the square brackets as a character
class: that is, it looks for a match for any character(s) contained within
the brackets. Since the only character within the brackets is 'f', '[f]oo'
is interpreted simply as 'foo'. As a result, 'grep' is searching for 'foo'
- but the 'grep' line itself, as listed by 'ps ax', does not contain
'foo'; it contains '[f]oo', which does not match.
The concept is a bit difficult to understand the first time, obvious - and
handy! - forever after. :)
I'd forgotten this; handy. Only works, of course, if the argument to grep is
a literal. Well, more accurately, it's even harder to understand (and
possibly might break other things) if you put it in a variable...
[Ben] You're right: it can be made to work but would Not Be Conducive to
Understanding. Something like
# [104]YANETUT
first=${var:0:1}
last=${var:1}
ps ax|grep "[$first]$last"
Ugh.
____________________________________________________
Using Windows Keyboard Media Buttons In Linux
john frey ([105]iaargh from shaw.ca)
For years now I have been staring at the extra keys on my Logitech Freedom
Optical with despair in my heart. I told myself I did not really need them,
but somehow I felt less than a windows drone because I paid the money for a
cordless keyboard and mouse and did not have full function.
Then I read this article, tried a few of the hotkeys for launching email,
web browser and local file browser. That was all very neat but what i really
wanted was to use the dial on the keyboard for volume control. My speakers
have buttons to push for volume control but they are clunky and response is
slow, using a slider on Kmix is equally unwieldy. When the email
notification suddenly blares out (because I just finished watching a movie
and forgot to lower the sound) I want to turn the sound down before the last
tones fade out.
I muddled about in the [106]KDE control centre a bit with not much success
then hit on the astounding idea that maybe I could configure this from Kmix.
Right click on the master volume control -> define keys......a few short
clicks later and I had the dial working to raise and lower sound and the
mute button as well. I felt f***n great. Can you say eeeasssy, can you say
in-tui-tive? Wow, this is really the cats pajamas!
Sometimes the smallest things just make life worth living again ;~)
____________________________________________________
Telnet's nice, netcat's better
Flavio Poletti ([107]anonymous)
Sending some network traffic from the shell.
Some time ago (actually, a long time ago) I needed to send some TCP traffic
towards a host on a regular basis. So... the only tool I knew was telnet, I
had no clue about socket programming, and I had to study expect in order to
get the job done. No need to say, it was a real pain - what else should I
/expect/? (For those who don't know what I'm talking about, I suggest to
perform more-than-trivial interaction with some server on ports other than
the telnet one).
Some time later, I learnt socket programming, so I was able to do the job
inside C and call my program from the shell. But you can bet on it - it was
some very focused application and proved to give me no help in a
similar-but-different context.
It was then that I discovered netcat.
=7= |