Control pulseaudio volumes with a Griffin Powermate using https://github.com/bethebunny/powermate and https://github.com/mk-fg/python-pulse-control
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
751 B

#!/usr/bin/python
import glob
from lib.powermate import powermate
from lib.python_pulse_control.pulsectl import pulsectl
INCREASE_AMOUNT = 0.01
class PowerMate(powermate.PowerMateBase):
def __init__(self, path):
self.pulse = pulsectl.Pulse()
super().__init__(path)
def rotate(self, rotation):
#print(rotation);
if (rotation > 0):
self.change_vol(INCREASE_AMOUNT)
else:
self.change_vol(-INCREASE_AMOUNT)
def change_vol(self, vol):
for sink in self.pulse.sink_list():
#print(sink)
self.pulse.volume_change_all_chans(sink, vol)
if __name__ == '__main__':
pm = PowerMate(glob.glob('/dev/input/by-id/*PowerMate*')[0])
pm.run()