Cleanup bspwm support scripts
This commit is contained in:
parent
11155e2fe6
commit
91c7ebd467
3 changed files with 33 additions and 94 deletions
33
.config/bspwm/focus-voip.py
Executable file
33
.config/bspwm/focus-voip.py
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import subprocess
|
||||
from functools import partial
|
||||
|
||||
|
||||
cmd_run = partial(subprocess.Popen, text=True, shell=True)
|
||||
|
||||
def cmd_output(cmd):
|
||||
try:
|
||||
out = subprocess.check_output(cmd, text=True, shell=True).strip()
|
||||
except Exception:
|
||||
out = ''
|
||||
return out
|
||||
|
||||
def execute(cmd):
|
||||
popen = subprocess.Popen(cmd, stdout=subprocess.PIPE,
|
||||
universal_newlines=True, text=True, shell=True)
|
||||
for stdout_line in iter(popen.stdout.readline, ''):
|
||||
yield stdout_line
|
||||
popen.stdout.close()
|
||||
return_code = popen.wait()
|
||||
if return_code:
|
||||
raise subprocess.CalledProcessError(return_code, cmd)
|
||||
|
||||
if __name__ == '__main__':
|
||||
for event in execute('bspc subscribe node'):
|
||||
event = event.split()
|
||||
if event[0] == 'node_remove' or event[0] == 'node_transfer':
|
||||
if cmd_output('bspc query -D --names -d ' + event[2]) == 'side-view':
|
||||
if cmd_output('bspc query -N -d side-view') == '':
|
||||
cmd_run('bspc desktop voip -f')
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue