omap3-pandora-kernel2: update
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts / op_xfcemenu.sh
1 #!/bin/bash
2
3 #
4 # Show or hide XFCE application/popup menu when Pandora key is pressed.
5 # Enhanced by bsp
6 #
7
8 function loc_menu_show {
9   xfce4-popup-menu
10 }
11
12 function loc_menu_hide {
13   WINID=`xwininfo -name xfce4-menu-plugin|grep 'Window id:'|awk '{print $4}'`
14   xdotool keydown --window $WINID Escape
15 }
16
17 MENU_SY=`xwininfo -name xfce4-menu-plugin|grep Height|awk '{print $2}'`
18
19 if [ 1 -eq $MENU_SY ]; then
20   # panel is in auto-hide mode and the menu is currently invisible
21   loc_menu_show
22 else
23   # hack to determine whether the menu is visible, regardless of the panel auto-hide mode
24   NUM_MENU_WINDOWS=`xwininfo -tree -root | grep 'xfce4-menu-plugin' | wc -l`
25   echo $NUM_MENU_WINDOWS
26   if [ $NUM_MENU_WINDOWS -gt 4 ]; then
27     loc_menu_hide
28   else
29     loc_menu_show
30   fi
31 fi