Updated alsa & clock modules with new mechanism
This commit is contained in:
parent
14c0528be5
commit
98e46ac3d6
@ -46,6 +46,11 @@ class ALSA(IntervalModule):
|
|||||||
alsamixer = None
|
alsamixer = None
|
||||||
has_mute = True
|
has_mute = True
|
||||||
|
|
||||||
|
on_scrollup = "increase_volume"
|
||||||
|
on_scrolldown = "decrease_volume"
|
||||||
|
on_lclick = "switch_mute"
|
||||||
|
on_rclick = on_lclick
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
self.create_mixer()
|
self.create_mixer()
|
||||||
try:
|
try:
|
||||||
@ -82,18 +87,15 @@ class ALSA(IntervalModule):
|
|||||||
"color": self.color_muted if muted else self.color,
|
"color": self.color_muted if muted else self.color,
|
||||||
}
|
}
|
||||||
|
|
||||||
def on_leftclick(self):
|
def switch_mute(self):
|
||||||
self.on_rightclick()
|
|
||||||
|
|
||||||
def on_rightclick(self):
|
|
||||||
if self.has_mute:
|
if self.has_mute:
|
||||||
muted = self.alsamixer.getmute()[self.channel]
|
muted = self.alsamixer.getmute()[self.channel]
|
||||||
self.alsamixer.setmute(not muted)
|
self.alsamixer.setmute(not muted)
|
||||||
|
|
||||||
def on_upscroll(self):
|
def increase_volume(self, delta=None):
|
||||||
vol = self.alsamixer.getvolume()[self.channel]
|
vol = self.alsamixer.getvolume()[self.channel]
|
||||||
self.alsamixer.setvolume(min(100, vol + self.increment))
|
self.alsamixer.setvolume(min(100, vol + (delta if delta else self.increment)))
|
||||||
|
|
||||||
def on_downscroll(self):
|
def decrease_volume(self, delta=None):
|
||||||
vol = self.alsamixer.getvolume()[self.channel]
|
vol = self.alsamixer.getvolume()[self.channel]
|
||||||
self.alsamixer.setvolume(max(0, vol - self.increment))
|
self.alsamixer.setvolume(max(0, vol - (delta if delta else self.increment)))
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
from i3pystatus.core.settings import SettingsBase
|
from i3pystatus.core.settings import SettingsBase
|
||||||
from i3pystatus.core.threading import Manager
|
from i3pystatus.core.threading import Manager
|
||||||
from i3pystatus.core.util import convert_position
|
from i3pystatus.core.util import convert_position
|
||||||
|
from i3pystatus.core.command import run_through_shell
|
||||||
|
|
||||||
|
|
||||||
class Module(SettingsBase):
|
class Module(SettingsBase):
|
||||||
output = None
|
output = None
|
||||||
position = 0
|
position = 0
|
||||||
|
|
||||||
settings = (
|
settings = ('on_lclick', "Callback called on left click",
|
||||||
'on_lclick', "Callback called on left click",
|
|
||||||
'on_rclick', "Callback called on right click",
|
'on_rclick', "Callback called on right click",
|
||||||
'on_scrollup', "Callback called on scrolling up",
|
'on_scrollup', "Callback called on scrolling up",
|
||||||
'on_scrolldown', "Callback called on scrolling down",
|
'on_scrolldown', "Callback called on scrolling down",
|
||||||
@ -48,6 +48,9 @@ class Module(SettingsBase):
|
|||||||
cb = self.on_scrollup or "on_upscroll"
|
cb = self.on_scrollup or "on_upscroll"
|
||||||
elif button == 5: # mouse wheel down
|
elif button == 5: # mouse wheel down
|
||||||
cb = self.on_scrolldown or "on_downscroll"
|
cb = self.on_scrolldown or "on_downscroll"
|
||||||
|
else:
|
||||||
|
self.logger.debug("Button not handled")
|
||||||
|
return
|
||||||
|
|
||||||
if callable(cb):
|
if callable(cb):
|
||||||
return cb(self)
|
return cb(self)
|
||||||
|
Loading…
Reference in New Issue
Block a user