From 8837b71e02d93787de60d454a493a8801a6427a5 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 18 Sep 2021 15:22:36 -0700 Subject: basic systemctl(1) properties: add USER argument for --user Signed-off-by: Sean Whitton --- src/util.lisp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/util.lisp') diff --git a/src/util.lisp b/src/util.lisp index cb3eace..1bed222 100644 --- a/src/util.lisp +++ b/src/util.lisp @@ -171,6 +171,30 @@ supported." (doplist (k v plist args) (push (strcat "--" (string-downcase (symbol-name k)) "=" v) args))) +(defun systemd--user (&rest args) + "Where ARGS are args to RUN or MRUN for an invocation of a systemd command +which can take \"--user\", insert the \"--user\" parameter, and modify or +insert an :ENV parameter so that the call is more likely to succeed." + (loop with xrd = (format nil "/run/user/~D" (get-connattr :remote-uid)) + with dsba = (format nil "unix:path=~A/bus" xrd) + with arg-done and env-done while args + as next = (pop args) collect next into accum + if (and (not arg-done) (stringp next)) + collect "--user" into accum and do (setq arg-done t) + if (eql :env next) + collect (aprog1 (copy-list (pop args)) + (setf (getf it :XDG_RUNTIME_DIR) xrd + (getf it :DBUS_SESSION_BUS_ADDRESS) dsba + env-done t)) + into accum + if (eql :input next) + collect (pop args) + finally (return (if env-done + accum + (list* :env `(:XDG_RUNTIME_DIR ,xrd + :DBUS_SESSION_BUS_ADDRESS ,dsba) + accum))))) + (defmacro with-local-temporary-directory ((dir) &body forms) "Execute FORMS with a local temporary directory's pathname in DIR. Currently assumes GNU mktemp(1). -- cgit v1.2.3