reduce indent to 2 spaces

This commit is contained in:
2022-08-27 13:58:34 +02:00
parent 998e13f71a
commit 888c9f4dbb

View File

@@ -13,36 +13,36 @@ out = shexec('xdpyinfo').split('\n')
############ GET FOCUSED WINDOW ID ##############
window = -1
for l in out:
if l.startswith('focus:'):
for field in l.split(' '):
field = field.rstrip(',')
if(field.startswith('0x')):
window = int(field,16)
if window == -1:
error("Failed to get window_focus\n")
if l.startswith('focus:'):
for field in l.split(' '):
field = field.rstrip(',')
if(field.startswith('0x')):
window = int(field,16)
if window == -1:
error("Failed to get window_focus\n")
if window==-1:
sys.exit()
sys.exit()
############ IF URXVT GET PID ###########
pid = -1
out = subprocess.check_output(['xprop','-id',hex(window)]).decode().split('\n')
#out = shexec('xprop -id '+hex(window)).split('\n') #not working
for l in out:
if l.startswith('WM_CLASS(STRING)') and 'urxvt' in l:
break;
if l.startswith('WM_CLASS(STRING)') and 'urxvt' in l:
break;
else:
sys.exit();
sys.exit();
for l in out:
if l.startswith('_NET_WM_PID(CARDINAL)'):
pid = int(l.split(' ')[-1])
if l.startswith('_NET_WM_PID(CARDINAL)'):
pid = int(l.split(' ')[-1])
if pid==-1:
error("Failed to get PID")
error("Failed to get PID")
############ START NEW TERMINAL ############
process = psutil.Process(pid)
for p in process.children(): #recursive=false
if p.name() in ['zsh','bash']:
subprocess.Popen(shlex.split('urxvt -cd ' + p.cwd()))
break
if p.name() in ['zsh','bash']:
subprocess.Popen(shlex.split('urxvt -cd ' + p.cwd()))
break
sys.exit()