#!/bin/bash # Show/hide terminal with pyradio. GEOMETRY_FILE="$HOME/.config/.quake-radio" TERM_CONFIG="$HOME/.config/terminator/transparent" NAME="Quake Radio" __run() { ID=$(wmctrl -x -l | grep "${NAME}" | awk '{print $1}' | head -n 1) if [ -z "${ID}" ]; then if [ ! -f $TERM_CONFIG ]; then cat < ${TERM_CONFIG} [global_config] dbus = False [keybindings] [profiles] [[default]] allow_bold = False background_darkness = 0.0 background_type = transparent cursor_blink = False cursor_color = "#aaaaaa" font = JetBrains Mono NL 9 show_titlebar = False scrollbar_position = hidden scroll_on_keystroke = False use_custom_command = False use_system_font = False [layouts] [plugins] EOF fi if [ -f "$GEOMETRY_FILE" ]; then POS=$(head -n 1 $GEOMETRY_FILE) terminator -b -g "${TERM_CONFIG}" -T "${NAME}" --icon=/usr/share/icons/pyradio.png --geometry "$POS" -e 'pyradio -lt' else TOP=$(wmctrl -d|grep "*"|awk '{print $8}'|cut -d',' -f2) ONESIXTH=$[$(wmctrl -d|grep "*"|awk '{print $4}'|cut -d'x' -f1)/6] HEIGHT=$[$(wmctrl -d|grep "*"|awk '{print $4}'|cut -d'x' -f2)/2] LEFT=$[${ONESIXTH}*5-80] WIDTH=$[${ONESIXTH}+60] terminator -b -g "${TERM_CONFIG}" -T "${NAME}" --icon=/usr/share/icons/pyradio.png --geometry "${WIDTH}x${HEIGHT}+${LEFT}+${TOP}" -e 'pyradio -lt' fi 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 eval $(xdotool getwindowgeometry --shell $(xdotool search --name "${NAME}")) echo "${WIDTH}x${HEIGHT}+${X}+${Y}" > $GEOMETRY_FILE fi } __save() { eval $(xdotool getwindowgeometry --shell $(xdotool search --name "${NAME}")) echo "${WIDTH}x${HEIGHT}+${X}+${Y}" > $GEOMETRY_FILE } __reset() { rm -f $GEOMETRY_FILE } case "$1" in reset) __reset;; *) __run;; esac