Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard shortcut should activate the terminal if unfocused but visible #241

Open
thiagoa opened this issue Jul 13, 2020 · 0 comments
Open

Comments

@thiagoa
Copy link

thiagoa commented Jul 13, 2020

Due to the principle of least surprise (in my opinion), if the terminal is unfocused but visible the default keyboard shortcut should simply activate it. To make it work like that in the meantime, I've unset the default keyboard shortcut and associated a custom keyboard shortcut through Gnome using the following bash script:

#!/bin/bash

is_open=$(wmctrl -l -x | grep 'Drop Down Terminal.DropDownTerminalWindow')
wm_id=$(xdotool getactivewindow)
wm_class=$(xprop -id "$wm_id" | grep WM_CLASS)
is_focused=$(echo $wm_class | grep DropDownTerminal)

function send_command {
  dbus-send --type=method_call \
            --dest=org.zzrough.GsExtensions.DropDownTerminal \
            /org/zzrough/GsExtensions/DropDownTerminal \
            org.zzrough.GsExtensions.DropDownTerminal.$1
}

if [[ ! -z "$is_open" ]] && [[ -z "$is_focused" ]]; then
  send_command Focus
else
  send_command Toggle
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant