The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
3

How do I automatically send SIGSTOP to workspace apps when switching away from a workspace?

asked 2013-08-22 09:12:31 +0000

lkraav gravatar image

updated 2013-08-22 18:37:12 +0000

I read somewhere in i3bar documentation or code or whatnot that it automatically sends SIGSTOP to i3status when in hidden mode. I think that's wonderful and would like to have the same thing for some background Wine apps that hammer the CPU when I don't need them to (hello Picasa 3).

So when I switch away from workspace 4, SIGSTOP should be sent to x+1 processes. When I switch back to workspace 4, SIGCONT is sent sent to x+1 processes.

Any suggestions?

edit retag flag offensive close merge delete

Comments

I know that endre and Merovius from #i3 have scripts to do this for firefox.

Michael gravatar imageMichael ( 2013-08-27 06:53:57 +0000 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2014-09-10 22:12:54 +0000

You can subscribe to workspace event with IPC. Whenever you catch the workspace focus event do the following:

  1. Remember the id of old workspace.
  2. Send GET_TREE.
  3. For each container in old workspace:
    1. Get the container's client X11 window ID (window in the TREE reply).
    2. Query the _NET_WM_PID with xprop.
    3. Send SIGSTOP to that pid.

This is a simplified algorithm which doesn't take setups with multiple monitors into account, but I think an additional check against WORKSPACES reply will do the trick.

Of course you'll have to send SIGCONT to windows on current workspace analogously.

edit flag offensive delete link more

Comments

Looks plausible, thanks!

lkraav gravatar imagelkraav ( 2014-09-11 07:08:36 +0000 )edit

Question Tools

4 followers

Stats

Asked: 2013-08-22 09:12:31 +0000

Seen: 517 times

Last updated: Sep 10 '14