audio.lisp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. (in-package :stumpwm)
  2. ;; Look for audio devices ‘mpv --audio-device=help’
  3. (defvar *headphones*
  4. "pulse/alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo"
  5. "Pulseaudio device. Heaphones.")
  6. (defcommand osd-sound () ()
  7. (run-shell-command "if pgrep -f osd-sound > /dev/null; then pkill osd-sound; osd-sound; else osd-sound; fi"))
  8. (defun volume-current ()
  9. (if (= 1 (parse-integer (run-shell-command "ponymix is-muted && printf 0 || printf 1" t)))
  10. (bar (parse-integer (string-trim '(#\Newline) (run-shell-command "ponymix get-volume" t))) 10
  11. #\#
  12. #\ )
  13. "MUTED"))
  14. (defcommand volume-current-message () ()
  15. (message (format nil "~a ~a"
  16. "Volume:"
  17. (volume-current))))
  18. (defcommand volume-current-update () ()
  19. (sb-thread:make-thread
  20. (lambda ()
  21. (setq *volume-current* (volume-current)))
  22. :name "volume-current-update"))
  23. (defcommand volume-decrease () ()
  24. (run-shell-command "ponymix decrease 5")
  25. (volume-current-update)
  26. (unless (head-mode-line (current-head))
  27. (volume-current-message)))
  28. (defcommand volume-increase () ()
  29. (run-shell-command "ponymix increase 5")
  30. (volume-current-update)
  31. (unless (head-mode-line (current-head))
  32. (volume-current-message)))
  33. (defcommand volume-toggle () ()
  34. (run-shell-command "ponymix toggle")
  35. (volume-current-update)
  36. (unless (head-mode-line (current-head))
  37. (volume-current-message)))
  38. (define-interactive-keymap volume nil
  39. ((kbd "-") "volume-decrease")
  40. ((kbd "=") "volume-increase"))
  41. (defcommand volume-increase-device-0 () ()
  42. (run-shell-command "ponymix increase --device 0 5"))
  43. (defcommand volume-decrease-device-0 () ()
  44. (run-shell-command "ponymix decrease --device 0 5"))
  45. (defcommand pavucontrol () ()
  46. (run-shell-command "pavucontrol"))
  47. (defcommand pulsemixer () ()
  48. (term-shell-command "pulsemixer" :terminal 'st :font "Monospace:size=8"))
  49. (defcommand pulseaudio-toggle-ladspa () ()
  50. (run-shell-command
  51. (concat (getenv "HOME")
  52. "/.local/share/chezmoi/src/python/pulseaudio/sink.py")))
  53. (defcommand alsamixer () ()
  54. "Download video."
  55. (run-shell-command "exec xterm -name alsamixer -e alsamixer"))