declare dbus service attributes once
This commit is contained in:
parent
0a2959af30
commit
29a17fafff
@ -3,6 +3,14 @@
|
|||||||
(local dbus (require :dbus_proxy))
|
(local dbus (require :dbus_proxy))
|
||||||
(local inspect (require :inspect))
|
(local inspect (require :inspect))
|
||||||
|
|
||||||
|
(local dbus-service-attrs
|
||||||
|
{
|
||||||
|
:bus dbus.Bus.SESSION
|
||||||
|
:name "net.telent.saturn"
|
||||||
|
:interface "net.telent.saturn"
|
||||||
|
:path "/net/telent/saturn"
|
||||||
|
})
|
||||||
|
|
||||||
(local bus (dbus.Proxy:new
|
(local bus (dbus.Proxy:new
|
||||||
{
|
{
|
||||||
:bus dbus.Bus.SESSION
|
:bus dbus.Bus.SESSION
|
||||||
@ -30,23 +38,20 @@
|
|||||||
(local DBUS_REQUEST_NAME_REPLY_EXISTS 3)
|
(local DBUS_REQUEST_NAME_REPLY_EXISTS 3)
|
||||||
(local DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER 4)
|
(local DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER 4)
|
||||||
|
|
||||||
(let [ret (bus:RequestName "net.telent.saturn" DBUS_NAME_FLAG_DO_NOT_QUEUE)]
|
(let [ret (bus:RequestName dbus-service-attrs.name
|
||||||
(if (or (= ret DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) (= ret DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER))
|
DBUS_NAME_FLAG_DO_NOT_QUEUE)]
|
||||||
true
|
(match ret
|
||||||
(= ret DBUS_REQUEST_NAME_REPLY_IN_QUEUE)
|
DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER
|
||||||
(error "unexpected DBUS_REQUEST_NAME_REPLY_IN_QUEUE")
|
true
|
||||||
(= ret DBUS_REQUEST_NAME_REPLY_EXISTS)
|
DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER
|
||||||
;; Show the currently running instance
|
true
|
||||||
(let [saturn (dbus.Proxy:new
|
DBUS_REQUEST_NAME_REPLY_IN_QUEUE
|
||||||
{
|
(error "unexpected DBUS_REQUEST_NAME_REPLY_IN_QUEUE")
|
||||||
:bus dbus.Bus.SESSION
|
DBUS_REQUEST_NAME_REPLY_EXISTS
|
||||||
:name "net.telent.saturn"
|
;; Show the currently running instance
|
||||||
:interface "net.telent.saturn"
|
(let [saturn (dbus.Proxy:new dbus-service-attrs)]
|
||||||
:path "/net/telent/saturn"
|
(saturn:SetVisible true)
|
||||||
})]
|
(os.exit 0))))
|
||||||
(saturn:SetVisible true)
|
|
||||||
(os.exit 0)
|
|
||||||
)))
|
|
||||||
|
|
||||||
|
|
||||||
(local lfs (require :lfs))
|
(local lfs (require :lfs))
|
||||||
@ -80,7 +85,8 @@
|
|||||||
(fn read-desktop-file [f]
|
(fn read-desktop-file [f]
|
||||||
(let [parsed (inifile.parse f)
|
(let [parsed (inifile.parse f)
|
||||||
vals (. parsed "Desktop Entry")]
|
vals (. parsed "Desktop Entry")]
|
||||||
(when vals.Icon (tset vals "IconImage" (find-icon vals.Icon)))
|
(when vals.Icon
|
||||||
|
(tset vals "IconImage" (find-icon vals.Icon)))
|
||||||
vals))
|
vals))
|
||||||
|
|
||||||
(fn all-apps []
|
(fn all-apps []
|
||||||
@ -129,8 +135,8 @@
|
|||||||
|
|
||||||
|
|
||||||
(fn handle-dbus-method-call [conn sender path interface method params invocation]
|
(fn handle-dbus-method-call [conn sender path interface method params invocation]
|
||||||
(when (and (= path "/net/telent/saturn")
|
(when (and (= path dbus-service-attrs.path)
|
||||||
(= interface "net.telent.saturn")
|
(= interface dbus-service-attrs.interface)
|
||||||
(= method "SetVisible"))
|
(= method "SetVisible"))
|
||||||
(let [[value] (dbus.variant.strip params)]
|
(let [[value] (dbus.variant.strip params)]
|
||||||
(if value (window:show_all) (window:hide))
|
(if value (window:show_all) (window:hide))
|
||||||
@ -138,7 +144,7 @@
|
|||||||
|
|
||||||
(Gio.DBusConnection.register_object
|
(Gio.DBusConnection.register_object
|
||||||
bus.connection
|
bus.connection
|
||||||
"/net/telent/saturn"
|
dbus-service-attrs.path
|
||||||
interface-info
|
interface-info
|
||||||
(lgi.GObject.Closure handle-dbus-method-call)
|
(lgi.GObject.Closure handle-dbus-method-call)
|
||||||
(lgi.GObject.Closure (fn [a] (print "get")))
|
(lgi.GObject.Closure (fn [a] (print "get")))
|
||||||
|
Loading…
Reference in New Issue
Block a user