This forum has been archived. All content is frozen. Please use KDE Discuss instead.

retrieving active terminal in yakuake

Tags: yakuake yakuake yakuake
(comma "," separated)
musonio
Registered Member
Posts
19
Karma
0
OS

retrieving active terminal in yakuake

Sat Jul 30, 2011 10:54 am
I posted this in LinuxQuestions before I figured out that the problem(?) was with yakuake itself.
I'm trying to run 4 instances of folding@home (one for each core) in a quad yakuake session. I tried with the following:

Code: Select all
#!/bin/sh
qdbus org.kde.yakuake /yakuake/sessions addSessionQuad
Term1=`qdbus org.kde.yakuake /yakuake/sessions org.kde.yakuake.activeTerminalId`
let Term2=$Term1+1
let Term3=$Term1+2
let Term4=$Term1+3
echo "Term1"=$Term1
echo "Term2"=$Term2

for i in 1 2 3 4 ; do
  echo $Term$i
  qdbus org.kde.yakuake /yakuake/sessions runCommandInTerminal $Term$i "cd ~/.FOLDING_HOME/F$i/ ; ls"
  # qdbus org.kde.yakuake /yakuake/sessions runCommandInTerminal $"$TermP" "cd ~/.FOLDING_HOME/F$i/ ; ./fah6 -verbosity 9"
done

(Needless to say: my bash skills are extremely poor).

The problem is that when when a quad session is created, no active terminal is defined. This is certainly not a bug but rather a feature (or the lack of it).

Examples:

Code: Select all
 

$ qdbus org.kde.yakuake /yakuake/sessions org.kde.yakuake.activeTerminalId
54

$ qdbus org.kde.yakuake /yakuake/sessions addSessionQuad ; qdbus org.kde.yakuake /yakuake/sessions org.kde.yakuake.activeTerminalId

-1



Is there any workaround for this?
hein
KDE Developer
Posts
69
Karma
1
OS
One of the forum admins kindly pointed me toward this thread :).

The reason this doesn't quite work is because the focus event that sets the active terminal id only occurs once the window is opened (or immediately when it's already open while the D-Bus call is made). I.e. if you do addSessionQuad while the window is closed, the active terminal id isn't set immediately because technically there is no active terminal yet.

I've fixed this now in the development version so that the terminal that will receive focus once the window opens is immediately set as the active terminal even while the window is closed, so activeTerminalId will return something useful.

Another interesting tidbit: Already as of a few weeks ago the addSession* and split* D-Bus calls return the id's of the newly-created sessions/terminals in the dev version.

Tip for the future: A Bugzilla report has a greater chance of reaching me, even if it worked this time :).


Plasma, apps hacker. KDE e.V. vice president.
musonio
Registered Member
Posts
19
Karma
0
OS
Hein:
First of all, congratulations for your work and thanks. Yakuake is a work of art.
Concerning the question of the post, I didn't post it in bugzilla since I didn't consider it a bug per se. That's why I asked for a workaround.
Thanks again.
hein
KDE Developer
Posts
69
Karma
1
OS
Yeah, it's not necessarily a bug, but Bugzilla is also appropriate for wishes, or generally if you have a problem accomplishing something with our software, so don't hesitate to go there in need. Also, thanks for your kind words :).


Plasma, apps hacker. KDE e.V. vice president.
musonio
Registered Member
Posts
19
Karma
0
OS
I've just find sort of a workaround.
Code: Select all
qdbus org.kde.yakuake /yakuake/sessions addSessionQuad ; qdbus org.kde.yakuake /yakuake/sessions terminalIdList


All I have to do is know hot to cut those final digits, but I'm sure a google and man cut will do.

This is perhaps the nastiest workaound imaginable, but it works:

Code: Select all
qdbus org.kde.yakuake /yakuake/sessions addSessionQuad
****=`qdbus org.kde.yakuake /yakuake/sessions activeSessionId`
qdbus org.kde.yakuake /yakuake/sessions removeSession $****
qdbus org.kde.yakuake /yakuake/sessions addSessionQuad
****=`qdbus org.kde.yakuake /yakuake/sessions activeSessionId`
qdbus org.kde.yakuake /yakuake/sessions removeSession $****
qdbus org.kde.yakuake /yakuake/sessions addSessionQuad
RAST=$(qdbus org.kde.yakuake /yakuake/sessions terminalIdList | awk '{LEN=length($0);print substr($0,LEN-10)}' | cut -c 1-2)
echo $RAST


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]