Changed pulseaudio with alsaaudio for volume control
This commit is contained in:
parent
7e480e4769
commit
192fbcc687
38
clock.py
38
clock.py
|
@ -67,7 +67,7 @@ from kivy.core.window import Window
|
||||||
if is_arm():
|
if is_arm():
|
||||||
Window.show_cursor = False
|
Window.show_cursor = False
|
||||||
|
|
||||||
import pulsectl
|
import alsaaudio
|
||||||
import vlc
|
import vlc
|
||||||
|
|
||||||
Builder.load_file('clock.kv')
|
Builder.load_file('clock.kv')
|
||||||
|
@ -176,6 +176,15 @@ class MyClockWidget(FloatLayout):
|
||||||
theme_selected = "Dark"
|
theme_selected = "Dark"
|
||||||
theme = ObjectProperty(Theme(theme_selected))
|
theme = ObjectProperty(Theme(theme_selected))
|
||||||
|
|
||||||
|
for x in ('', 'PCM'):
|
||||||
|
try:
|
||||||
|
mixer = alsaaudio.Mixer()
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
raise OSError('could not open mixer ' + x)
|
||||||
|
|
||||||
grabbed = ""
|
grabbed = ""
|
||||||
face_numbers = []
|
face_numbers = []
|
||||||
|
|
||||||
|
@ -966,13 +975,11 @@ class MyClockWidget(FloatLayout):
|
||||||
|
|
||||||
print("Volume changed to " + str(alarm_settings.volume))
|
print("Volume changed to " + str(alarm_settings.volume))
|
||||||
|
|
||||||
with pulsectl.Pulse('volume-increaser') as pulse:
|
# Volume is in 0-100 range
|
||||||
for sink in pulse.sink_list():
|
old_vol = self.mixer.getvolume()
|
||||||
# Volume is usually in 0-1.0 range, with >1.0 being soft-boosted
|
self.mixer.setvolume(int(alarm_settings.volume * 5.0))
|
||||||
old_vol = pulse.volume_get_all_chans(sink)
|
new_vol = self.mixer.getvolume()
|
||||||
pulse.volume_set_all_chans(sink, alarm_settings.volume / 20.0)
|
print("HW volume changed from " + str(old_vol) + " to " + str(new_vol))
|
||||||
new_vol = pulse.volume_get_all_chans(sink)
|
|
||||||
print("HW volume changed from " + str(old_vol) + " to " + str(new_vol))
|
|
||||||
|
|
||||||
|
|
||||||
def wake_up_brightness_slider_value(self, *args):
|
def wake_up_brightness_slider_value(self, *args):
|
||||||
|
@ -1294,15 +1301,6 @@ class MyApp(App):
|
||||||
alarm_settings = AlarmSettings()
|
alarm_settings = AlarmSettings()
|
||||||
update_rate = 60.0
|
update_rate = 60.0
|
||||||
|
|
||||||
# apply volume setting
|
|
||||||
with pulsectl.Pulse('volume-increaser') as pulse:
|
|
||||||
for sink in pulse.sink_list():
|
|
||||||
# Volume is usually in 0-1.0 range, with >1.0 being soft-boosted
|
|
||||||
old_vol = pulse.volume_get_all_chans(sink)
|
|
||||||
pulse.volume_set_all_chans(sink, alarm_settings.volume / 20.0)
|
|
||||||
new_vol = pulse.volume_get_all_chans(sink)
|
|
||||||
print("HW volume changed from " + str(old_vol) + " to " + str(new_vol))
|
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
clock_widget = MyClockWidget()
|
clock_widget = MyClockWidget()
|
||||||
|
|
||||||
|
@ -1318,6 +1316,12 @@ class MyApp(App):
|
||||||
if is_arm():
|
if is_arm():
|
||||||
Window.borderless = True
|
Window.borderless = True
|
||||||
|
|
||||||
|
# Volume is in 0-100 range
|
||||||
|
old_vol = clock_widget.mixer.getvolume()
|
||||||
|
clock_widget.mixer.setvolume(int(self.alarm_settings.volume * 5.0))
|
||||||
|
new_vol = clock_widget.mixer.getvolume()
|
||||||
|
print("HW volume changed from " + str(old_vol) + " to " + str(new_vol))
|
||||||
|
|
||||||
return clock_widget
|
return clock_widget
|
||||||
|
|
||||||
def except_hook(type, value, tb):
|
def except_hook(type, value, tb):
|
||||||
|
|
Loading…
Reference in New Issue