Skip to content

Instantly share code, notes, and snippets.

@rsdy
Created September 14, 2015 01:05
Show Gist options
  • Save rsdy/c54888514d41ca592784 to your computer and use it in GitHub Desktop.
Save rsdy/c54888514d41ca592784 to your computer and use it in GitHub Desktop.
Stops a process by name if switched away from workspace
#!/usr/bin/env python3
import i3ipc
from sh import pkill
WNAME='browser'
PNAME='firefox'
def on_workspace(i3, e):
if e.current.props.name == WNAME:
pkill('-CONT', PNAME)
else:
pkill('-STOP', PNAME)
i3 = i3ipc.Connection()
i3.on('workspace::focus', on_workspace)
i3.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment