Merge pull request #111 from teto/mousewheel

i3 next branch send click events on mouse wheel up/down. This patch allo...
This commit is contained in:
enkore 2014-09-04 14:01:08 +02:00
commit 73413efe4a
2 changed files with 19 additions and 0 deletions

View File

@ -25,6 +25,7 @@ class ALSA(IntervalModule):
("mixer", "ALSA mixer"),
("mixer_id", "ALSA mixer id"),
("card", "ALSA sound card"),
("increment","integer percentage of max volume to in/decrement volume on mousewheel"),
"muted", "unmuted",
"color_muted", "color",
"channel"
@ -40,6 +41,7 @@ class ALSA(IntervalModule):
mixer_id = 0
card = 0
channel = 0
increment = 5
alsamixer = None
has_mute = True
@ -79,3 +81,11 @@ class ALSA(IntervalModule):
"full_text": output_format.format(**self.fdict),
"color": self.color_muted if muted else self.color,
}
def on_upscroll(self):
vol = self.alsamixer.getvolume()
self.alsamixer.setvolume( vol[0] + self.increment)
def on_downscroll(self):
vol = self.alsamixer.getvolume()
self.alsamixer.setvolume( vol[0] - self.increment)

View File

@ -27,6 +27,10 @@ class Module(SettingsBase):
self.on_leftclick()
elif button == 3: # Right mouse button
self.on_rightclick()
elif button == 4: # mouse wheel up
self.on_upscroll()
elif button == 5: # mouse wheel down
self.on_downscroll()
def move(self, position):
self.position = position
@ -38,6 +42,11 @@ class Module(SettingsBase):
def on_rightclick(self):
pass
def on_upscroll(self):
pass
def on_downscroll(self):
pass
class IntervalModuleMeta(type):
"""Add interval setting to `settings` attribute if it does not exist."""