-
-
Save kden416/30c7d888cbc95e6d8d03d98e80c2deec to your computer and use it in GitHub Desktop.
Toggle your GNOME Terminal window with a keyboard shortcut under Linux.
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 | |
function toggle_terminal () { | |
Terminal_Window_ID=`xdotool search --all --onlyvisible --classname gnome-terminal` | |
# echo $Terminal_Window_ID | |
if [[ -z "$Terminal_Window_ID" ]] | |
then | |
gnome-terminal --working-directory="/home/$USER" | |
else | |
Active_Window_ID=`xdotool getactivewindow` | |
if [[ "$Terminal_Window_ID" == "$Active_Window_ID" ]] | |
then | |
xdotool windowminimize ${Terminal_Window_ID} | |
else | |
# Uncomment the following two lines | |
# if the Terminal is not set to be visible on all Workspaces | |
# | |
# Active_Desktop_ID=`xdotool get_desktop` | |
# xdotool set_desktop_for_window ${Terminal_Window_ID} ${Active_Desktop_ID} | |
# | |
xdotool windowraise ${Terminal_Window_ID} | |
xdotool windowfocus ${Terminal_Window_ID} | |
fi | |
fi | |
} | |
toggle_terminal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment