View previous topic :: View next topic |
Author |
Message |
SnEptUne l33t
Joined: 23 Aug 2004 Posts: 656
|
Posted: Sat Jun 09, 2018 4:29 pm Post subject: Calling command when minimizing/restoring X application |
|
|
Does anyone know whether there is a desktop environment that let you execute a command on the X11 process when you minimize or restore the GUI application? _________________ "There will be more joy in heaven over the tear-bathed face of a repentant sinner than over the white robes of a hundred just men." (LM, 114) |
|
Back to top |
|
|
R0b0t1 Apprentice
Joined: 05 Jun 2008 Posts: 264
|
Posted: Sun Jun 10, 2018 5:55 am Post subject: |
|
|
I'm not aware of a program that can do this out of the box. At some point I was actually trying to write my own.
For scripting you can use xev with the -id flag to watch all events to a window. The ID can be obtained with xwininfo. Check for reception of _NET_WM_STATE and look for any of the flags _NET_WM_STATE_HIDDEN, _NET_WM_STATE_MAXIMIZED_VERT, or _NET_WM_STATE_MAXIMIZED_HORZ. There will likely be other events you will be interested in. You can look at the structure of a program like sxhkd for how to map matched events to an action. |
|
Back to top |
|
|
krinn Watchman
Joined: 02 May 2003 Posts: 7470
|
Posted: Sun Jun 10, 2018 10:39 am Post subject: |
|
|
I'm not totally sure, but i think compiz do that no? |
|
Back to top |
|
|
SnEptUne l33t
Joined: 23 Aug 2004 Posts: 656
|
Posted: Sun Jun 10, 2018 12:44 pm Post subject: |
|
|
Thanks, xev and xwininfo seems to do what I want, but I have to point my mouse to the windows to get the windows id. Is there a way to automate the retrieve of windowid by pid? xdotool search --pid $PID doesn't seem to do what it claims to do, it returns a list of numbers. _________________ "There will be more joy in heaven over the tear-bathed face of a repentant sinner than over the white robes of a hundred just men." (LM, 114) |
|
Back to top |
|
|
R0b0t1 Apprentice
Joined: 05 Jun 2008 Posts: 264
|
Posted: Sun Jun 10, 2018 10:22 pm Post subject: |
|
|
krinn wrote: | I'm not totally sure, but i think compiz do that no? | Compiz needs to know about them to apply the compositing effects, yes.
SnEptUne wrote: | Thanks, xev and xwininfo seems to do what I want, but I have to point my mouse to the windows to get the windows id. Is there a way to automate the retrieve of windowid by pid? xdotool search --pid $PID doesn't seem to do what it claims to do, it returns a list of numbers. | All of the returned windows are associated with the process. You'll need some other way to figure out which is the main window. You should use classname and inspect the other properties of the window, namely _NET_WM_WINDOW_TYPE for _NET_WM_WINDOW_TYPE_NORMAL.
Keep in mind that applications can use X11's facilities in atrange ways or not at all. For example: Code: | for p in $(xdotool search --class 'firefox'); do
name=$(xdotool getwindowname "$p")
if [[ "$name" == "Firefox" ]]; then
echo "Match."
fi
done
|
Firefox is a particularly good demonstration as it creates a lot of fake windows. Some other programs do similar or even stranger things. The best thing to watch is the window manager styles and hints. I.e. is this a tool window, a GUI popup, or a main application window?
You can check these with xwininfo. |
|
Back to top |
|
|
|