Last active
February 6, 2018 14:12
-
-
Save neeasade/c268a4587c5a9e739524 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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
https://www.reddit.com/r/unixporn/comments/3m58zw/script_wm_independent_slop_program_spawn/