How can I activate a Panel-icon via a script (or get its screen co-ordinates; to click it)?

Posted by fred.bear on Ask Ubuntu See other posts from Ask Ubuntu or by fred.bear
Published on 2010-12-08T04:44:48Z Indexed on 2011/01/11 19:59 UTC
Read the original article Hit count: 180

Filed under:
|

This question is in the context of Lucid 10.04 desktop (ie. no Unity).

I do most screen navigation via the keyboard (not the mouse), so I'm looking for a script solution to re-activating an app which has been "minimized" to the Panel's Notification Area.

I'll use Skype as an example.

wmctrl allows me enough access to normally-minimized windows, but when Skype is "minimized" to the Notification Area, it simply goes "off the radar" as far as wmctrl is concerned.

Bearing in mind that icon positions in the Notification Area can vary, is there some way to determine the screen co-ordinates of Skype's Panel icon, so I can "click" it using xdotool (or a similar utility)?

...or maybe there is a more direct way to activate the "dormant" Skype? ... (and I don't mean the mouse ;)

Here is the script, so far. Hopefully it will make clear what I'm trying to do:

#!/bin/bash
procname="skype-wrapper"
windmask="Skype™"
if [[ $(pgrep -x -n -c "$procname") == 1 ]] ; then 
  wintitle="$(wmctrl -l |grep "$windmask" |head -n 1 |sed -n "s/^.\+${HOSTNAME} \(.*\)/\1/p")"
  if [ "$wintitle" = "" ] ; then
    echo "Click on Skype's Panel-icon to show the main window"  
    ###############################################################
    # How can I find the screen co-ordinates of Skype's Panel Icon
    ###############################################################
  else
    # Skype is running, and has (at least) one visible window which matches $windmask. Activate it.
   wmctrl -a "$wintitle"
  fi
else 
  # The process is not currently running. Start it.
  ("$procname" &)
fi

© Ask Ubuntu or respective owner

Related posts about xorg

Related posts about bash