Subject: [bug#60013] [PATCH 2/3] gnu: Add clightd

From: [email-masked]
Date: Mon, 12 Dec 2022 20:31:20 +0000

From: florhizome <[email-masked]>

* gnu/packages/wm.scm (clightd): New variable.
---
 gnu/packages/wm.scm | 69 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 69 insertions(+)

diff --git a/gnu/packages/wm.scm b/gnu/packages/wm.scm
index 86573658f4..919bcc9400 100644
--- a/gnu/packages/wm.scm
+++ b/gnu/packages/wm.scm
@@ -61,6 +61,7 @@
 ;;; Copyright © 2022 ( <[email-masked]>
 ;;; Copyright © 2022 zamfofex <[email-masked]>
 ;;;
+;;; Copyright © 2022 florhizome <[email-masked]>
 ;;; This file is part of GNU Guix.
 ;;;
 ;;; GNU Guix is free software; you can redistribute it and/or modify it
@@ -102,6 +103,7 @@ (define-module (gnu packages wm)
   #:use-module (gnu packages calendar)
   #:use-module (gnu packages check)
   #:use-module (gnu packages cpp)
+  #:use-module (gnu packages c)
   #:use-module (gnu packages datastructures)
   #:use-module (gnu packages docbook)
   #:use-module (gnu packages documentation)
@@ -114,6 +116,7 @@ (define-module (gnu packages wm)
   #:use-module (gnu packages gperf)
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages gnome)
+  #:use-module (gnu packages hardware)
   #:use-module (gnu packages haskell-check)
   #:use-module (gnu packages haskell-web)
   #:use-module (gnu packages haskell-xyz)
@@ -121,6 +124,7 @@ (define-module (gnu packages wm)
   #:use-module (gnu packages imagemagick)
   #:use-module (gnu packages libevent)
   #:use-module (gnu packages libffi)
+  #:use-module (gnu packages libusb)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages lisp-check)
   #:use-module (gnu packages lisp-xyz)
@@ -132,6 +136,7 @@ (define-module (gnu packages wm)
   #:use-module (gnu packages mpd)
   #:use-module (gnu packages pcre)
   #:use-module (gnu packages perl)
+  #:use-module (gnu packages polkit)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages pretty-print)
   #:use-module (gnu packages pulseaudio)
@@ -188,6 +193,70 @@ (define-public bspwm
 the leaves of a full binary tree.")
     (license license:bsd-2)))
 
+
+(define-public clightd
+  (package
+    (name "clightd")
+    (version "5.7")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/FedeDP/clightd")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1b6hc98vk0nm06plld4rgk70f825g8kakcxrv2prsxxvkvlqrmp1"))))
+    (build-system cmake-build-system)
+    (native-inputs (list pkg-config libmodule))
+    (inputs (list elogind
+                  eudev
+                  dbus
+                  ddcutil
+                  libdrm
+                  libjpeg-turbo
+                  libmodule
+                  libxrandr
+                  libdrm
+                  libusb
+                  libx11
+                  libxext
+                  polkit-duktape
+                  wayland
+                  wayland-protocols))
+    (arguments
+     (list
+      #:tests? #f  ;;;tests not found
+      #:configure-flags #~(list "-DENABLE_GAMMA=1"
+                                "-DENABLE_DPMS=1"
+                                "-DENABLE_DDC=1"
+                                "-DENABLE_SCREEN=1"
+                                "-DENABLE_YOCTOLIGHT=1"
+                                (string-append "-DMODULE_LOAD_DIR=" #$output
+                                               "/etc/modprobe.d")
+                                (string-append "-DDBUS_CONFIG_DIR=" #$output
+                                               "/share/dbus-1/system.d"))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after
+              'patch-source-shebangs 'patch-target-dirs
+            (lambda _
+              (substitute* "./CMakeLists.txt"
+                (("DESTINATION \\$\\{SYSTEM_BUS_DIR\\}")
+                 (string-append "DESTINATION "
+                                #$output "/share/dbus-1/system-services"))
+                (("DESTINATION \\$\\{POLKIT_ACTION_DIR\\}")
+                 (string-append "DESTINATION "
+                                #$output "/share/polkit-1/actions"))))))))
+    (home-page "https://github.com/FedeDP/Clightd")
+    (description "Bus interface for many display capabilities")
+    (synopsis "Clightd is a bus interface that lets you easily set/get screen
+ brightness, gamma temperature and display dpms state. Moreover, it enables
+ getting ambient brightness through webcam frames capture or ALS devices.
+
+ It works on X, Wayland and tty.")
+    (license license:gpl3)))
+
 (define-public herbstluftwm
   (package
     (name "herbstluftwm")
-- 
2.38.1