helm/bin/scratch

27 lines
785 B
Plaintext
Raw Normal View History

#!/usr/bin/env bash
SCRID=scratch
CMD=${1:-'tmux new-session -A -s scratch -n scratch'}
focused=$(xdotool getactivewindow)
scratch=$(xdotool search --onlyvisible --classname $SCRID)
if [[ -n $scratch ]]; then
if [[ $focused == $scratch ]]; then
xdotool windowkill $scratch
else
xdotool windowactivate $scratch
fi
elif command -v alacritty >/dev/null; then
alacritty --class $SCRID \
-e $SHELL -c "$CMD"
elif command -v urxvt >/dev/null; then
urxvt -name $SCRID \
2020-02-02 14:22:31 -08:00
-e $SHELL -c "$CMD"
elif command -v xst >/dev/null; then
xst -t $SCRID -n $SCRID -c $SCRID \
2020-02-02 14:22:31 -08:00
-f "$(xrdb -query | grep 'scratch\.font' | cut -f2)" \
-e $SHELL -c "$CMD"
else
>&2 echo "No shell to launch the scratch terminal with"
exit 1
fi