eufon

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 11facddf8a6a2b1e3b9b665b826c0ae7a86a92a7
parent e822df5f17a61e8d9956e51829a202efddce24d1
Author: Daniel Barlow <dan@telent.net>
Date:   Tue, 18 Jan 2022 20:26:28 +0000

Merge pull request #2 from samueldr/feature/show-again-when-running

saturn: Show current instance on re-exec

Diffstat:
Msaturn/main.fnl | 25+++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/saturn/main.fnl b/saturn/main.fnl @@ -25,15 +25,28 @@ (local DBUS_NAME_FLAG_DO_NOT_QUEUE 4) +(local DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER 1) +(local DBUS_REQUEST_NAME_REPLY_IN_QUEUE 2) +(local DBUS_REQUEST_NAME_REPLY_EXISTS 3) +(local DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER 4) + (let [ret (bus:RequestName "net.telent.saturn" DBUS_NAME_FLAG_DO_NOT_QUEUE)] - (if (or (= ret 1) (= ret 4)) + (if (or (= ret DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) (= ret DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER)) true - (= ret 2) + (= ret DBUS_REQUEST_NAME_REPLY_IN_QUEUE) (error "unexpected DBUS_REQUEST_NAME_REPLY_IN_QUEUE") - (= ret 3) - (do - (print "already running") - (os.exit 0)))) + (= ret DBUS_REQUEST_NAME_REPLY_EXISTS) + ;; Show the currently running instance + (let [saturn (dbus.Proxy:new + { + :bus dbus.Bus.SESSION + :name "net.telent.saturn" + :interface "net.telent.saturn" + :path "/net/telent/saturn" + })] + (saturn:SetVisible true) + (os.exit 0) + ))) (local lfs (require :lfs))