#!/usr/bin/env bb

(ns cycle-notifications
  (:require [babashka.process :as p]
            [clojure.string :as str]
            [cheshire.core :as json]))

(defn get-mode []
  (case (:out (p/shell {:out :string} "swaync-client -D"))
    "true" :dnd
    "false" :default))

#_
(get-mode)

(defn toggle! []
  (p/shell {:out nil} "swaync-client -d")
  ;; Update Waybar.
  (p/shell "pkill -SIGRTMIN+2 waybar"))

(defn status []
  (-> (case (:out (p/shell {:out :string} "swaync-client -D"))
        "false" {:text "" :tooltip "Notify"}
        "true" {:text "" :tooltip "Do not disturb"})
      json/generate-string
      println))

(defn -main [& args]
  (case (first args)
    "toggle" (toggle!)
    nil (status)))
