-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvolume.lisp
49 lines (38 loc) · 1.2 KB
/
volume.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
;;; Setup pavol
;;; Load package
(in-package :stumpwm)
(load-module :pavol)
;;; Changes to pavol to get volume to 150%
;;; This follows the maximum volume allowed by pavolcontrol
;;; This is to hacky to merge
(in-package :pavol)
(defparameter *max-volume* (if t
150
100)
"The maximum allowed volume.
pavucontrol allows a max volume percentage of 150.
this may damage the speakers so make it be explicatly set.
The default value is 100.")
(defmethod (setf volume) (percentage (sink sink))
(assert (<= 0 percentage *max-volume*))
(pacmd "set-sink-volume ~a ~a"
(sink-index sink)
(percentage->integer percentage))
percentage)
(defun volume-up (sink percentage)
(setf (volume sink) (min (+ (volume sink) percentage) *max-volume*)))
(defun make-volume-bar (percent)
"Return a string that represents a volume bar"
(format nil "^B~3d%^b [^[^7*~a^]]"
percent (stumpwm::bar (min 100 percent) 50 #\# #\:)))
;;; Setup keybindings
(in-package :stumpwm)
(define-key *top-map*
(kbd "XF86AudioRaiseVolume")
"pavol-vol+")
(define-key *top-map*
(kbd "XF86AudioLowerVolume")
"pavol-vol-")
(define-key *top-map*
(kbd "XF86AudioMute")
"pavol-toggle-mute")