# --- Configuration ---
# The name of your systemd user service file.
SERVICE_NAME="ttd.service"

# --- Logic ---
# Check if the service is currently enabled. The '--quiet' flag just sets
# the exit code without printing anything, which is perfect for scripts.
if systemctl --user is-enabled --quiet "$SERVICE_NAME"; then
    # If it IS enabled, then we DISABLE and STOP it.
    systemctl --user disable "$SERVICE_NAME"
    systemctl --user stop "$SERVICE_NAME"
    notify-send "TwoToneDetect Autostart" "Autostart has been DISABLED." -i "dialog-error"
else
    # If it IS NOT enabled, then we ENABLE and START it.
    systemctl --user enable "$SERVICE_NAME"
    systemctl --user start "$SERVICE_NAME"
    notify-send "TwoToneDetect Autostart" "Autostart has been ENABLED." -i "dialog-information"
fi

exit 0