#!/bin/bash

# restart instantWM from cli

if ! [ -e /tmp/wmpid ]; then
    if pgrep instantwm; then
        pkill instantwm
        exit
    fi
else
    WMPID="$(cat /tmp/wmpid)"
    if kill -0 "$WMPID"; then
        kill "$WMPID"
        rm /tmp/wmpid
        exit
    fi
fi

echo "no running window manager found"
