aboutsummaryrefslogtreecommitdiffstats
path: root/oni/home/services/xdisorg.scm
blob: 1c013a3218e6308aad8da8bba72df06bfe653212 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
(define-module (oni home services xdisorg)
  #:use-module ((gnu home services)
                #:select (service-type
                          service-extension
                          home-profile-service-type
                          home-xdg-configuration-files-service-type
                          home-run-on-change-service-type))
  #:use-module ((gnu home services shepherd)
                #:select (home-shepherd-service-type
                          shepherd-service))
  #:use-module ((gnu packages admin)
                #:select (shepherd))
  #:use-module ((gnu packages xdisorg)
                #:select (xss-lock
                          sxhkd))
  #:use-module ((gnu services configuration)
                #:select (serialize-package
                          define-configuration
                          text-config?
                          serialize-text-config))
  #:use-module ((guix gexp)
                #:select (gexp
                          file-append
                          mixed-text-file))
  #:use-module ((guix packages)
                #:select (package?))

  #:export (home-xss-lock-configuration
            home-xss-lock-service-type

            home-sxhkd-configuration
            home-sxhkd-service-type))

(define-configuration home-xss-lock-configuration
  (package
   (package xss-lock)
   "Package to use for setting xss-lock"))

(define (add-xss-lock-packages config)
  (list (home-xss-lock-configuration-package config)))

(define (home-xss-lock-shepherd-service config)
  (list
   (shepherd-service
    (documentation "Start xss-lock")
    (provision '(xss-lock))
    (auto-start? #t)
    (start
     #~(make-forkexec-constructor
        (list #$(file-append (home-xss-lock-configuration-package config) "/bin/xss-lock") "i3lock" "--" "--color" "222224")
        #:log-file (format #f "~a/.local/var/log/xss-lock.log" (getenv "HOME"))))
    (stop #~(make-kill-destructor)))))

(define home-xss-lock-service-type
  (service-type
   (name 'home-xss-lock)
   (extensions
    (list (service-extension
           home-profile-service-type
           add-xss-lock-packages)
          (service-extension
           home-shepherd-service-type
           home-xss-lock-shepherd-service)))
   (compose identity)
   (default-value (home-xss-lock-configuration))
   (description "Install and configure xss-lock.")))

(define-configuration home-sxhkd-configuration
  (package
    (package sxhkd)
    "Package to use for setting sxhkd")
  (configurations
   (text-config '())
   "Extra configuration."))

(define-configuration home-sxhkd-extension
  (configurations
   (text-config '())
   "Extra configuration."))

(define (add-sxhkd-packages config)
  (list (home-sxhkd-configuration-package config)))

(define (home-sxhkd-config-files config)
  `(("sxhkd/sxhkdrc"
     ,(mixed-text-file
       "sxhkdrc"
       (serialize-text-config config (home-sxhkd-configuration-configurations config))))))

(define (home-sxhkd-extensions original-config extension-configs)
  (home-sxhkd-configuration
   (inherit original-config)
   (configurations
    (apply append (home-sxhkd-configuration-configurations original-config)
           (map home-sxhkd-extension-configurations extension-configs)))))

(define (home-sxhkd-shepherd-service config)
  (list
   (shepherd-service
    (documentation "Start sxhkd")
    (provision '(sxhkd))
    (auto-start? #t)
    (start
     #~(make-forkexec-constructor
        (list #$(file-append (home-sxhkd-configuration-package config) "/bin/sxhkd"))
        #:log-file (format #f "~a/.local/var/log/sxhkd.log" (getenv "HOME"))))
    (stop #~(make-kill-destructor)))))

(define (reload-sxhkd-config-gexp _)
  `(("files/.config/sxhkd/sxhkdrc"
     ,#~(system* #$(file-append shepherd "/bin/herd") "restart" "sxhkd"))))

(define home-sxhkd-service-type
  (service-type
   (name 'home-sxhkd)
   (extensions
    (list (service-extension
           home-profile-service-type
           add-sxhkd-packages)
          (service-extension
           home-shepherd-service-type
           home-sxhkd-shepherd-service)
          (service-extension
           home-xdg-configuration-files-service-type
           home-sxhkd-config-files)
          (service-extension
           home-run-on-change-service-type
           reload-sxhkd-config-gexp)))
   (compose identity)
   (extend home-sxhkd-extensions)
   (default-value (home-sxhkd-configuration))
   (description "Install and configure sxhkd.")))