Skip to content

Instantly share code, notes, and snippets.

@neeasade
Last active February 6, 2018 14:12
Show Gist options
  • Save neeasade/c268a4587c5a9e739524 to your computer and use it in GitHub Desktop.
Save neeasade/c268a4587c5a9e739524 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# depends: dmenu slop xdotool
# assumes next spawned window will be floating/moveable by xdotool.
# get program name to launch using dmenu cache:
cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"}
if [ -d "$cachedir" ]; then
cache=$cachedir/dmenu_run
else
cache=$HOME/.dmenu_cache # if no xdg dir, fall back to dotfile in ~
fi
program=$(
IFS=:
if stest -dqr -n "$cache" $PATH; then
stest -flx $PATH | sort -u | tee "$cache" | dmenu "$@"
else
dmenu "$@" < "$cache"
fi
)
# Set dimension vars with slop
eval `slop`
# Get current window
win=`xdotool getactivewindow`
# bspwm specific, force next floating:
bspc rule -a \* --one-shot floating=true
$program &
# Wait for window to spawn and move with xdotool.
newwin=$win
while [ "$newwin" = "$win" ]; do
newwin=`xdotool getactivewindow`
done
xdotool windowmove $newwin $X $Y
xdotool windowsize $newwin $W $H
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment