Let's say I have the window manager Blackbox running on two different X displays, e.g. :0.0
and :1.0
launched from tty1
and tty2
respectively. From a terminal (emulator), how do I exit (kill) the Blackbox process that uses the current X display? The command killall blackbox
does not fit since it terminates both sessions.
Here is a solution inspired by soubunmei's answer:
#!/bin/sh
ActiveWindowManagerPID()
{
local windowManager="$1"
local windowManagerPIDs="$(pidof "$windowManager")"
local displayNumber="$(echo $DISPLAY \
| awk 'BEGIN { FS = "[:.]" } { print $2 }')"
ps e -p "$windowManagerPIDs" \
| awk -v n="$displayNumber" \
'$0 ~ " DISPLAY=:" n "[\n .]" { print $1 }'
}
kill "$(ActiveWindowManagerPID blackbox)"
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments