Initial checkin, broken, with freedesktop api
This commit is contained in:
commit
f10de92455
|
@ -0,0 +1,9 @@
|
||||||
|
.DS_Store
|
||||||
|
.idea
|
||||||
|
*.log
|
||||||
|
tmp/
|
||||||
|
|
||||||
|
.cpcache/
|
||||||
|
.nrepl-port
|
||||||
|
target/
|
||||||
|
result
|
|
@ -0,0 +1,122 @@
|
||||||
|
(ns build
|
||||||
|
(:require [clojure.tools.build.api :as b]
|
||||||
|
[clojure.pprint :refer [pprint]]
|
||||||
|
[clojure.edn :as edn]))
|
||||||
|
|
||||||
|
(def lib 'org.fudo/tattler)
|
||||||
|
(def default-version "DEV")
|
||||||
|
(defn- class-dir [{:keys [target]}] (format "%s/classes" target))
|
||||||
|
(def basis (b/create-basis {:project "deps.edn"}))
|
||||||
|
(defn- jar-file [{:keys [target version]
|
||||||
|
:or {version default-version}}]
|
||||||
|
(format "%s/%s-%s.jar" target (name lib) version))
|
||||||
|
|
||||||
|
(defn- uberjar-file [{:keys [target version]
|
||||||
|
:or {version default-version}}]
|
||||||
|
(format "%s/%s-uber-%s.jar" target (name lib) version))
|
||||||
|
|
||||||
|
(def default-params
|
||||||
|
{
|
||||||
|
:verbose false
|
||||||
|
:version "DEV"
|
||||||
|
})
|
||||||
|
|
||||||
|
(defn clean [{:keys [target] :as params}]
|
||||||
|
(b/delete {:path target})
|
||||||
|
params)
|
||||||
|
|
||||||
|
(defn compile-java [{:keys [verbose java-src] :as params}]
|
||||||
|
(when verbose (println (format "compiling java files in %s..." java-src)))
|
||||||
|
(b/javac {:src-dirs [java-src]
|
||||||
|
:class-dir (class-dir params)
|
||||||
|
:basis basis
|
||||||
|
:javac-opts ["-source" "12" "-target" "12"]})
|
||||||
|
params)
|
||||||
|
|
||||||
|
(defn compile-clj [{:keys [verbose clj-src] :as params}]
|
||||||
|
(when verbose (println (format "compiling clj files in %s..." clj-src)))
|
||||||
|
(b/compile-clj {:basis basis
|
||||||
|
:src-dirs [clj-src]
|
||||||
|
:class-dir (class-dir params)}))
|
||||||
|
|
||||||
|
(defn- pthru [o] (pprint o) o)
|
||||||
|
|
||||||
|
(defn- read-metadata [filename]
|
||||||
|
(-> filename
|
||||||
|
(slurp)
|
||||||
|
(edn/read-string)))
|
||||||
|
|
||||||
|
(defn jar [base-params]
|
||||||
|
(let [params (-> (merge default-params
|
||||||
|
(read-metadata (or (:metadata base-params)
|
||||||
|
"metadata.edn"))
|
||||||
|
base-params)
|
||||||
|
(update :target str)
|
||||||
|
(update :version str)
|
||||||
|
(update :java-src str)
|
||||||
|
(update :clj-src str)
|
||||||
|
(update :main-ns str))
|
||||||
|
{:keys [java-src clj-src main-ns version verbose]} params
|
||||||
|
classes (class-dir params)]
|
||||||
|
(when verbose
|
||||||
|
(print "parameters: ")
|
||||||
|
(pprint params))
|
||||||
|
(compile-java params)
|
||||||
|
(compile-clj params)
|
||||||
|
(when verbose (println (format "writing POM file to %s..." classes)))
|
||||||
|
(b/write-pom {
|
||||||
|
:class-dir classes
|
||||||
|
:lib lib
|
||||||
|
:version (str version)
|
||||||
|
:basis basis
|
||||||
|
:src-dirs [java-src clj-src]
|
||||||
|
})
|
||||||
|
(when verbose (println (format "copying source files from %s to %s..."
|
||||||
|
[java-src clj-src] classes)))
|
||||||
|
(b/copy-dir {:src-dirs [java-src clj-src]
|
||||||
|
:target-dir classes})
|
||||||
|
(let [jar (jar-file params)]
|
||||||
|
(when verbose (println (format "writing JAR file to %s..." jar)))
|
||||||
|
(b/jar {:class-dir classes
|
||||||
|
:jar-file jar
|
||||||
|
:main main-ns}))
|
||||||
|
(when verbose (println "done!"))
|
||||||
|
params))
|
||||||
|
|
||||||
|
(defn uberjar [base-params]
|
||||||
|
(let [params (-> (merge default-params
|
||||||
|
(read-metadata (or (:metadata base-params)
|
||||||
|
"metadata.edn"))
|
||||||
|
base-params)
|
||||||
|
(update :target str)
|
||||||
|
(update :version str)
|
||||||
|
(update :java-src str)
|
||||||
|
(update :clj-src str)
|
||||||
|
(update :main-ns str))
|
||||||
|
{:keys [java-src clj-src main-ns version verbose]} params
|
||||||
|
classes (class-dir params)]
|
||||||
|
(when verbose
|
||||||
|
(print "parameters: ")
|
||||||
|
(pprint params))
|
||||||
|
(compile-java params)
|
||||||
|
(compile-clj params)
|
||||||
|
(when verbose (println (format "writing POM file to %s..." classes)))
|
||||||
|
(b/write-pom {
|
||||||
|
:class-dir classes
|
||||||
|
:lib lib
|
||||||
|
:version (str version)
|
||||||
|
:basis basis
|
||||||
|
:src-dirs [java-src clj-src]
|
||||||
|
})
|
||||||
|
(when verbose (println (format "copying source files from %s to %s..."
|
||||||
|
[java-src clj-src] classes)))
|
||||||
|
(b/copy-dir {:src-dirs [java-src clj-src]
|
||||||
|
:target-dir classes})
|
||||||
|
(let [uberjar (uberjar-file params)]
|
||||||
|
(when verbose (println (format "writing uberjar file to %s..." uberjar)))
|
||||||
|
(b/uber {:class-dir classes
|
||||||
|
:uber-file uberjar
|
||||||
|
:basis basis
|
||||||
|
:main main-ns}))
|
||||||
|
(when verbose (println "done!"))
|
||||||
|
params))
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
: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" }
|
||||||
|
}
|
||||||
|
;; :mvn/repos {
|
||||||
|
;; "in2p3" {:url "https://maven.in2p3.fr/"}
|
||||||
|
;; }
|
||||||
|
:aliases {
|
||||||
|
:build {
|
||||||
|
:extra-deps {
|
||||||
|
io.github.clojure/tools.build {:mvn/version "0.9.4"}
|
||||||
|
}
|
||||||
|
:ns-default build
|
||||||
|
:exec-fn uberjar
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
:version "0.1"
|
||||||
|
:target "target"
|
||||||
|
:java-src "src/java"
|
||||||
|
:clj-src "src/clj"
|
||||||
|
:main-ns "tattler.core"
|
||||||
|
:verbose true
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
(ns tattler.core
|
||||||
|
(:import [org.freedesktop.dbus DBusConnection]
|
||||||
|
[org.freedesktop Notifications])
|
||||||
|
(: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 send [{app :app conn :conn} notification]
|
||||||
|
(let []))
|
||||||
|
|
||||||
|
(defn -main [& args]
|
||||||
|
(println (get-server-capabilities)))
|
Loading…
Reference in New Issue