#!/bin/sh

if ! [ -z "$(swaymsg -t get_tree | grep 'ddterminal')" ]; then
    if [ -z "$(swaymsg -t get_tree | grep -A 46 'ddterminal' | tail -n 1 | grep 'true')" ]; then
        swaymsg '[title="ddterminal"] scratchpad show'
    else
        swaymsg '[title="ddterminal"] move scratchpad'
    fi
else
    $TERMINAL -t "ddterminal" -e tmuxatt &
    sleep 0.2s
    currenty=$(swaygetcurrentwindow | cut -d ' ' -f1 | cut -d ',' -f2 )
    let moveup=$currenty-30
    swaymsg move up "$moveup px"
fi