
;; Copyright (C) 2026 Tommi Höynälänmaa

;; Distributed under GNU Lesser General Public License.


(define-proper-program (theme-d-intr dbus dbus-introspect)
  
  
  (import (standard-library core)
          (standard-library list-utilities)
          (standard-library console-io))
  

  (import (theme-d-intr base variant)
          (theme-d-intr dbus connection))


  (define-simple-method introspect
      (((conn <g-dbus-connection>)
        (str-service <string>)
        (str-object <string>))
       <string> nonpure)
    (let ((vnt-result
           (g-dbus-connection-call-sync
            conn
            str-service
            str-object
            "org.freedesktop.DBus.Introspectable"
            "Introspect"
            #f
            (g-variant-type-new "(s)")
            '(none)
            1000
            #f)))
      (car (g-variant-get-string (g-variant-get-child-value vnt-result 0)))))


  (define-main-proc (((l-args (:uniform-list <string>))) <none> nonpure)
    (let* ((conn
            (g-bus-get-sync 'session #f))
           (str-service (uniform-list-ref l-args 1))
           (str-object (uniform-list-ref l-args 2))
           (str-intr (introspect conn str-service str-object)))
      (console-display-line str-intr))))


