-
Notifications
You must be signed in to change notification settings - Fork 0
Running Processes
Goal: To provide an overview of the running processes on the device including process name and process id.
This will give the opened windows when on linux distro for xWin. This in combination with
-
xprop -id %window id% (sth like 0x600052% | grep _NET_WM_PID | cut -d'=' -f2 | grep -oP "^\K.*"
will return the main PID of the application. -
xwininfo -tree -root | grep -w -o "0x[0-9a-zA-Z]*
will give all window ids
Running it from terminal
bash nameofscriptbelow.sh
Script Code
#!/bin/sh
known_windows=$(xwininfo -tree -root | grep -w -o "0x[0-9a-zA-Z]*")
for windowid in ${known_windows}
do
#echo "$windowid"
if ! [ "$windowid" == "0x0" ]; then
pid=$(xprop -id $windowid | grep _NET_WM_PID | cut -d'=' -f2)
if ! [ "x$pid" == "x" ]; then
windowidlength=$(printf "%s" "$windowid" | wc -c)
if [ $windowidlength -gt 4 ]; then
title=$(xprop -id $windowid | grep _NET_WM_NAME | cut -d'=' -f2)
process=$(ps -waux | grep $pid | grep -v grep | awk '{ print $11 }')
echo "windowId: $windowid |; processId: $pid |; processName: $process |; windowTitle: $title"
fi
fi
fi
done
Output
For each window that gets fetched the script will produce the following output:
windowId: 0x3000001 |; processId: 2033 |; processName: /usr/share/code/code /usr/share/code/code /usr/share/code/code |; windowTitle: "get_namesandprocesses.sh - Documents - Visual Studio Code"
This will give the running 'commands' on the machine
This will onlu print the command (short names) and the process id attached to it
nodejs package node-window-listing
Image Name | PID | Session Name | Session# | Mem Usage | User Name | CPU Time | Window Title |
---|---|---|---|---|---|---|---|
string |
number |
string |
number |
number string
|
string |
time (*1) |
string |
(*1)time
: number
:number
:number
(e.g.: 0:01:56
).
Same as above, but in a list format.