]> git.ekhem.eu.org Git - guix.git/commitdiff
[system] Package a script for controlling volume level.
authorJakub Czajka <jakub@ekhem.eu.org>
Fri, 23 Dec 2022 20:45:38 +0000 (21:45 +0100)
committerJakub Czajka <jczajka@google.com>
Sun, 24 Dec 2023 18:53:07 +0000 (19:53 +0100)
conf/system/volume.scm [new file with mode: 0644]
scripts/volume [new file with mode: 0755]
system.scm

diff --git a/conf/system/volume.scm b/conf/system/volume.scm
new file mode 100644 (file)
index 0000000..7f457bf
--- /dev/null
@@ -0,0 +1,41 @@
+;; Copyright (c) 2022 Jakub Czajka <jakub@ekhem.eu.org>
+;; License: GPL-3.0 or later.
+;;
+;; volume.scm - package for controling system's volume.
+
+(define-module (conf system volume)
+  #:use-module (gnu packages linux)
+  #:use-module (gnu services)
+  #:use-module (guix build-system trivial)
+  #:use-module (guix gexp)
+  #:use-module (guix licenses)
+  #:use-module (guix packages)
+  #:export (volume))
+
+(define volume
+  (package
+   (name "volume")
+   (version "1.0")
+   (source
+    (local-file
+     (string-concatenate
+      (list (getenv "GUIX_PACKAGE_PATH")
+           "/scripts/volume"))))
+   (build-system trivial-build-system)
+   (arguments
+    '(#:modules ((guix build utils))
+      #:builder
+      (begin
+       (use-modules (guix build utils))
+
+       (let* ((ins  (assoc-ref %build-inputs "source"))
+              (out  (assoc-ref %outputs "out"))
+              (dir  (string-concatenate (list out "/bin")))
+              (file (string-append dir "/volume")))
+         (mkdir-p dir)
+         (copy-file ins file)
+         (chmod file #o555)))))
+   (synopsis "Script for controlling the volume level.")
+   (description "Wraps a scripts which can control system's volume level.")
+   (home-page "https://git.ekhem.eu.org")
+   (license gpl3+)))
diff --git a/scripts/volume b/scripts/volume
new file mode 100755 (executable)
index 0000000..fb7ed0e
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+# Copyright (c) 2022 Jakub Czajka <jakub@ekhem.eu.org>
+# License: GPL-3.0 or later.
+
+if [ -z "${1}" ]
+then
+    echo "New volume level not specified"
+    exit 1
+fi
+
+SCARD=$(amixer | head -n1 | cut -d\' -f2)
+amixer set "${SCARD}" "${1}"
index ca9f2bee5ff29c80d8267f25f48e29002c1ea9bf..26bf5a9bdb649aefac32f30010d64f6e050a43a7 100644 (file)
@@ -3,7 +3,8 @@
 ;;
 ;; system.scm - system configuration for GNU Guix.
 
-(use-modules (gnu)
+(use-modules (conf system volume)
+             (gnu)
              (gnu system nss))
 
 (use-package-modules certs
@@ -59,7 +60,8 @@
  (packages
   (append
    (list gnu-make
-        nss-certs)
+        nss-certs
+        volume)
    %base-packages))
  (timezone "Europe/Warsaw")
  (locale "en_US.UTF-8")