Skip to main content
Add syntax hints
Source Link
AdminBee
  • 23.6k
  • 25
  • 55
  • 77

For example, getting the title of konsole window current interactive bash instance is running in:

#!/bin/bash get_title() { local pid=$$ local pids=`pstree -lpsT $pid | tr '-' '\n' | tac | xargs | grep -oE '[0-9]+'` for pid in $pids do local wid=`xdotool search --pid $pid` if [ ! -z "${wid}" ] then echo `xdotool getwindowname $wid` exit fi done } get_title 
#!/bin/bash get_title() { local pid=$$ local pids=`pstree -lpsT $pid | tr '-' '\n' | tac | xargs | grep -oE '[0-9]+'` for pid in $pids do local wid=`xdotool search --pid $pid` if [ ! -z "${wid}" ] then echo `xdotool getwindowname $wid` exit fi done } get_title 

For example, getting the title of konsole window current interactive bash instance is running in:

#!/bin/bash get_title() { local pid=$$ local pids=`pstree -lpsT $pid | tr '-' '\n' | tac | xargs | grep -oE '[0-9]+'` for pid in $pids do local wid=`xdotool search --pid $pid` if [ ! -z "${wid}" ] then echo `xdotool getwindowname $wid` exit fi done } get_title 

For example, getting the title of konsole window current interactive bash instance is running in:

#!/bin/bash get_title() { local pid=$$ local pids=`pstree -lpsT $pid | tr '-' '\n' | tac | xargs | grep -oE '[0-9]+'` for pid in $pids do local wid=`xdotool search --pid $pid` if [ ! -z "${wid}" ] then echo `xdotool getwindowname $wid` exit fi done } get_title 
added 218 characters in body
Source Link

For example, getting the title of konsole window current interactive bash instance is running in:

#!/bin/bash pppid=`psget_title() { local pid=$$ local pids=`pstree -olpsT ppid=$pid | tr '-p' $PPID`'\n' | tac | xargs | grep -oE '[0-9]+'` echo   "pppid: $pppid" for pid in $pids  do  local wid=`xdotool search --pid $pppid`$pid` echo "wid: $wid" if [ ! -z "${wid}" ]  then title=`xdotool  echo `xdotool getwindowname $wid` echo "title: $title" exit fi done } get_title 

For example, getting the title of konsole window current interactive bash instance is running in:

#!/bin/bash pppid=`ps -o ppid= -p $PPID` echo "pppid: $pppid" wid=`xdotool search --pid $pppid` echo "wid: $wid" title=`xdotool getwindowname $wid` echo "title: $title" 

For example, getting the title of konsole window current interactive bash instance is running in:

#!/bin/bash get_title() { local pid=$$ local pids=`pstree -lpsT $pid | tr '-' '\n' | tac | xargs | grep -oE '[0-9]+'`     for pid in $pids  do  local wid=`xdotool search --pid $pid`  if [ ! -z "${wid}" ]  then   echo `xdotool getwindowname $wid`  exit fi done } get_title 
Source Link

For example, getting the title of konsole window current interactive bash instance is running in:

#!/bin/bash pppid=`ps -o ppid= -p $PPID` echo "pppid: $pppid" wid=`xdotool search --pid $pppid` echo "wid: $wid" title=`xdotool getwindowname $wid` echo "title: $title"