How does my shell script control the placement of the zenity window?

I use zenity to post a simple notification when my spam filter daemon filters a group of messages. This message is currently being sent to the middle of the screen, which is intrusive. I want to send it to the upper left corner. However, zenity does not comply with the -geometry option, which should be standard for all X applications, and its documentation provides options for controlling the height and width of the window, but not for placement.

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

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


EDIT . In ~/.fvwm2rc ( fvwm version 2.5.26) do not work:

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

They also do not work with garbage -0 -0 , as shown on the manual page. (The window name for zenity --info is “Information.”)

Interestingly, zenity ignored my previous window manager directive, that by default windows must be manually placed.


EDIT

Among many other fascinating pieces of information, xprop(1) reports this in 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 an encouraging report, the window was not actually placed at 0.0: - (

I know that the Style command takes effect because I added the !Borders parameter, and of course the zenity window will fit without borders ... but still in the center of the damned screen!

+4
source share
5 answers

I do this 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 

The first wmctrl moves zenity to the top left, the second moves it to the current workspace. See full example .

+4
source

You can try using the "old" way to do this using FvwmEvent.

 AddToFunc StartFunction I Module FvwmEvent FvwmEvent-MoveWindow DestroyModuleConfig FvwmEvent-MoveWindow: * *FvwmEvent-MoveWindow: Cmd Function *FvwmEvent-MoveWindow: add_window MoveZenity DestroyFunc MoveZenity AddToFunc MoveZenity + I ThisWindow ("zenity") Move -0 -0 

If this still doesn't work (or you decide to get it to work using PositionPlacement), you can try

 BugOpts ExplainWindowPlacement 

Fvwm will then write the debug output to a log file (or to the console, depending on your installation), explaining how it places windows (and why this is done).

Also just fyi, if you want to get window information, you can use the FvwmIdent module to get this information (instead of xprop, although both work fine).

+2
source

Yes, it is definitely possible with the proper help of the window manager. For example, with xmonad this will be one line of code ...

My fvwm is a little rusty, but it seems to be something like:

 Style "zenity" PositionPlacement -0 -0 

in your fvwm2rc should do the trick.

EDIT: pay attention to the lower case "zenity", because, according to the documents, it should correspond not only to the window title, but also to the window class (which you can learn using the "xprop" utility: run it and point to the window in the question).

According to xprop, the zenity window has two interesting properties:

  • It has _NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DIALOG , indicating that this is a dialog box
  • It has WM_TRANSIENT_FOR(WINDOW): window id # <some window id here> , indicating the main window for which this is a dialog (in my case, the xterm window)

So, if my suggestion does not work, then this is almost certainly due to the fact that fvwm handles dialogs in a special way - either because of the configuration, or because of hard-coding behavior.

You can try adding " EWMHIgnoreWindowType " to the zenity window style, which should hope that fvwm ignores these prompts.

+1
source

You can use wmctrl to get windowid and then xdotool to place it where you want. Simple and adaptable to many types of environments.

  ## Arg 1 - Pid of window to move. ## Arg 2 - X-Coord. ## Arg 3 - Y-Coord. function move_win() { xdotool windowmove $(wmctrl -lp | grep ${1} | cut -d' ' -f1) ${2} ${3} } 

eg. $> move_win $(pidof zenity) 0 0

0
source

All Articles