Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can my shell script control the placement of a zenity window?

Tags:

shell

x11

zenity

I'm using zenity to post a simple notification when my spam-filter daemon filters a group of messages. Currently this message is posted to the middle of the screen, which is obtrusive. I want to post it to the upper left corner. However, zenity does not honor the -geometry option which is supposed to be standard for all X applications, and its documentation gives options for controlling window height and width, but not placement.

Is there a way to control the (x,y) coordinate at which a zenity window is posted?

If not, is there a way to solve this problem by tinkering with X resources or the window manager (I'm using the fvwm)?


EDIT: The following do not work in ~/.fvwm2rc (fvwm version 2.5.26):

Style "Information" PositionPlacement -0 -0
Style "Zenity" PositionPlacement -0 -0

They also don't work with the -0 -0 dropped, as suggested in the man page. (The window title for zenity --info is "Information".)

Interestingly, zenity was ignoring my earlier window-manager directive that windows should be placed manually by default.


EDIT:

Among many other fascinating pieces of information, xprop(1) reports this about the zenity window:

_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DIALOG
WM_NORMAL_HINTS(WM_SIZE_HINTS):
                program specified location: 0, 0
                program specified minimum size: 307 by 128
                program specified maximum size: 307 by 128
                window gravity: NorthWest
WM_CLASS(STRING) = "zenity", "Zenity"
WM_ICON_NAME(STRING) = "Information"
WM_NAME(STRING) = "Information"

Despite this apparently encouraging report, the window is not in fact posted at the location 0,0 :-(

I know the Style command is taking effect because I added the !Borders option, and sure enough the zenity window posts without borders... but still in the center of the damn screen!

like image 461
Norman Ramsey Avatar asked Nov 11 '09 21:11

Norman Ramsey


Video Answer


1 Answers

I do it by using wmctrl in a subshell. Example:

((sleep .4;wmctrl -r TeaTimer -R TeaTimer -e 0,50,20,-1,-1)
for ((a=$LIMIT; a > 0; a--)); do
# for loop generates text, not shown
done
wmctrl -R TeaTimer
) | zenity --progress --title="TeaTimer" --percentage=0

First wmctrl moves zenity to upper left, second moves it to current workspace. See a full example.

like image 59
Roland Avatar answered Sep 19 '22 10:09

Roland