Skip to content

Instantly share code, notes, and snippets.

@jkpl
Created September 12, 2015 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkpl/01226bfc7006e920a631 to your computer and use it in GitHub Desktop.
Save jkpl/01226bfc7006e920a631 to your computer and use it in GitHub Desktop.
Script for showing/hiding KeepassX window. Bind to a global shortcut for max power.
#!/bin/sh -e
function xdokeepassx {
xdotool search --maxdepth 3 --classname keepassx $@
}
function show_keepassx {
local desktop="`xdotool get_desktop`"
xdokeepassx \
set_desktop_for_window %@ $desktop \
windowactivate %@ \
> /dev/null 2>&1
}
function hide_keepassx {
xdokeepassx windowminimize %@ > /dev/null 2>&1
}
function is_keepassx_shown {
local active_id="`xdotool getactivewindow`"
xdokeepassx | grep -F $active_id > /dev/null 2>&1
}
if is_keepassx_shown; then
hide_keepassx
else
show_keepassx
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment