2020-09-22 23:01:19 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Author: Daniel Napora <napcok@gmail.com>
|
|
|
|
# "Show-Hide" terminal wrapper for terminator for use with keybind eg. super + enter.
|
|
|
|
# Depenging on actual state it will start, show or hide terminal window.
|
|
|
|
|
2021-01-20 18:49:37 +01:00
|
|
|
GEOMETRY_FILE="$HOME/.config/mabox/.quake-term"
|
|
|
|
NAME="quake-term"
|
|
|
|
|
|
|
|
__run() {
|
|
|
|
ID=$(wmctrl -x -l | grep ${NAME} | awk '{print $1}' | head -n 1)
|
2020-09-22 23:01:19 +02:00
|
|
|
if [ -z "${ID}" ]; then
|
2021-01-20 18:49:37 +01:00
|
|
|
if [ -f "$GEOMETRY_FILE" ]; then
|
|
|
|
POS=$(head -n 1 $GEOMETRY_FILE)
|
|
|
|
terminator -T ${NAME} -b --geometry "$POS"
|
|
|
|
else
|
2020-09-22 23:01:19 +02:00
|
|
|
TOP=$(wmctrl -d|grep "*"|awk '{print $8}'|cut -d',' -f2)
|
|
|
|
LEFT=$[$(wmctrl -d|grep "*"|awk '{print $4}'|cut -d'x' -f1)/8]
|
|
|
|
HEIGHT=$[$(wmctrl -d|grep "*"|awk '{print $4}'|cut -d'x' -f2)/2]
|
|
|
|
WIDTH=$[${LEFT}*6]
|
2021-01-20 18:49:37 +01:00
|
|
|
terminator -T ${NAME} -b --geometry "${WIDTH}x${HEIGHT}+${LEFT}+${TOP}"
|
|
|
|
fi
|
2020-09-22 23:01:19 +02:00
|
|
|
else
|
|
|
|
ID_DEC=$((${ID}))
|
|
|
|
ACTIVE_WIN_DEC=$(xdotool getactivewindow)
|
|
|
|
if [ "${ACTIVE_WIN_DEC}" == "${ID_DEC}" ]; then
|
|
|
|
xdotool windowminimize ${ID_DEC}
|
|
|
|
else
|
|
|
|
xdotool windowactivate ${ID_DEC}
|
|
|
|
fi
|
|
|
|
fi
|
2021-01-20 18:49:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
__save() {
|
|
|
|
eval $(xdotool getwindowgeometry --shell $(xdotool getactivewindow))
|
2021-02-26 01:26:13 +01:00
|
|
|
echo "${WIDTH}x${HEIGHT}+${X}+${Y}" > $GEOMETRY_FILE
|
2021-01-20 18:49:37 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
__reset() {
|
|
|
|
rm -f $GEOMETRY_FILE
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
save) __save;;
|
|
|
|
reset) __reset;;
|
|
|
|
*) __run;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|