Skip to content

Instantly share code, notes, and snippets.

@TimboKZ
Last active March 1, 2023 23:52
Show Gist options
  • Save TimboKZ/d05bda63f7f818fdc20c3afa3f6a624d to your computer and use it in GitHub Desktop.
Save TimboKZ/d05bda63f7f818fdc20c3afa3f6a624d to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Get the command from arguments
arg_str="$*"
$arg_str &
pid="$!"
# Wait for the window to open and grab its window ID
winid=''
while : ; do
winid="`wmctrl -lp | awk -vpid=$pid '$3==pid {print $1; exit}'`"
[[ -z "${winid}" ]] || break
done
# Focus the window we found
wmctrl -ia "${winid}"
# Make it float
i3-msg floating enable > /dev/null;
# Move it to the center for good measure
i3-msg move position center > /dev/null;
# Wait for the application to quit
wait "${pid}";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment