mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2026-01-30 09:48:11 +01:00
Improve window PID discovery in sd script
The current way of finding the PID of the active window is quite fragile due to the extremely loose regex in place. Since xdotool is already a dependency of multiple other scripts I'd recommend just using that.
This commit is contained in:
parent
6c92dfa4eb
commit
033c7f854d
@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
# Open a terminal window in the same directory as the currently active window.
|
# Open a terminal window in the same directory as the currently active window.
|
||||||
|
|
||||||
windowPID=$(xprop -id "$(xprop -root | sed -n "/_NET_ACTIVE_WINDOW/ s/^.*# // p")" | sed -n "/PID/ s/^.*= // p")
|
PIDlist=$(pstree -lpATna "$(xdotool getactivewindow getwindowpid)" | sed -En 's/.*,([0-9]+).*/\1/p' | tac)
|
||||||
PIDlist=$(pstree -lpATna "$windowPID" | sed -En 's/.*,([0-9]+).*/\1/p' | tac)
|
|
||||||
for PID in $PIDlist; do
|
for PID in $PIDlist; do
|
||||||
cmdline=$(ps -o args= -p "$PID")
|
cmdline=$(ps -o args= -p "$PID")
|
||||||
process_group_leader=$(ps -o comm= -p "$(ps -o pgid= -p "$PID" | tr -d ' ')")
|
process_group_leader=$(ps -o comm= -p "$(ps -o pgid= -p "$PID" | tr -d ' ')")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user