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" ''
function find_leaf_pid(){
local PID=$1
local CHILD_PID=$(pgrep -P "$PID")
if [ "$CHILD_PID" != "" ]; then
local RET=$(find_leaf_pid "$CHILD_PID")
local PID
local RET
local NAME
PID=$1
for CHILD_PID in $(pgrep -P "$PID"); do
RET=$(find_leaf_pid "$CHILD_PID")
if [ "$RET" != "" ]; then
PID=$RET
PID="$RET"
fi
fi
local NAME=$(ps -p "$PID" -o comm=)
done
NAME=$(ps -p "$PID" -o comm=)
if [ "$NAME" == "zsh" ]; then
echo "$PID"
elif [ "$NAME" == "ssh" ]; then