mirror of
https://github.com/FAUSheppy/config
synced 2025-12-06 23:21:34 +01:00
reduce indent to 2 spaces
This commit is contained in:
@@ -13,36 +13,36 @@ out = shexec('xdpyinfo').split('\n')
|
|||||||
############ GET FOCUSED WINDOW ID ##############
|
############ GET FOCUSED WINDOW ID ##############
|
||||||
window = -1
|
window = -1
|
||||||
for l in out:
|
for l in out:
|
||||||
if l.startswith('focus:'):
|
if l.startswith('focus:'):
|
||||||
for field in l.split(' '):
|
for field in l.split(' '):
|
||||||
field = field.rstrip(',')
|
field = field.rstrip(',')
|
||||||
if(field.startswith('0x')):
|
if(field.startswith('0x')):
|
||||||
window = int(field,16)
|
window = int(field,16)
|
||||||
if window == -1:
|
if window == -1:
|
||||||
error("Failed to get window_focus\n")
|
error("Failed to get window_focus\n")
|
||||||
if window==-1:
|
if window==-1:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
############ IF URXVT GET PID ###########
|
############ IF URXVT GET PID ###########
|
||||||
pid = -1
|
pid = -1
|
||||||
out = subprocess.check_output(['xprop','-id',hex(window)]).decode().split('\n')
|
out = subprocess.check_output(['xprop','-id',hex(window)]).decode().split('\n')
|
||||||
#out = shexec('xprop -id '+hex(window)).split('\n') #not working
|
#out = shexec('xprop -id '+hex(window)).split('\n') #not working
|
||||||
for l in out:
|
for l in out:
|
||||||
if l.startswith('WM_CLASS(STRING)') and 'urxvt' in l:
|
if l.startswith('WM_CLASS(STRING)') and 'urxvt' in l:
|
||||||
break;
|
break;
|
||||||
else:
|
else:
|
||||||
sys.exit();
|
sys.exit();
|
||||||
|
|
||||||
for l in out:
|
for l in out:
|
||||||
if l.startswith('_NET_WM_PID(CARDINAL)'):
|
if l.startswith('_NET_WM_PID(CARDINAL)'):
|
||||||
pid = int(l.split(' ')[-1])
|
pid = int(l.split(' ')[-1])
|
||||||
if pid==-1:
|
if pid==-1:
|
||||||
error("Failed to get PID")
|
error("Failed to get PID")
|
||||||
|
|
||||||
############ START NEW TERMINAL ############
|
############ START NEW TERMINAL ############
|
||||||
process = psutil.Process(pid)
|
process = psutil.Process(pid)
|
||||||
for p in process.children(): #recursive=false
|
for p in process.children(): #recursive=false
|
||||||
if p.name() in ['zsh','bash']:
|
if p.name() in ['zsh','bash']:
|
||||||
subprocess.Popen(shlex.split('urxvt -cd ' + p.cwd()))
|
subprocess.Popen(shlex.split('urxvt -cd ' + p.cwd()))
|
||||||
break
|
break
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|||||||
Reference in New Issue
Block a user