Drop-down or actually show-hide terminal

A drop-down terminal can be very handy sometimes. In Mabox, the default terminal emulator is Terminator, which does not have such functionality.
So I added a little wrapper – mabox-terminal – which is binded to the Ctrl-Grave key combination.
It’s not actually a drop-down terminal, it’s more of a show-hide.

There is a Terminator underneath so we have all its functionalities available like window splitting: Ctrl-Shift-O (vertically) Ctrl-Shift-E (horizontally). Use Alt-Arrow to move between terminals. F11 – toogle full screen.

This wrapper is a simple bash script – if you want to adapt it to your needs, just copy it to the ~/bin directory and edit it there:

cp /usr/bin/mabox-terminal ~/bin/

Wrapper script:

#!/bin/bash
# "Show-Hide" terminal wrapper for terminator for use with keybind eg. super + enter.
# Depending on actual state it will start, show or hide terminal window.

ID=$(wmctrl -x -l | grep mabox-terminal | awk '{print $1}' | head -n 1)
if [ -z "${ID}" ]; then
	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]
	terminator -T mabox-terminal -b --geometry "${WIDTH}x${HEIGHT}+${LEFT}+${TOP}"
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

Dependencies: wmctrl and xdotool

I haven’t tested that, but it seems that the script can be easily adapted to the use of other terminals and not only in Mabox or OpenBox.