Wait until the window appears and then send it to the original workspace:
#!/bin/bash
activeworkspace=$(i3-msg -t get_workspaces | jq -c '.[] | select(.focused) | .name' --raw-output)
atom &
windowname=atom
xprop -spy -root _NET_ACTIVE_WINDOW | \
while read line ; do
if xprop WM_CLASS -id ${line##* } | grep -q $windowname ; then
i3-msg move "[con_id=\"${line##* }\"]" $activeworkspace
exit
fi
done
- At first get the active workspace, use `jq` as an example
- run your program in the background: `atom &`
- Use `xprop -spy` to 'Examine window properties forever, looking for property change events.'
- Act on all new active windows with `while read line`
- Get WM_CLASS of them with `xprop WM_CLASS`, extract the windowid with bash `${line##* }`
- Filter with `grep $windowname`
- Move the window to the original workspace with `i3-msg move ..`
You should stay on the active workspace and a window on this workspace should get focused.
It doesn't work when you have multiple atom windows which get focused between the start and the move of a new atom window. In this case you would have to look for the NET_WM_PID atom instead of WM_CLASS.