Skip to content

Instantly share code, notes, and snippets.

@scovl
Forked from neeasade/slopspawn.sh
Created September 24, 2015 11:51
Show Gist options
  • Save scovl/67f5d782f3addfba5d91 to your computer and use it in GitHub Desktop.
Save scovl/67f5d782f3addfba5d91 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`
$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