KDE Articles from Linux Gazette

Issue 104 of Linux Gazette is out, and features two articles aimed at new users: Using Windows Keyboard Media Buttons In Linux by Tom Brown discusses the use of KHotKeys, with a brief introduction to DCOP for full control of KDE; and my own article, Front and Back: KPGP and GPG, introduces KGPG, while also showing the corresponding commands for those "stuck at a console" moments.

Dot Categories: 

Comments

by a.c. (not verified)

Thanx for the intro on khotkeys. I was wondering how best to accomplish this.

Now, I am still trying to get irkick to work (mandrake 10 with haupauge card). Just does not seem to want to work. Anybody able to do that?

by standsolid (not verified)

I was just able to get irkick to work over this past week. I've got to tell you it's pretty great.

It was with one of those cheap-o packard bell receievers, tho.

I ended up downloading the sources of lirc .7 snapshot, so it would work with the 2.6.X kernel.

It's soooo cool controlling your desktop with a remote, really it is!

The next thing to do is make it convenient to browse through my TV show collection from my bed. mmmmm. maybe mythtv.... whateva

//standsolid//

by AC (not verified)

Good stuff this KHotKeys. I have one question; is it possible to define more actions to one key based on the current status of the PC. Let me give an example;

No programms are open, I press play/pause button, Juk opens and start playing a song
Juk is playing a song, I press play/pause button, Juk is pausing a song
Juk is in paused mode, I press play/pause button, Juk continues a song
Juk is in stopped mode, I press play/pause button, Juk start playing a song

I don't think KHotKeys is easy to use, for example adding volume de/increase to the buttons I need to browse with KDCOP and find the correct entry.

I'm no usabillity engineer, so I don't really have a great idea how ot improve usabillity. Maybe adding some good templates?

by Jimmy O'Regan (not verified)

I don't have Juk installed, so I can't give you a complete answer, but what you need to do is to create a script, and assign the hotkey to that.

#!/bin/bash
if [ -n "ps aux | grep mozilla | grep -v 'grep mozilla'" ]
then
#Juk is running
dcop juk Player play
else
juk
dcop juk Player play
fi

Juk more than likely has a way of returning its status, so you should be able to do what you want from a single script.

by Jimmy O'Regan (not verified)

Sorry, that should (of course) have been:

#!/bin/bash
if [ -n "ps aux | grep juk | grep -v 'grep juk'" ]
then
#Juk is running
dcop juk Player play
else
juk
dcop juk Player play
fi

I was pasting from a recent discussion on Linux Gazette's Answer Gang. If you post your query there (tagATlinuxgazette.net), Tom might get back to you with an answer. (I've mailed him, pointing here, so he might drop by and answer, but it's best to double your chances :)

by Jimmy O'Regan (not verified)

OK, I installed Juk, and here's your script. Save it somewhere as 'juk.sh'

#!/bin/bash

if [ -z "$(ps aux | grep juk | grep -v 'grep juk' | grep -v 'juk.sh')" ]
then
/usr/bin/juk &
sleep 10
# we need to sleep while Juk initialises DCOP
fi

if [ "$(dcop juk Player playingString)" == "No song playing" ]
then
dcop juk Player startPlayingPlaylist
else
dcop juk Player playPause
fi

by Ari (not verified)

Looks good, but one comment...
You don't actually need to make a script for this part of it:
> if [ -z "$(ps aux | grep juk | grep -v 'grep juk' | grep -v 'juk.sh')" ]

KHotkeys actually has the ability to be pretty smart in how you specify things, so you can tell it to only use a hotkey if a particular app is running or if that app has focus. For example, the group of hotkeys "Konqueror gestures" that come with KDE includes the condition that Active window is Konqueror. You could make a "JuK" group that contains the condition "Existing window" is JuK.

The script works fine, but just thought I'd point that out.

by Jimmy O'Regan (not verified)

Well, the first part of the original question was "No programms are open, I press play/pause button, Juk opens and start playing a song", which is why I had that part.

Also, Ben Okopnik, the editor of LG, has pointed out that the line you highlighted could be better written as:
if [ -z "$(ps aux | grep [j]uk | grep -v 'juk.sh')" ]

by drc (not verified)

This is what I have writen

#!/bin/bash
if ! dcop juk Player playPause
then
juk &
sleep 2
i=50;
while (($i>0))
do
if ! dcop juk Player playPause
then
sleep 1
else
break;
fi
((i=$i-1))
done
fi