About to repurpose this library...
This commit is contained in:
parent
cc93882d8f
commit
b270cec637
|
@ -30,7 +30,7 @@
|
|||
(b/javac {:src-dirs [java-src]
|
||||
:class-dir (class-dir params)
|
||||
:basis basis
|
||||
:javac-opts ["-source" "12" "-target" "12"]})
|
||||
:javac-opts ["-source" "16" "-target" "16"]})
|
||||
params)
|
||||
|
||||
(defn compile-clj [{:keys [verbose clj-src] :as params}]
|
||||
|
|
14
deps.edn
14
deps.edn
|
@ -2,13 +2,15 @@
|
|||
:paths ["src/clj" "src/java"]
|
||||
:deps {
|
||||
org.clojure/clojure { :mvn/version "1.11.1" }
|
||||
;;org.freedesktop/libdbus-java { :mvn/version "2.7" }
|
||||
;;com.github.hypfvieh/libmatthew { :mvn/version "0.8.3" }
|
||||
com.github.hypfvieh/dbus-java { :mvn/version "3.3.2" }
|
||||
com.github.hypfvieh/dbus-java-core { :mvn/version "4.3.0" }
|
||||
com.github.hypfvieh/dbus-java-transport-native-unixsocket { :mvn/version "4.3.0" }
|
||||
org.fudo/milquetoast {
|
||||
:git/url "https://git.fudo.org/fudo-public/milquetoast.git"
|
||||
:git/sha "ae81b91f0c710632f55b43f0193e16ab0dd81dde"
|
||||
}
|
||||
metosin/malli { :mvn/version "0.11.0" }
|
||||
org.fudo/notifier { :mvn/version "0.1" }
|
||||
}
|
||||
;; :mvn/repos {
|
||||
;; "in2p3" {:url "https://maven.in2p3.fr/"}
|
||||
;; }
|
||||
:aliases {
|
||||
:build {
|
||||
:extra-deps {
|
||||
|
|
|
@ -1,17 +1,43 @@
|
|||
(ns tattler.core
|
||||
(:import [org.freedesktop.dbus DBusConnection]
|
||||
[org.freedesktop Notifications])
|
||||
(:import [org.freedesktop Notifications]
|
||||
[org.freedesktop.dbus.connections.impl
|
||||
DBusConnectionBuilder]
|
||||
org.freedesktop.dbus.types.UInt32)
|
||||
(:gen-class))
|
||||
|
||||
(def ^:private ^:const NOTIFICATIONS_PATH "/org/freedesktop/Notifications")
|
||||
(def ^:private ^:const NOTIFICATIONS_BUS "org.freedesktop.Notifications")
|
||||
|
||||
(defn get-server-capabilities []
|
||||
(let [dbus (DBusConnection/getConnection DBusConnection/SESSION)]
|
||||
(.getRemoteObject dbus NOTIFICATIONS_BUS NOTIFICATIONS_PATH (.class Notifications))))
|
||||
(defn connect-session-bus []
|
||||
(-> (DBusConnectionBuilder/forSessionBus)
|
||||
(.build)
|
||||
(.getRemoteObject NOTIFICATIONS_BUS NOTIFICATIONS_PATH Notifications)))
|
||||
|
||||
(defn send-notification
|
||||
[bus
|
||||
{:keys [app replace-id icon summary body actions timeout urgency]
|
||||
:or {replace-id 0
|
||||
icon ""
|
||||
actions []
|
||||
timeout -1}
|
||||
:as args}]
|
||||
(doseq [arg [:app :summary :body]]
|
||||
(when (not (contains? args arg))
|
||||
(throw (ex-info (format "Missing required argument: %s" arg)
|
||||
{:arg arg}))))
|
||||
(.Notify bus
|
||||
app
|
||||
(UInt32. replace-id)
|
||||
icon
|
||||
summary
|
||||
body
|
||||
actions
|
||||
hints
|
||||
timeout))
|
||||
|
||||
#_(defn send [{app :app conn :conn} notification]
|
||||
(let []))
|
||||
|
||||
(defn -main [& args]
|
||||
(println (get-server-capabilities)))
|
||||
(send-notification (connect-session-bus)
|
||||
{:app "my_app" :summary "Hey there" :body "How's it going now?"}))
|
||||
|
|
|
@ -2,38 +2,38 @@ package org.freedesktop;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.freedesktop.dbus.DBusInterface;
|
||||
import org.freedesktop.dbus.DBusSignal;
|
||||
import org.freedesktop.dbus.UInt32;
|
||||
import org.freedesktop.dbus.Variant;
|
||||
import org.freedesktop.dbus.interfaces.DBusInterface;
|
||||
// import org.freedesktop.dbus.DBusSignal;
|
||||
import org.freedesktop.dbus.types.UInt32;
|
||||
import org.freedesktop.dbus.types.Variant;
|
||||
import org.freedesktop.dbus.exceptions.DBusException;
|
||||
|
||||
public interface Notifications extends DBusInterface {
|
||||
public static class ActionInvoked extends DBusSignal {
|
||||
public final UInt32 id;
|
||||
public final String action_key;
|
||||
// public static class ActionInvoked extends DBusSignal {
|
||||
// public final UInt32 id;
|
||||
// public final String action_key;
|
||||
|
||||
public ActionInvoked(String path, UInt32 id, String action_key) throws DBusException {
|
||||
super(path, id, action_key);
|
||||
this.id = id;
|
||||
this.action_key = action_key;
|
||||
}
|
||||
}
|
||||
// public ActionInvoked(String path, UInt32 id, String action_key) throws DBusException {
|
||||
// super(path, id, action_key);
|
||||
// this.id = id;
|
||||
// this.action_key = action_key;
|
||||
// }
|
||||
// }
|
||||
|
||||
public static class NotificationClosed extends DBusSignal {
|
||||
public final UInt32 id;
|
||||
public final UInt32 reason;
|
||||
// public static class NotificationClosed extends DBusSignal {
|
||||
// public final UInt32 id;
|
||||
// public final UInt32 reason;
|
||||
|
||||
public NotificationClosed(String path, UInt32 id, UInt32 reason) throws DBusException {
|
||||
super(path, id, reason);
|
||||
this.id = id;
|
||||
this.reason = reason;
|
||||
}
|
||||
}
|
||||
// public NotificationClosed(String path, UInt32 id, UInt32 reason) throws DBusException {
|
||||
// super(path, id, reason);
|
||||
// this.id = id;
|
||||
// this.reason = reason;
|
||||
// }
|
||||
// }
|
||||
|
||||
public void CloseNotification(UInt32 id);
|
||||
// public void CloseNotification(UInt32 id);
|
||||
public List<String> GetCapabilities();
|
||||
public Quad<String, String, String, String> GetServerInformation();
|
||||
// public Quad<String, String, String, String> GetServerInformation();
|
||||
|
||||
public UInt32 Notify(
|
||||
String app_name,
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
package org.freedesktop;
|
||||
|
||||
import org.freedesktop.dbus.Position;
|
||||
import org.freedesktop.dbus.Tuple;
|
||||
|
||||
public final class Quad<A, B, C, D> extends Tuple {
|
||||
@Position(0)
|
||||
public final A a;
|
||||
@Position(1)
|
||||
public final B b;
|
||||
@Position(3)
|
||||
public final C c;
|
||||
@Position(4)
|
||||
public final D d;
|
||||
|
||||
public Quad(A a, B b, C c, D d) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
this.d = d;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue