Skip to content

Commit

Permalink
Added flag for centring mouse when activating window
Browse files Browse the repository at this point in the history
  • Loading branch information
Jānis Mezītis committed Jan 29, 2018
1 parent 9356ca0 commit f02039f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions jumpapp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ Options:
-t NAME -- process window has to have NAME as the window title
-c NAME -- find window using NAME as WM_CLASS (instead of COMMAND)
-i NAME -- find process using NAME as the command name (instead of COMMAND)
-w -- only find the applications in the current workspace"
-w -- only find the applications in the current workspace
-m -- move cursor to the middle of raising application (xdotool needed)"
}

main() {
local classid cmdid force fork=1 list passthrough in_reverse matching_title workspace_filter
local classid cmdid force fork=1 list passthrough in_reverse matching_title workspace_filter mouse_center

local OPTIND
while getopts c:fhi:Lnprt:w opt; do
while getopts c:fhi:Lnprt:wm opt; do
case "$opt" in
c) classid="$OPTARG" ;;
f) force=1 ;;
Expand All @@ -36,6 +37,8 @@ main() {
r) in_reverse=1 ;;
t) matching_title="$OPTARG"; force=1 ;;
w) workspace_filter="$(get_active_workspace)"; force=1 ;;
m) mouse_center=1 ;;

esac
done
shift $(( OPTIND - 1 ))
Expand Down Expand Up @@ -349,7 +352,12 @@ get_active_workspace() {
}

activate_window() {
wmctrl -i -a "$1"
WID=$( echo "$1" | head -1 )
wmctrl -i -a "$WID"
if [ -n "$mouse_center" ]; then
# move cursor to middle of application
xdotool mousemove -w "$WID" $(wmctrl -lG | grep "$WID" | awk '{ print $5/2 " " $6/2 }')
fi
}

has_command() {
Expand Down

0 comments on commit f02039f

Please sign in to comment.