Created
February 18, 2020 15:04
-
-
Save 73/40b1863dcac0770351ccbe799d8bcd04 to your computer and use it in GitHub Desktop.
Workspace-aware on-demand terminal window (x11 only)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
_cmd="gnome-terminal" | |
_terminal="usr/libexec/gnome-terminal" | |
_current_workspace=$(wmctrl -d | grep -Po "^[\d]+(?= \*)") | |
_windows=$(wmctrl -lp | awk '{ if ($2 == cws) print $1,$3 }' cws="${_current_workspace}" ) | |
_active_win=$(xprop -root _NET_ACTIVE_WINDOW | sed 's/.* //') | |
echo "${_windows}" | while read _window | |
do | |
# echo "${_window}" | |
_desc=($_window) | |
# echo "${_desc[0]}" | |
if readlink -f "/proc/${_desc[1]}/exe" | grep -q "$_terminal" | |
then | |
if [ $(printf "%d" ${_active_win}) -eq $(printf "%d" ${_desc[0]}) ] | |
then | |
if [ $(echo "${_windows}" | wc -l) != 1 ] | |
then | |
xdotool getactivewindow windowminimize | |
else | |
xdotool getactivewindow windowkill | |
fi | |
else | |
wmctrl -ia "${_desc[0]}" | |
fi | |
exit 73 | |
fi | |
done | |
if [ $? != 73 ] | |
then | |
eval "$_cmd" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment