-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdionysos-volume.el
105 lines (77 loc) · 3.18 KB
/
dionysos-volume.el
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
;;; dionysos-volume.el --- Dionysos volume management
;; Copyright (C) 2015-2016 Nicolas Lamirault <[email protected]>
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License
;; as published by the Free Software Foundation; either version 2
;; of the License, or (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
;; 02110-1301, USA.
;;; Commentary:
;;; Code:
(require 'dionysos-process)
;; ------------------
;; Customization
;; ------------------
(defgroup dionysos-volume nil
"Customization group for `dionysos-volume'."
:prefix "dionysos-volume-"
:tag "Dionysos volume management"
:group 'dionysos)
(defcustom dionysos-volume-cmd 'pamixer
"Command to control the mixer."
:group 'dionysos-volume
:type '(choice
(const :tag "amixer" amixer)
(const :tag "pamixer" pamixer)))
;; ------------------
;; Intern
;; ------------------
(defconst dionysos--volume-process "dionysos-volume"
"The process name for Dionysos volume management process.")
(defconst dionysos--volume-amixer-increase-args
(list "-q" "sset" "Master" "5%+")
"Arguments to increase volume for amixer.")
(defconst dionysos--volume-amixer-decrease-args
(list "-q" "sset" "Master" "5%-")
"Arguments to decrease volume for amixer.")
(defconst dionysos--volume-pamixer-increase-args
(list "-i" "5")
"Arguments to increase volume for pamixer.")
(defconst dionysos--volume-pamixer-decrease-args
(list "-d" "5")
"Arguments to decrease volume for pamixer.")
;; ------------------
;; API
;; ------------------
(defun dionysos-volume-raise ()
"Raise volume."
(interactive)
(cond ((eql 'amixer dionysos-volume-cmd)
(dionysos--create-process dionysos--volume-process
"amixer"
dionysos--volume-amixer-increase-args))
((eql 'pamixer dionysos-volume-cmd)
(dionysos--create-process dionysos--volume-process
"pamixer"
dionysos--volume-pamixer-increase-args))
(t (message "No volume command available."))))
(defun dionysos-volume-decrease ()
"Decrease volume."
(interactive)
(cond ((eql 'amixer dionysos-volume-cmd)
(dionysos--create-process dionysos--volume-process
"amixer"
dionysos--volume-amixer-decrease-args))
((eql 'pamixer dionysos-volume-cmd)
(dionysos--create-process dionysos--volume-process
"pamixer"
dionysos--volume-pamixer-decrease-args))
(t (message "No volume command available."))))
(provide 'dionysos-volume)
;;; dionysos-volume.el ends here