#!/bin/zsh
JOPLIN_DEST=$(busctl --user list | grep "joplin" | awk '{print $1}' | sort -V | sed -n -e '2p')

if [ -n "$JOPLIN_DEST" ]; then
    busctl --user call "$JOPLIN_DEST" /StatusNotifierItem org.kde.StatusNotifierItem Activate ii 0 0
else
    exec gtk-launch joplin.desktop
fi
