@@ -67,7 +67,7 @@ def calculate_subwoofer_volume(spk_vol, balance):
67
67
else :
68
68
balL = balL - balance
69
69
balR = 100
70
-
70
+
71
71
valL = 87 * spk_vol * balL / 100 / 100 + extraVolume
72
72
valR = 87 * spk_vol * balR / 100 / 100 + extraVolume
73
73
@@ -77,7 +77,7 @@ def calculate_subwoofer_volume(spk_vol, balance):
77
77
78
78
def set_subwoofer ():
79
79
vol = get_biggest_volume ()
80
- subVols = calculate_subwoofer_volume (vol , subwooferBalance )
80
+ subVols = calculate_subwoofer_volume (vol , subwooferBalance )
81
81
set_subwoofer_volume (subVols )
82
82
83
83
# Speaker part
@@ -97,8 +97,8 @@ def calculate_speaker_balance(spk_vol, balance):
97
97
98
98
valL = spk_vol * balL / 100
99
99
valR = spk_vol * balR / 100
100
-
101
- return [valL , valR ]
100
+
101
+ return [valL , valR ]
102
102
103
103
def set_speaker_volumes (volumes ):
104
104
volumes = calibrate100 (volumes )
@@ -116,8 +116,8 @@ def set_speakers():
116
116
headphones_set = False
117
117
118
118
vol = get_biggest_volume ()
119
- spkVols = calculate_speaker_balance (vol , speakerBalance )
120
- set_speaker_volumes ( spkVols )
119
+ spkVols = calculate_speaker_balance (vol , speakerBalance )
120
+ set_speaker_volumes ( spkVols )
121
121
122
122
def get_biggest_volume ():
123
123
volumes = get_volumes ()
@@ -136,8 +136,8 @@ def get_volumes():
136
136
if '%' in line :
137
137
vol = line .split ('[' )[1 ].split ('%]' )[0 ]
138
138
output .append (int (vol ))
139
-
140
- return output
139
+
140
+ return output
141
141
142
142
# Headphones part
143
143
#################
@@ -153,14 +153,14 @@ def set_headphones():
153
153
speakers_set = False
154
154
155
155
vol = get_biggest_volume ()
156
- spkVols = calculate_speaker_balance (vol , headphonesBalance )
157
- set_speaker_volumes (spkVols )
156
+ spkVols = calculate_speaker_balance (vol , headphonesBalance )
157
+ set_speaker_volumes (spkVols )
158
158
159
159
def headphones_in_query ():
160
160
global headphones_in
161
161
amixer = subprocess .Popen (["amixer" , "-c" , str (devId ), "cget" , "numid=22" ], stdout = subprocess .PIPE , stderr = subprocess .PIPE )
162
162
163
- i = 0
163
+ i = 0
164
164
count = False
165
165
for line in iter (amixer .stdout .readline , '' ):
166
166
if "numid=22" in line :
@@ -172,9 +172,9 @@ def headphones_in_query():
172
172
headphones_in = False
173
173
elif "values=on" in line :
174
174
headphones_in = True
175
- break
176
-
177
- amixer .terminate ()
175
+ break
176
+
177
+ amixer .terminate ()
178
178
179
179
def check_headphones ():
180
180
headphones_in_query ()
@@ -201,22 +201,22 @@ def calibrate(volumes, limit):
201
201
elif volumes [1 ] < 0 :
202
202
volumes [1 ] = 0
203
203
204
- return [volumes [0 ], volumes [1 ]]
205
-
204
+ return [volumes [0 ], volumes [1 ]]
205
+
206
206
def calibrate100 (volumes ):
207
207
return calibrate (volumes , 100 )
208
208
209
209
def calibrate87 (volumes ):
210
- return calibrate (volumes , 87 )
210
+ return calibrate (volumes , 87 )
211
211
212
- def check_volume ():
212
+ def check_volume ():
213
213
global curr_volume
214
214
new_volume = get_biggest_volume ()
215
215
216
216
if curr_volume != new_volume :
217
217
curr_volume = new_volume
218
218
print "Volume change detected: " , curr_volume
219
-
219
+
220
220
if headphones_in == False :
221
221
set_subwoofer ()
222
222
@@ -259,7 +259,7 @@ def on_exit():
259
259
if "Event 'change' on sink #" + sinkNo in line :
260
260
check_headphones ()
261
261
check_volume ()
262
-
262
+
263
263
264
264
265
265
0 commit comments