summary refs log tree commit diff
path: root/gnu/services/desktop.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/services/desktop.scm')
-rw-r--r--gnu/services/desktop.scm376
1 files changed, 372 insertions, 4 deletions
diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm
index c2ee3a3d80..ecadb16b2f 100644
--- a/gnu/services/desktop.scm
+++ b/gnu/services/desktop.scm
@@ -44,6 +44,7 @@
   #:use-module (gnu system)
   #:use-module (gnu system setuid)
   #:use-module (gnu system shadow)
+  #:use-module (gnu system uuid)
   #:use-module (gnu system pam)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages admin)
@@ -68,6 +69,7 @@
   #:use-module (guix utils)
   #:use-module (guix gexp)
   #:use-module (srfi srfi-1)
+  #:use-module (ice-9 format)
   #:use-module (ice-9 match)
   #:export (<upower-configuration>
             upower-configuration
@@ -403,14 +405,380 @@ site} for more information."
   bluetooth-configuration make-bluetooth-configuration
   bluetooth-configuration?
   (bluez bluetooth-configuration-bluez (default bluez))
-  (auto-enable? bluetooth-configuration-auto-enable? (default #f)))
+
+  ;;; [General]
+  (name bluetooth-configuration-name (default "BlueZ"))
+  (class bluetooth-configuration-class (default #x000000))
+  (discoverable-timeout
+   bluetooth-configuration-discoverable-timeout (default 180))
+  (always-pairable? bluetooth-configuration-always-pairable? (default #f))
+  (pairable-timeout bluetooth-configuration-pairable-timeout (default 0))
+
+  ;;; MAYBE: Exclude into separate <device-id> record-type?
+  (device-id bluetooth-configuration-device-id (default #f))
+  (reverse-service-discovery?
+   bluetooth-configuration-reverse-service-discovery (default #t))
+  (name-resolving? bluetooth-configuration-name-resolving? (default #t))
+  (debug-keys? bluetooth-configuration-debug-keys? (default #f))
+
+  ;;; Possible values:
+  ;;; 'dual, 'bredr, 'le
+  (controller-mode bluetooth-configuration-controller-mode (default 'dual))
+
+  ;;; Possible values:
+  ;;; 'off, 'single, 'multiple
+  (multi-profile bluetooth-configuration-multi-profile (default 'off))
+  (fast-connectable? bluetooth-configuration-fast-connectable? (default #f))
+
+  ;;; Possible values:
+  ;;; for LE mode: 'off, 'network/on, 'device
+  ;;; for Dual mode: 'off, 'network/on', 'device, 'limited-network, 'limited-device
+  ;;; Source: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/main.conf#n68
+  (privacy bluetooth-configuration-privacy (default 'off))
+
+  ;;; Possible values:
+  ;;; 'never, 'confirm, 'always
+  (just-works-repairing
+   bluetooth-configuration-just-works-repairing (default 'never))
+  (temporary-timeout bluetooth-configuration-temporary-timeout (default 30))
+  (refresh-discovery? bluetooth-configuration-refresh-discovery (default #t))
+
+  ;;; Possible values: #t, #f, (uuid <uuid>)
+  ;;; Possible UUIDs:
+  ;;; d4992530-b9ec-469f-ab01-6c481c47da1c (BlueZ Experimental Debug)
+  ;;; 671b10b5-42c0-4696-9227-eb28d1b049d6 (BlueZ Experimental Simultaneous Central and Peripheral)
+  ;;; 15c0a148-c273-11ea-b3de-0242ac130004 (BlueZ Experimental LL privacy)
+  ;;; 330859bc-7506-492d-9370-9a6f0614037f (BlueZ Experimental Bluetooth Quality Report)
+  ;;; a6695ace-ee7f-4fb9-881a-5fac66c629af (BlueZ Experimental Offload Codecs)
+  ;;; Source: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/main.conf#n110
+  (experimental bluetooth-configuration-experimental (default #f))
+  (remote-name-request-retry-delay
+   bluetooth-configuration-remote-name-request-retry-delay (default 300))
+
+  ;;; [BR]
+  (page-scan-type bluetooth-configuration-page-scan-type (default #f))
+  (page-scan-interval bluetooth-configuration-page-scan-interval (default #f))
+  (page-scan-window bluetooth-configuration-page-scan-window (default #f))
+  (inquiry-scan-type bluetooth-configuration-inquiry-scan-type (default #f))
+  (inquiry-scan-interval bluetooth-configuration-inquiry-scan-interval (default #f))
+  (inquiry-scan-window bluetooth-configuration-inquiry-scan-window (default #f))
+  (link-supervision-timeout bluetooth-configuration-link-supervision-timeout (default #f))
+  (page-timeout bluetooth-configuration-page-timeout (default #f))
+  (min-sniff-interval bluetooth-configuration-min-sniff-interval (default #f))
+  (max-sniff-interval bluetooth-configuration-max-sniff-interval (default #f))
+
+  ;;; [LE]
+  (min-advertisement-interval
+   bluetooth-configuration-min-advertisement-interval (default #f))
+  (max-advertisement-interval
+   bluetooth-configuration-max-advertisement-interval (default #f))
+  (multi-advertisement-rotation-interval
+   bluetooth-configuration-multi-advertisement-rotation-interval (default #f))
+  (scan-interval-auto-connect
+   bluetooth-configuration-scan-interval-auto-connect (default #f))
+  (scan-window-auto-connect
+   bluetooth-configuration-scan-window-auto-connect (default #f))
+  (scan-interval-suspend
+   bluetooth-configuration-scan-interval-suspend (default #f))
+  (scan-window-suspend
+   bluetooth-configuration-scan-window-suspend (default #f))
+  (scan-interval-discovery
+   bluetooth-configuration-scan-interval-discovery (default #f))
+  (scan-window-discovery
+   bluetooth-configuration-scan-window-discovery (default #f))
+  (scan-interval-adv-monitor
+   bluetooth-configuration-scan-interval-adv-monitor (default #f))
+  (scan-window-adv-monitor
+   bluetooth-configuration-scan-window-adv-monitor (default #f))
+  (scan-interval-connect
+   bluetooth-configuration-scan-interval-connect (default #f))
+  (scan-window-connect
+   bluetooth-configuration-scan-window-connect (default #f))
+  (min-connection-interval
+   bluetooth-configuration-min-connection-interval (default #f))
+  (max-connection-interval
+   bluetooth-configuration-max-connection-interval (default #f))
+  (connection-latency
+   bluetooth-configuration-connection-latency (default #f))
+  (connection-supervision-timeout
+   bluetooth-configuration-connection-supervision-timeout (default #f))
+  (autoconnect-timeout
+   bluetooth-configuration-autoconnect-timeout (default #f))
+  (adv-mon-allowlist-scan-duration
+   bluetooth-configuration-adv-mon-allowlist-scan-duration (default 300))
+  (adv-mon-no-filter-scan-duration
+   bluetooth-configuration-adv-mon-no-filter-scan-duration (default 500))
+  (enable-adv-mon-interleave-scan?
+   bluetooth-configuration-enable-adv-mon-interleave-scan (default #t))
+
+  ;;; [GATT]
+  ;;; Possible values: 'yes, 'no, 'always
+  (cache bluetooth-configuration-cache (default 'always))
+
+  ;;; Possible values: 7 ... 16, 0 (don't care)
+  (key-size bluetooth-configuration-key-size (default 0))
+
+  ;;; Possible values: 23 ... 517
+  (exchange-mtu bluetooth-configuration-exchange-mtu (default 517))
+
+  ;;; Possible values: 1 ... 5
+  (att-channels bluetooth-configuration-att-channels (default 3))
+
+  ;;; [AVDTP]
+  ;;; Possible values: 'basic, 'ertm
+  (session-mode bluetooth-configuration-session-mode (default 'basic))
+
+  ;;; Possible values: 'basic, 'streaming
+  (stream-mode bluetooth-configuration-stream-mode (default 'basic))
+
+  ;;; [Policy]
+  (reconnect-uuids bluetooth-configuration-reconnect-uuids (default '()))
+  (reconnect-attempts bluetooth-configuration-reconnect-attempts (default 7))
+  (reconnect-intervals bluetooth-configuration-reconnect-intervals
+                       (default (list 1 2 4 8 16 32 64)))
+  (auto-enable? bluetooth-configuration-auto-enable? (default #f))
+  (resume-delay bluetooth-configuration-resume-delay (default 2))
+
+  ;;; [AdvMon]
+  ;;; Possible values:
+  ;;; "0x00", "0xFF",
+  ;;; "N = 0x00" ... "N = 0xFF"
+  ;;; Source: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/main.conf#n286
+  (rssi-sampling-period bluetooth-configuration-rssi-sampling-period
+                        (default #xFF)))
 
 (define (bluetooth-configuration-file config)
   "Return a configuration file for the systemd bluetooth service, as a string."
   (string-append
-   "[Policy]\n"
-   "AutoEnable=" (bool (bluetooth-configuration-auto-enable?
-                        config))))
+   "[General]"
+   "\nName = " (bluetooth-configuration-name config)
+   "\nClass = " (string-append
+                 "0x"
+                 (format #f "~6,'0x" (bluetooth-configuration-class config)))
+   "\nDiscoverableTimeout = " (number->string
+                               (bluetooth-configuration-discoverable-timeout
+                                config))
+   "\nAlwaysPairable = " (bool (bluetooth-configuration-always-pairable?
+                                config))
+   "\nPairableTimeout = " (number->string
+                           (bluetooth-configuration-pairable-timeout
+                            config))
+   (if (bluetooth-configuration-device-id config)
+       (string-append "\nDeviceID = " (bluetooth-configuration-device-id config))
+       "")
+   "\nReverseServiceDiscovery = " (bool
+                                   (bluetooth-configuration-reverse-service-discovery
+                                    config))
+   "\nNameResolving = " (bool (bluetooth-configuration-name-resolving? config))
+   "\nDebugKeys = " (bool (bluetooth-configuration-debug-keys? config))
+   "\nControllerMode = " (symbol->string
+                          (bluetooth-configuration-controller-mode config))
+   "\nMultiProfile = " (symbol->string (bluetooth-configuration-multi-profile
+                                        config))
+   "\nFastConnectable = " (bool (bluetooth-configuration-fast-connectable? config))
+   "\nPrivacy = " (symbol->string (bluetooth-configuration-privacy config))
+   "\nJustWorksRepairing = " (symbol->string
+                              (bluetooth-configuration-just-works-repairing config))
+   "\nTemporaryTimeout = " (number->string
+                            (bluetooth-configuration-temporary-timeout config))
+   "\nRefreshDiscovery = " (bool (bluetooth-configuration-refresh-discovery config))
+   "\nExperimental = " (let ((experimental (bluetooth-configuration-experimental config)))
+                         (cond ((or (eq? experimental #t)
+                                    (eq? experimental #f)) (bool experimental))
+                               ((list? experimental)
+                                (string-join (map uuid->string experimental) ","))))
+   "\nRemoteNameRequestRetryDelay = " (number->string
+                                       (bluetooth-configuration-remote-name-request-retry-delay
+                                        config))
+   "\n[BR]"
+   (if (bluetooth-configuration-page-scan-type config)
+       (string-append
+        "\nPageScanType = "
+        (number->string (bluetooth-configuration-page-scan-type config)))
+       "")
+   (if (bluetooth-configuration-page-scan-interval config)
+       (string-append
+        "\nPageScanInterval = "
+        (number->string (bluetooth-configuration-page-scan-interval config)))
+       "")
+   (if (bluetooth-configuration-page-scan-window config)
+       (string-append
+        "\nPageScanWindow = "
+        (number->string (bluetooth-configuration-page-scan-window config)))
+       "")
+   (if (bluetooth-configuration-inquiry-scan-type config)
+       (string-append
+        "\nInquiryScanType = "
+        (number->string (bluetooth-configuration-inquiry-scan-type config)))
+       "")
+   (if (bluetooth-configuration-inquiry-scan-interval config)
+       (string-append
+        "\nInquiryScanInterval = "
+        (number->string (bluetooth-configuration-inquiry-scan-interval config)))
+       "")
+   (if (bluetooth-configuration-inquiry-scan-window config)
+       (string-append
+        "\nInquiryScanWindow = "
+        (number->string (bluetooth-configuration-inquiry-scan-window config)))
+       "")
+   (if (bluetooth-configuration-link-supervision-timeout config)
+       (string-append
+        "\nLinkSupervisionTimeout = "
+        (number->string (bluetooth-configuration-link-supervision-timeout config)))
+       "")
+   (if (bluetooth-configuration-page-timeout config)
+       (string-append
+        "\nPageTimeout = "
+        (number->string (bluetooth-configuration-page-timeout config)))
+       "")
+   (if (bluetooth-configuration-min-sniff-interval config)
+       (string-append
+        "\nMinSniffInterval = "
+        (number->string (bluetooth-configuration-min-sniff-interval config)))
+       "")
+   (if (bluetooth-configuration-max-sniff-interval config)
+       (string-append
+        "\nMaxSniffInterval = "
+        (number->string (bluetooth-configuration-max-sniff-interval config)))
+       "")
+
+   "\n[LE]"
+   (if (bluetooth-configuration-min-advertisement-interval config)
+       (string-append
+        "\nMinAdvertisementInterval = "
+        (number->string (bluetooth-configuration-min-advertisement-interval config)))
+       "")
+   (if (bluetooth-configuration-max-advertisement-interval config)
+       (string-append
+        "\nMaxAdvertisementInterval = "
+        (number->string (bluetooth-configuration-max-advertisement-interval config)))
+       "")
+   (if (bluetooth-configuration-multi-advertisement-rotation-interval config)
+       (string-append
+        "\nMultiAdvertisementRotationInterval = "
+        (number->string
+         (bluetooth-configuration-multi-advertisement-rotation-interval config)))
+       "")
+   (if (bluetooth-configuration-scan-interval-auto-connect config)
+       (string-append
+        "\nScanIntervalAutoConnect = "
+        (number->string (bluetooth-configuration-scan-interval-auto-connect config)))
+       "")
+   (if (bluetooth-configuration-scan-window-auto-connect config)
+       (string-append
+        "\nScanWindowAutoConnect = "
+        (number->string (bluetooth-configuration-scan-window-auto-connect config)))
+       "")
+   (if (bluetooth-configuration-scan-interval-suspend config)
+       (string-append
+        "\nScanIntervalSuspend = "
+        (number->string (bluetooth-configuration-scan-interval-suspend config)))
+       "")
+   (if (bluetooth-configuration-scan-window-suspend config)
+       (string-append
+        "\nScanWindowSuspend = "
+        (number->string (bluetooth-configuration-scan-window-suspend config)))
+       "")
+   (if (bluetooth-configuration-scan-interval-discovery config)
+       (string-append
+        "\nScanIntervalDiscovery = "
+        (number->string (bluetooth-configuration-scan-interval-discovery config)))
+       "")
+   (if (bluetooth-configuration-scan-window-discovery config)
+       (string-append
+        "\nScanWindowDiscovery = "
+        (number->string (bluetooth-configuration-scan-window-discovery config)))
+       "")
+   (if (bluetooth-configuration-scan-interval-adv-monitor config)
+       (string-append
+        "\nScanIntervalAdvMonitor = "
+        (number->string (bluetooth-configuration-scan-interval-adv-monitor config)))
+       "")
+   (if (bluetooth-configuration-scan-window-adv-monitor config)
+       (string-append
+        "\nScanWindowAdvMonitor = "
+        (number->string (bluetooth-configuration-scan-window-adv-monitor config)))
+       "")
+   (if (bluetooth-configuration-scan-interval-connect config)
+       (string-append
+        "\nScanIntervalConnect = "
+        (number->string (bluetooth-configuration-scan-interval-connect config)))
+       "")
+   (if (bluetooth-configuration-scan-window-connect config)
+       (string-append
+        "\nScanWindowConnect = "
+        (number->string (bluetooth-configuration-scan-window-connect config)))
+       "")
+   (if (bluetooth-configuration-min-connection-interval config)
+       (string-append
+        "\nMinConnectionInterval = "
+        (number->string (bluetooth-configuration-min-connection-interval config)))
+       "")
+   (if (bluetooth-configuration-max-connection-interval config)
+       (string-append
+        "\nMaxConnectionInterval = "
+        (number->string (bluetooth-configuration-max-connection-interval config)))
+       "")
+   (if (bluetooth-configuration-connection-latency config)
+       (string-append
+        "\nConnectionLatency = "
+        (number->string (bluetooth-configuration-connection-latency config)))
+       "")
+   (if (bluetooth-configuration-connection-supervision-timeout config)
+       (string-append
+        "\nConnectionSupervisionTimeout = "
+        (number->string (bluetooth-configuration-connection-supervision-timeout config)))
+       "")
+   (if (bluetooth-configuration-autoconnect-timeout config)
+       (string-append
+        "\nAutoconnecttimeout = "
+        (number->string (bluetooth-configuration-autoconnect-timeout config)))
+       "")
+   "\nAdvMonAllowlistScanDuration = " (number->string
+                                       (bluetooth-configuration-adv-mon-allowlist-scan-duration
+                                        config))
+   "\nAdvMonNoFilterScanDuration = " (number->string
+                                      (bluetooth-configuration-adv-mon-no-filter-scan-duration
+                                       config))
+   "\nEnableAdvMonInterleaveScan = " (number->string
+                                      (if (eq? #t
+                                               (bluetooth-configuration-enable-adv-mon-interleave-scan
+                                                config))
+                                          1 0))
+   
+   "\n[GATT]"
+   "\nCache = " (symbol->string (bluetooth-configuration-cache config))
+   "\nKeySize = " (number->string (bluetooth-configuration-key-size config))
+   "\nExchangeMTU = " (number->string (bluetooth-configuration-exchange-mtu config))
+   "\nChannels = " (number->string (bluetooth-configuration-att-channels config))
+
+   "\n[AVDTP]"
+   "\nSessionMode = " (symbol->string (bluetooth-configuration-session-mode config))
+   "\nStreamMode = " (symbol->string (bluetooth-configuration-stream-mode config))
+
+   "\n[Policy]"
+   (let ((uuids (bluetooth-configuration-reconnect-uuids config)))
+     (if (not (eq? '() uuids))
+         (string-append
+          "\nReconnectUUIDs = "
+          (string-join (map uuid->string uuids) ","))
+         ""))
+   "\nReconnectAttempts = " (number->string
+                             (bluetooth-configuration-reconnect-attempts config))
+   "\nReconnectIntervals = " (string-join
+                              (map number->string
+                                   (bluetooth-configuration-reconnect-intervals
+                                    config))
+                              ",")
+   "\nAutoEnable = " (bool (bluetooth-configuration-auto-enable?
+                            config))
+   "\nResumeDelay = " (number->string (bluetooth-configuration-resume-delay config))
+
+   "\n[AdvMon]"
+   "\nRSSISamplingPeriod = " (string-append
+                              "0x"
+                              (format #f "~2,'0x"
+                                      (bluetooth-configuration-rssi-sampling-period config)))))
 
 (define (bluetooth-directory config)
   (computed-file "etc-bluetooth"