mabox-tools/bin/quake-radio

71 lines
1.8 KiB
Plaintext
Raw Permalink Normal View History

2024-02-16 23:44:14 +01:00
#!/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 <<EOF > ${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"
2024-02-17 09:16:10 +01:00
font = JetBrains Mono NL 9
2024-02-16 23:44:14 +01:00
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)
2024-02-17 09:16:10 +01:00
ONESIXTH=$[$(wmctrl -d|grep "*"|awk '{print $4}'|cut -d'x' -f1)/6]
2024-02-16 23:44:14 +01:00
HEIGHT=$[$(wmctrl -d|grep "*"|awk '{print $4}'|cut -d'x' -f2)/2]
2024-02-17 09:16:10 +01:00
LEFT=$[${ONESIXTH}*5-80]
WIDTH=$[${ONESIXTH}+60]
2024-02-16 23:44:14 +01:00
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