allow only one copy of saturn to run at a time
This commit is contained in:
parent
beddfa6a35
commit
786d9fc68a
@ -15,6 +15,10 @@ let fennel = fetchurl {
|
|||||||
url = "https://fennel-lang.org/downloads/fennel-1.0.0";
|
url = "https://fennel-lang.org/downloads/fennel-1.0.0";
|
||||||
hash = "sha256:1nha32yilzagfwrs44hc763jgwxd700kaik1is7x7lsjjvkgapw7";
|
hash = "sha256:1nha32yilzagfwrs44hc763jgwxd700kaik1is7x7lsjjvkgapw7";
|
||||||
};
|
};
|
||||||
|
dbusProxy = callPackage ../beehive/dbus-proxy.nix {
|
||||||
|
inherit (lua53Packages) lgi buildLuaPackage;
|
||||||
|
lua = lua5_3;
|
||||||
|
};
|
||||||
inifile = let lua = lua5_3; in lua53Packages.buildLuaPackage rec {
|
inifile = let lua = lua5_3; in lua53Packages.buildLuaPackage rec {
|
||||||
pname = "inifile";
|
pname = "inifile";
|
||||||
name = "${pname}-${version}";
|
name = "${pname}-${version}";
|
||||||
@ -32,6 +36,7 @@ let fennel = fetchurl {
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
lua = lua5_3.withPackages (ps: with ps; [
|
lua = lua5_3.withPackages (ps: with ps; [
|
||||||
|
dbusProxy
|
||||||
inifile
|
inifile
|
||||||
inspect
|
inspect
|
||||||
lgi
|
lgi
|
||||||
|
@ -1,3 +1,23 @@
|
|||||||
|
(local dbus (require :dbus_proxy))
|
||||||
|
|
||||||
|
(local bus (dbus.Proxy:new
|
||||||
|
{
|
||||||
|
:bus dbus.Bus.SESSION
|
||||||
|
:name "org.freedesktop.DBus"
|
||||||
|
:interface "org.freedesktop.DBus"
|
||||||
|
:path "/org/freedesktop/DBus"
|
||||||
|
}))
|
||||||
|
|
||||||
|
(local DBUS_NAME_FLAG_DO_NOT_QUEUE 4)
|
||||||
|
(let [ret (bus:RequestName "net.telent.saturn" DBUS_NAME_FLAG_DO_NOT_QUEUE)]
|
||||||
|
(if (or (= ret 1) (= ret 4))
|
||||||
|
true
|
||||||
|
(= ret 2)
|
||||||
|
(error "unexpected DBUS_REQUEST_NAME_REPLY_IN_QUEUE")
|
||||||
|
(= ret 3)
|
||||||
|
(do
|
||||||
|
(print "already running")
|
||||||
|
(os.exit 0))))
|
||||||
|
|
||||||
(local lfs (require :lfs))
|
(local lfs (require :lfs))
|
||||||
(local inifile (require :inifile))
|
(local inifile (require :inifile))
|
||||||
|
Loading…
Reference in New Issue
Block a user