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 Aug 22 '13

lkraav gravatar image

updated Aug 22 '13

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?

Comments

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

Michael gravatar imageMichael (Aug 27 '13)edit

1 answer

Sort by » oldest newest most voted
2

answered Sep 10 '14

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.

Comments

Looks plausible, thanks!

lkraav gravatar imagelkraav (Sep 11 '14)edit

Question Tools

4 followers

Stats

Asked: Aug 22 '13

Seen: 516 times

Last updated: Sep 10 '14