summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Wilken2022-10-30 12:24:32 +0100
committerTimo Wilken2022-10-30 12:24:32 +0100
commit3396d94d0aa98185336665357180c7c1e764398e (patch)
tree80c8e4d958a4e602045f963034c255a9584632ed
parentfcf5b9d9760145ae5de7d34794fc0f536db89665 (diff)
Don't use `with-imported-modules' for built-in modules
-rw-r--r--home-configuration.scm166
1 files changed, 80 insertions, 86 deletions
diff --git a/home-configuration.scm b/home-configuration.scm
index 69da0f71..7d34386e 100644
--- a/home-configuration.scm
+++ b/home-configuration.scm
@@ -73,27 +73,25 @@
Each item in SUBSTITUTIONS is a `cons' of a regular expression and a
replacement spec (to which `regexp-substitute/global' is applied)."
(computed-file name
- (with-imported-modules '((ice-9 regex)
- (ice-9 textual-ports))
- #~(begin
- (use-modules (ice-9 regex)
- (ice-9 textual-ports))
- (call-with-output-file #$output
- (lambda (oport)
- (call-with-input-file #$input-file
- (lambda (iport)
- (let loop ((output (get-string-all iport))
- (substitutions '#$substitutions))
- (if (null? substitutions)
- (put-string oport output)
- (loop (call-with-output-string
- (lambda (sport)
- (apply regexp-substitute/global
- sport
- (caar substitutions)
- output
- (cdar substitutions))))
- (cdr substitutions))))))))))))
+ #~(begin
+ (use-modules (ice-9 regex)
+ (ice-9 textual-ports))
+ (call-with-output-file #$output
+ (lambda (oport)
+ (call-with-input-file #$input-file
+ (lambda (iport)
+ (let loop ((output (get-string-all iport))
+ (substitutions '#$substitutions))
+ (if (null? substitutions)
+ (put-string oport output)
+ (loop (call-with-output-string
+ (lambda (sport)
+ (apply regexp-substitute/global
+ sport
+ (caar substitutions)
+ output
+ (cdar substitutions))))
+ (cdr substitutions)))))))))))
(define gui-packages
'(;; i3 and Xorg. i3 itself must be installed system-wide for gdm to pick it up.
@@ -270,71 +268,67 @@ replacement spec (to which `regexp-substitute/global' is applied)."
(".local/bin/volume"
,(program-file
"volume"
- (with-imported-modules '((ice-9 format)
- (ice-9 match)
- (ice-9 popen)
- (ice-9 regex)
- (ice-9 textual-ports))
- #~(begin
- (use-modules (ice-9 format)
- (ice-9 match)
- (ice-9 popen)
- (ice-9 regex)
- (ice-9 textual-ports))
-
- (define (read-from-pactl . args)
- (let* ((port (apply open-pipe* OPEN_READ
- #$(package-binary "pulseaudio" "pactl") args))
- (output (get-string-all port)))
- (close-pipe port)
- (string-trim-right output #\newline)))
-
- (define %default-sink
- (read-from-pactl "get-default-sink"))
-
- (define* (sink-muted? #:optional (sink %default-sink))
- (match (read-from-pactl "get-sink-mute" sink)
- ("Mute: yes" #t)
- ("Mute: no" #f)
- (output (error "Unknown `pactl get-sink-mute' output" output))))
-
- (define* (sink-volume #:optional (sink %default-sink))
- (match-let ((`#(,match (,start . ,end))
- (string-match "[0-9]+%" (read-from-pactl "get-sink-volume" sink))))
- (string->number (substring match start (1- end))))) ; trim trailing "%"
-
- (define* (set-sink-mute! #:optional (state "toggle") (sink %default-sink))
- (status:exit-val
- (system* #$(package-binary "pulseaudio" "pactl") "set-sink-mute" sink state)))
-
- (define* (increment-sink-volume! increment-percent #:optional (sink %default-sink))
- (status:exit-val
- (system* #$(package-binary "pulseaudio" "pactl")
- "set-sink-volume" sink
- ;; A percentage with a sign is an increment.
- (format #f "~@d%" increment-percent))))
-
- (define* (notify #:optional (muted? (sink-muted?)) (volume (sink-volume)))
- (status:exit-val
- (system* "dunstify" "-a" "volume" "-u" "low"
- "-i" (cond (muted? "audio-volume-muted")
- ((< volume 50) "audio-volume-low")
- (#t "audio-volume-high"))
- "-h" "string:x-canonical-private-synchronous:volume"
- "-h" (format #f "int:value:~d" (if muted? 0 volume))
- (if muted? "Volume muted" "Volume"))))
-
- (match (cdr (program-arguments))
- (() 0) ; notify only
- (("mute") (set-sink-mute! "true"))
- (("unmute") (set-sink-mute! "false"))
- (("toggle-mute") (set-sink-mute! "toggle"))
- (((? string->number increment-percent))
- (and (set-sink-mute! "false")
- (increment-sink-volume!
- (string->number increment-percent))))
- (args (error "Could not parse command-line arguments:" args)))
- (notify)))))))))
+ #~(begin
+ (use-modules (ice-9 format)
+ (ice-9 match)
+ (ice-9 popen)
+ (ice-9 regex)
+ (ice-9 textual-ports))
+
+ (define (read-from-pactl . args)
+ (let* ((port (apply open-pipe* OPEN_READ
+ #$(package-binary "pulseaudio" "pactl") args))
+ (output (get-string-all port)))
+ (close-pipe port)
+ (string-trim-right output #\newline)))
+
+ (define %default-sink
+ (read-from-pactl "get-default-sink"))
+
+ (define* (sink-muted? #:optional (sink %default-sink))
+ (match (read-from-pactl "get-sink-mute" sink)
+ ("Mute: yes" #t)
+ ("Mute: no" #f)
+ (output (error "Unknown `pactl get-sink-mute' output" output))))
+
+ (define* (sink-volume #:optional (sink %default-sink))
+ (match-let ((`#(,match (,start . ,end))
+ (string-match "[0-9]+%" (read-from-pactl "get-sink-volume" sink))))
+ (string->number (substring match start (1- end))))) ; trim trailing "%"
+
+ (define* (set-sink-mute! #:optional (state "toggle") (sink %default-sink))
+ (status:exit-val
+ (system* #$(package-binary "pulseaudio" "pactl") "set-sink-mute" sink state)))
+
+ (define* (increment-sink-volume! increment-percent #:optional (sink %default-sink))
+ (status:exit-val
+ (system* #$(package-binary "pulseaudio" "pactl")
+ "set-sink-volume" sink
+ ;; A percentage with a sign is an increment.
+ (format #f "~@d%" increment-percent))))
+
+ (define* (notify #:optional (muted? (sink-muted?)) (volume (sink-volume)))
+ (status:exit-val
+ (system* #$(package-binary "dunst" "dunstify")
+ "-a" "volume" "-u" "low"
+ "-i" (cond (muted? "audio-volume-muted")
+ ((< volume 50) "audio-volume-low")
+ (#t "audio-volume-high"))
+ "-h" "string:x-canonical-private-synchronous:volume"
+ "-h" (format #f "int:value:~d" (if muted? 0 volume))
+ (if muted? "Volume muted" "Volume"))))
+
+ (match (cdr (program-arguments))
+ (() 0) ; notify only
+ (("mute") (set-sink-mute! "true"))
+ (("unmute") (set-sink-mute! "false"))
+ (("toggle-mute") (set-sink-mute! "toggle"))
+ (((? string->number increment-percent))
+ (and (set-sink-mute! "false")
+ (increment-sink-volume!
+ (string->number increment-percent))))
+ (args (error "Could not parse command-line arguments:" args)))
+ (notify))))))))
(home-environment
(packages