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

Setting a shortcut to a System Tray application

Tags: None
(comma "," separated)
user 01
Registered Member
Posts
16
Karma
0
Hi there,

I am a bit frustrated ... and need some help ...



The problem :

When I start my Kubuntu Trusty (KDE 4.13.3) amd64 , one of the applications that autostarts is Babylon, the translator, through Wine ... it works acceptably well. It autostarts minimized on the System Tray (not on the panel or taskbar) , which is cool (
http://ge.tt/40mVVBq1 ) .

The thing is I would like to set a shortcut to activate it (bring it to the foreground) ( http://ge.tt/820sXBq1 ) ... and I am not able to get there :-(




Aparently three options :

I can think of ways to set this shortcut :

- Customizing the System Tray entries preferences.

- Through qdbus .

- Using tools like 'xdotool' , 'wmctrl' , 'xlsclients' , 'devilspie' , etc ...




Customizing the System Tray entries preferences :

I can not set a shortcut through this way because the option is greyed out ( http://ge.tt/9E6FYBq1 ) .




Through qdbus :

I have been wading through StatusNotifiers ... but I haven't found anything apparently related to Babylon or Wine ( I am not very familiar with this tool either way ) .




Using tools like 'xdotool' , 'wmctrl' , 'xlsclients' , 'devilspie' , etc ... :


Let me tell you that I am not an expert at all about using these tools, but I had though in something like :

wmctrl -lpx ... for getting the Babylon's windowid ... and ...

xdotool windowactivate $windowid ... then make a little bash script and bind it to a global KDE shortcut.


This doesn't work. The problem seems to be that neither 'wmcrtl' nor 'xdotool' have access to the System Tray.




Another option might be something like :

xlsclients -al ... for getting the Babylon's windowid ... and ...

xdotool windowactivate $windowid ... and so on ...



'xlsclients' seems to have access to all applications running on my system, but it throws an unending amount of information ... and when searching for 'Babylon' , 'babylon', 'Wine' , 'wine' and the like nothing comes up. Either way I wouldn't be able to foreground Babylon through 'xdotool' ...


I have spend some time searching on the web without luck, and now I'm frustrated and stuck ...


I would appreciate if somebody could show me some guidance ...


Thanks a lot.
User avatar
Hans
Administrator
Posts
3304
Karma
24
OS
See if this topic helps you: viewtopic.php?f=66&t=122111&p=315841&#p315822


Problem solved? Please click on "Accept this answer" below the post with the best answer to mark your topic as solved.

10 things you might want to do in KDE | Open menu with Super key | Mouse shortcuts
user 01
Registered Member
Posts
16
Karma
0
With Babylon minimized on the System Tray ... ... I send through Konsole :

xwininfo -tree -root | grep "Wine"



... I get :

0x2e00009 (has no name): ("explorer.exe" "Wine") 24x24+0+0 +877+772
0x2e0000c (has no name): ("explorer.exe" "Wine") 1280x34+0+766 +0+766
0x2e0000b (has no name): ("explorer.exe" "Wine") 24x24+1+1 +1+1
0x2e0000a (has no name): ("explorer.exe" "Wine") 1x1+0+0 +0+0
0x3a00001 "BabyScrnag": ("Babylon.exe" "Wine") 106x2+3+22 +3+22
0x3600013 "Babylon": ("Babylon.exe" "Wine") 1x1+0+0 +0+0
0x2e00002 (has no name): ("explorer.exe" "Wine") 1280x20+1280+800 +1280+800
0x3600012 (has no name): ("Babylon.exe" "Wine") 1x1+0+0 +0+0
0x360000c (has no name): ("Babylon.exe" "Wine") 1x1+0+0 +0+0
0x360000a "AXWIN Frame Window": ("Babylon.exe" "Wine") 952x573+4+23 +4+23
0x2e00006 (has no name): ("explorer.exe" "Wine") 1x1+0+0 +0+0
0x2e00005 (has no name): ("explorer.exe" "Wine") 1x1+0+0 +0+0
0x2e00004 (has no name): ("explorer.exe" "Wine") 1x1+0+0 +0+0
0x2e00003 (has no name): ("explorer.exe" "Wine") 1x1+0+0 +0+0


When I send through Konsole :

xdotool search --classname Babylon.exe windowmap


"AXWIN Frame Window" comes up ... which is something like an empty and transparent frame ...

... I guess what I might want is the "BabyScrnag" one ...


... but if I try : xdotool windowactivate 0x3a00001
... I am getting : "XGetWindowProperty[_NET_WM_DESKTOP] failed (code=1)"

How could I refer to "BabyScrnag" instance ?

Do you want the full output from 'xwininfo -tree -root' ?



Thank you.
luebking
Karma
0
BabyScrnag is only 2px high - I doubt that's the window of your interest?

The problem is that mapping a window does just that: map the window.
If the client doesn't react to that event, it will not setup any actual content - internally even may still think to be hidden.

If wine accepts faked events, you may try to "xdotool click" the systray icon.
For FDO typed systray icons (asuuming babylon is), the icon will be a subwindow to the panel window where the systray resides.
It's likely not gonna have many attributes (classname etc.) though.
user 01
Registered Member
Posts
16
Karma
0
I followed your hint, luebking ...



Code: Select all
user01@box01:~/transfer$ xwininfo -tree -root -int | grep "\""
     73400321 "VIM": ("VIM" "Vim_xterm")  1x1+0+0  +0+0
     29360393 "plasma-desktop": ("Plasma" "Plasma")  1280x34+0+766  +0+766
           65011747 "ksystraycmd": ("ksystraycmd" "Ksystraycmd")  24x24+0+0  +849+772
           54525987 "ksystraycmd": ("ksystraycmd" "Ksystraycmd")  24x24+0+0  +877+772
           56623113 (has no name): ("explorer.exe" "Wine")  24x24+0+0  +905+772
           4194419 "Xpad": ("xpad" "xpad")  22x22+0+0  +933+772
           39846077 "shutter": ("shutter" "Shutter")  22x22+0+0  +961+772
     56623163 (has no name): ("explorer.exe" "Wine")  1280x34+0+766  +0+766
     72018484 "Firefox": ("Popup" "Firefox")  200x200+0+0  +0+0
     56623162 (has no name): ("explorer.exe" "Wine")  1280x34+0+766  +0+766
     56623161 (has no name): ("explorer.exe" "Wine")  1280x34+0+766  +0+766
     14680099 "kded4": ("kded4" "Kded4")  378x50+451+640  +451+640
     56623160 (has no name): ("explorer.exe" "Wine")  1280x34+0+766  +0+766
     56623114 (has no name): ("explorer.exe" "Wine")  1x1+0+0  +0+0
     56623159 (has no name): ("explorer.exe" "Wine")  1280x34+0+766  +0+766
     56623158 (has no name): ("explorer.exe" "Wine")  1280x34+0+766  +0+766
     56623157 (has no name): ("explorer.exe" "Wine")  1280x34+0+766  +0+766
     56623106 (has no name): ("explorer.exe" "Wine")  1280x20+1280+800  +1280+800
     56623156 (has no name): ("explorer.exe" "Wine")  1280x34+0+766  +0+766
     56623155 (has no name): ("explorer.exe" "Wine")  1280x34+0+766  +0+766
     56623154 (has no name): ("explorer.exe" "Wine")  1280x34+0+766  +0+766
     58720275 "Babylon": ("Babylon.exe" "Wine")  1x1+0+0  +0+0
     56623153 (has no name): ("explorer.exe" "Wine")  1280x34+0+766  +0+766
     56623152 (has no name): ("explorer.exe" "Wine")  1280x34+0+766  +0+766
     56623151 (has no name): ("explorer.exe" "Wine")  1280x34+0+766  +0+766
     56623150 (has no name): ("explorer.exe" "Wine")  1280x34+0+766  +0+766




... then ...


Code: Select all
user01@box01:~/transfer$ xdotool mousemove 344 799 ; sleep .05 ; xdotool mousemove --window 56623113 5 5 click 1 ; sleep .05 ; xdotool mousemove 1109 725


... my panel autohides, so I have to first use xdotool to show the panel, then click on Babylon icon and finally move again the pointer to a safe place and so left the panel to autohide again.

( http://ge.tt/8YuP7Nq1/v/0 )



Since my Babylon System Tray icon is virtually always on the same position, I tried to make things even simpler. While the mouse pointer was resting over Babylon System Tray icon :


Code: Select all
user01@box01:~/transfer$ xdotool getmouselocation --shell
X=916
Y=788
SCREEN=0
WINDOW=29360393



Image



... and finally :


Code: Select all
user01@box01:~/transfer$ xdotool mousemove 344 799 ; sleep .05 ; xdotool mousemove 916 788 click 1 ; sleep .05 ; xdotool mousemove 1109 725




Image



I have to admit that while neither option is very elegant nor ultra-quick ... and the proccess unhiding/hiding the panel meanwhile the Babylon client comes up is some kind of orthopedic ... it works. So even though the solution is not optimal, I guess the question is SOLVED.


Since Babylon client actually implements a customizable internal shortcut to activate itself, which apparently does not work through Wine, I will keep searching a way to send this shortcut key press simulation to the client and so get a more consistent and graceful solution. I just have learnt that while Babylon client is resting on the System Tray, I can not send this info through 'X window utilities' ... maybe qdbus will be my friend ... I'll see ...



Let me please ask you one more question it just came from the botom of my head : I have a Babylon entry in my Kmenu. When Babylon autostarts on boot time it actually executes a copy of this babylon.desktop file placed on ~/.config/autostart :


Code: Select all
[Desktop Entry]
Comment[es]=
Comment=
Exec=WINEPREFIX=~/.winebon wine start /Unix "/home/user01/.winebon/drive_c/Program Files/Babylon/Babylon-Pro/Babylon.exe"
GenericName[es]=
GenericName=
Icon=/home/user01/Installing SW/Icons & shots/Babylon2.png
MimeType=
Name[es]=Babylon
Name=Babylon
NoDisplay=false
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=




Would it be useful to inform any of these X-DBUS or X-KDE parameters in order to make things easier regarding this kind of problem ?





Thank you very much !!!
luebking
Karma
0
Babylon won't talk dbus (dbus is not a usual IPC on windows) and no config entry would ever change that.

I'd check for "babylon.exe /?" what under windows would usually print a list of supported command switches.
It _may_ offer to bring the window up and that _may_ work under wine.

Please reconsider the "i click the same position" approach which is pot. harmful (anything can be there and you're causing unwanted things)
You could go for fetching the panel from "xwininfo -children -root" and then passing its id to "xwininfo -children -id <panel_id>" to get to the likely babylon systray window (esp. if you're not running other wine systray apps)

While clicking a hidden window does not work, sending a keypress though should, btw. - at least in theory ;-)


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], q.ignora, watchstar