aboutsummaryrefslogtreecommitdiff
path: root/mirenn/home/services/brightnessctl.scm
diff options
context:
space:
mode:
Diffstat (limited to 'mirenn/home/services/brightnessctl.scm')
-rw-r--r--mirenn/home/services/brightnessctl.scm37
1 files changed, 37 insertions, 0 deletions
diff --git a/mirenn/home/services/brightnessctl.scm b/mirenn/home/services/brightnessctl.scm
new file mode 100644
index 0000000..b71e04a
--- /dev/null
+++ b/mirenn/home/services/brightnessctl.scm
@@ -0,0 +1,37 @@
+(define-module (mirenn home services brightnessctl)
+ #:use-module (guix gexp)
+ #:use-module (gnu services)
+ #:use-module (gnu services shepherd)
+ #:use-module (gnu services configuration)
+ #:use-module (gnu home services)
+ #:use-module (gnu home services shepherd)
+ #:use-module (gnu packages linux)
+
+ #:export (home-brightnessctl-configuration))
+
+(define-configuration/no-serialization home-brightnessctl-configuration
+ (state-file
+ (string ".local/state/brightnessctl")
+ "The file which the brightness state is stored."))
+
+(define (home-brightnessctl-shepherd-service config)
+ (list
+ (shepherd-service
+ (provision '(brightnessctl))
+ (documentation "Save and restore brightness.")
+ (start #~(make-system-constructor
+ #$(string-append "brightnessctl set $(cat \"$HOME/"
+ (home-brightnessctl-configuration-state-file config)
+ "\")")))
+ (stop #~(make-system-destructor
+ #$(string-append "brightnessctl get > \"$HOME/"
+ (home-brightnessctl-configuration-state-file config)
+ "\""))))))
+
+(define-public home-brightnessctl-service-type
+ (service-type
+ (name 'home-brightnessctl)
+ (extensions
+ (list (service-extension home-shepherd-service-type home-brightnessctl-shepherd-service)))
+ (description "Save and restore brightness.")
+ (default-value (home-brightnessctl-configuration))))