Another example how I use the script above
Forked Popup/Quake style terminal using the hey command
to use winpwnr.sh, the Terminal will fit the upper half of screen, while not active will be moved upward showing only a thin area, click on that area to make the window active again and bring back the Terminal
#!/bin/sh
### the unique window title prefix for our terminal session
terminalKeyword="QuakeTerm"
### optionally set the location of a custom terminal profile to be used
### it must contain whatever is used as the terminalKeyword at the beginning of the "Window title"
### for example: "Window title" , "QuakeTerm %i: %t"
# terminalProfile="/boot/home/config/non-packaged/apps/MyCustomTerminal"
### watch and minimize the window even if it was activated by Deskbar/twitcher/....
### otherwise only auto-hide if it's been activated by this script
### comment out the line to disable
continuousWatch=1
### how frequently should we check the status of the window
### lower numbers give faster response and can be decimal numbers like 0.5,1.5,2.2,...
watcherSleepTime=1
move_by=$(hey Tracker get Frame of Window 0 | awk '/result/{sub(/...$/,"");print ($7+1)/2-10}')
### function to find the process ID of our custom terminal session
function findTerminalSession() {
QTERMPID=-99
for i in `roster | fgrep /apps/Terminal | awk '{ print $1 }'`;do
title=`hey -o $i get Title of Window 0 | grep "^${terminalKeyword}"`
if [ -n "${title}" ];then
QTERMPID=$i
break
fi
done
}
### initial check to see if we're already running
findTerminalSession
if [ ${QTERMPID} -lt 0 ];then
### no existing terminal session, start a new one
if [ -n "${terminalProfile}" ];then
open "${terminalProfile}"
else
/boot/system/apps/Terminal -t "${terminalKeyword}" &
fi
### loop a few times to give the terminal process time to start before giving up
for i in {1..6};do
findTerminalSession
if [ ${QTERMPID} -gt 0 ];then
break;
elif [ ${i} -eq 6 ];then
### last time through the loop and we haven't found our terminal
alert --stop "Error finding custom Terminal process"
exit 1
else
sleep 1
fi
done
### disable the fullscreen button in the tabbar
hey ${QTERMPID} set Enabled of View 1 of View 1 of Window 0 to false
### resize and then hide the menubar
### extract our current BRect(left,top,right,bottom) frame and replace the fourth number with 0.0
menuFrame=`hey ${QTERMPID} get Frame of View 0 of Window 0 | grep -o 'BRect(.*)$' | sed 's/[0-9]\+.[0-9]\+/0.0/4'`
hey ${QTERMPID} set Frame of View 0 of Window 0 to "${menuFrame}"
hey ${QTERMPID} set Hidden of View 0 of Window 0 to true
### resize the tabview to take up the empty menubar space
### extract our current BRect(left,top,right,bottom) frame and replace the second number with 0.0
tabFrame=`hey ${QTERMPID} get Frame of View 1 of Window 0 | grep -o 'BRect(.*)$' | sed 's/[0-9]\+.[0-9]\+/0.0/2'`
hey ${QTERMPID} set Frame of View 1 of Window 0 to "${tabFrame}"
# shows Terminal on all workspaces, w/o tab only borders, not resizable, movable, minimizable or zoomable, shown in the upper half of the screen not overlapping the Deskbar
winpwnr.sh -a Terminal -s ${terminalKeyword} -d -H 8 -w all -G nm,nr,nb,nz -L b
startWatcher=1
fi
if [ -n "${startWatcher}" ];then
was_active="true"
while true;do
### check to see if our window is inactive but still showing
active=`hey -o ${QTERMPID} get Active of Window 0`
if [ "${active}" == "false" ] && [ "${was_active}" == "true" ]
then
# when the window is not active it will be moved upward showing a small clickable area of 10x10
winpwnr.sh -a Terminal -s ${terminalKeyword} -p 0,-${move_by}
was_active="false"
[ -z "${continuousWatch}" ] && exit
else
if [ "${active}" == "true" ] && [ "${was_active}" == "false" ]
then
# when the window is active again will be moved downward
winpwnr.sh -a Terminal -s ${terminalKeyword} -p 0,${move_by}
was_active="true"
fi
[ -z "${active}" ] && exit
sleep ${watcherSleepTime}
fi
done
fi