#!/bin/bash # checks if instance of arg 1 exists, will show it if it does exists=$(i3-msg "[instance=$1] scratchpad show" 2>&1 | grep ERROR) if [ -n "$exists" ] ; then # creating it then showing if [ -z "$1" ] ; then echo "Missing class in arg 1" >&2 exit 1 elif [ -z "$2" ] ; then echo "Missing command to launch application in arg 2" >&2 exit 1 fi # runs remaining commands and shows ${@:2} 2>&1 1>/dev/null & sleep 1 # lets application load then shows it on scratchpad i3-msg "[instance=$1] scratchpad show" 1>/dev/null fi