From 5082aaae0c7d56547e2be33da6a5cd86d346afb1 Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Thu, 1 Aug 2019 14:37:23 -0400 Subject: [PATCH] initial commit --- .gitignore | 1 + .gitmodules | 6 ++++++ lib/powermate | 1 + lib/python_pulse_control | 1 + powermate_pactl.py | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 44 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 160000 lib/powermate create mode 160000 lib/python_pulse_control create mode 100755 powermate_pactl.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c18dd8d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..bb45568 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "lib/powermate"] + path = lib/powermate + url = https://github.com/bethebunny/powermate +[submodule "lib/python_pulse_control"] + path = lib/python_pulse_control + url = https://github.com/mk-fg/python-pulse-control diff --git a/lib/powermate b/lib/powermate new file mode 160000 index 0000000..d7b6628 --- /dev/null +++ b/lib/powermate @@ -0,0 +1 @@ +Subproject commit d7b6628b10171a6f5245ff9c9a6b57fe5cc4766e diff --git a/lib/python_pulse_control b/lib/python_pulse_control new file mode 160000 index 0000000..902d5e9 --- /dev/null +++ b/lib/python_pulse_control @@ -0,0 +1 @@ +Subproject commit 902d5e9e5591b89c356e5194a370212e23fb0e93 diff --git a/powermate_pactl.py b/powermate_pactl.py new file mode 100755 index 0000000..2d56356 --- /dev/null +++ b/powermate_pactl.py @@ -0,0 +1,35 @@ +#!/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()