Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Calling command when minimizing/restoring X application
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo Chat
View previous topic :: View next topic  
Author Message
SnEptUne
l33t
l33t


Joined: 23 Aug 2004
Posts: 653

PostPosted: Sat Jun 09, 2018 4:29 pm    Post subject: Calling command when minimizing/restoring X application Reply with quote

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
View user's profile Send private message
R0b0t1
Apprentice
Apprentice


Joined: 05 Jun 2008
Posts: 255

PostPosted: Sun Jun 10, 2018 5:55 am    Post subject: Reply with quote

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
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 6814

PostPosted: Sun Jun 10, 2018 10:39 am    Post subject: Reply with quote

I'm not totally sure, but i think compiz do that no?
Back to top
View user's profile Send private message
SnEptUne
l33t
l33t


Joined: 23 Aug 2004
Posts: 653

PostPosted: Sun Jun 10, 2018 12:44 pm    Post subject: Reply with quote

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
View user's profile Send private message
R0b0t1
Apprentice
Apprentice


Joined: 05 Jun 2008
Posts: 255

PostPosted: Sun Jun 10, 2018 10:22 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo Chat All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum