Fix launch workspace script

This commit is contained in:
Thomas Avé 2025-02-27 13:31:41 +01:00
parent 722b0b68d5
commit 6740f1bdb7
1 changed files with 9 additions and 7 deletions

View File

@ -30,15 +30,17 @@ let
launch_terminal = pkgs.writeShellScriptBin "launch_terminal" '' launch_terminal = pkgs.writeShellScriptBin "launch_terminal" ''
function find_leaf_pid(){ function find_leaf_pid(){
local PID=$1 local PID
local CHILD_PID=$(pgrep -P "$PID") local RET
if [ "$CHILD_PID" != "" ]; then local NAME
local RET=$(find_leaf_pid "$CHILD_PID") PID=$1
for CHILD_PID in $(pgrep -P "$PID"); do
RET=$(find_leaf_pid "$CHILD_PID")
if [ "$RET" != "" ]; then if [ "$RET" != "" ]; then
PID=$RET PID="$RET"
fi fi
fi done
local NAME=$(ps -p "$PID" -o comm=) NAME=$(ps -p "$PID" -o comm=)
if [ "$NAME" == "zsh" ]; then if [ "$NAME" == "zsh" ]; then
echo "$PID" echo "$PID"
elif [ "$NAME" == "ssh" ]; then elif [ "$NAME" == "ssh" ]; then