helm/bin/scratch
2020-02-01 23:16:07 -05:00

30 lines
889 B
Bash
Executable file

#!/usr/bin/env bash
SCRID=scratch
CMD='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 \
-d 90 26 \
-e $SHELL -c "$CMD"
elif command -v urxvt >/dev/null; then
urxvt -name $SCRID \
-geometry 100x26 \
-e $SHELL -c '${tmux}/bin/tmux new-session -A -s scratch -n scratch'
elif command -v xst >/dev/null; then
xst -t $SCRID -n $SCRID -c $SCRID \
-f "$(xrdb -query | grep 'st-scratch\.font' | cut -f2)" \
-g 100x26 \
-e $SHELL
else
>&2 echo "No shell to launch the scratch terminal with"
exit 1
fi