2023-04-01 16:23:45 -07:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
if [ $# -ne 2 ]; then
|
|
|
|
echo "Usage: "${0}" <i3_mark> <launch_cmd>"
|
|
|
|
echo "Example: ${0} 'scratch-emacs' 'emacsclient -c -a emacs'"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
I3_MARK=${1}
|
|
|
|
LAUNCH_CMD=${2}
|
|
|
|
|
|
|
|
scratchpad_show() {
|
2023-04-03 14:00:04 -07:00
|
|
|
swaymsg "[con_mark=${I3_MARK}]" scratchpad show
|
2023-04-01 16:23:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
# try showing the scratchpad window
|
|
|
|
if ! scratchpad_show; then
|
|
|
|
# if there is no such window...
|
|
|
|
|
|
|
|
# launch the application.
|
|
|
|
eval "${LAUNCH_CMD}" &
|
|
|
|
|
|
|
|
# Wait for the next window event.
|
2023-04-03 14:00:04 -07:00
|
|
|
swaymsg -t subscribe '[ "window" ]'
|
2023-04-01 16:23:45 -07:00
|
|
|
|
|
|
|
# Set a mark
|
2023-04-03 14:00:04 -07:00
|
|
|
swaymsg mark ${I3_MARK}
|
2023-04-01 16:23:45 -07:00
|
|
|
|
|
|
|
# Move it to the scratchpad workspace
|
2023-04-03 14:00:04 -07:00
|
|
|
swaymsg move scratchpad
|
2023-04-01 16:23:45 -07:00
|
|
|
|
|
|
|
# show the scratchpad window
|
|
|
|
scratchpad_show
|
|
|
|
fi
|