stumpwm/sound.lisp @ 6c4c335faf47

Merge
author Steve Losh <steve@stevelosh.com>
date Tue, 06 Aug 2024 10:56:16 -0400
parents 4e1d6d6873fe
children (none)
(in-package :stumpwm-user)

(defun volume% ()
  (_ (run-shell-command "amixer sget Master" t)
    (string-grep "Front Left:" _ :first-only t)
    (string-split "[]" _)
    second
    (string-trim "%" _)
    parse-integer))

(defcached (volume :seconds 30)
  (volume%))

(defcommand mute () ()
  (run-shell-command "mute")
  (volume/uncache)
  (echo "Muted."))

(defcommand volume-up () ()
  (run-shell-command "amixer -q sset Master 5%+")
  (volume/uncache)
  (message "Volume: ~D%" (volume)))

(defcommand volume-down () ()
  (run-shell-command "amixer -q sset Master 5%-")
  (volume/uncache)
  (message "Volume: ~D%" (volume)))

(defun volume-modeline (ml)
  (declare (ignore ml))
  (format nil "~D%" (volume)))

(add-screen-mode-line-formatter #\V #'volume-modeline)

#; Scratch --------------------------------------------------------------------
(volume)