コード例 #1
0
ファイル: listener.py プロジェクト: hobarrera/volctl2
class MediaKeyListener(BaseXListener):
    """
    Thread that listens to mouse buttons presses.
    """

    def run(self):
        self.listen(device_events=(X.KeyPress, X.KeyRelease))

    def processEvent(self, event):
        if event.detail not in [121, 122, 123]:
            return
        if event.type == X.KeyPress:
            if not self.volume_modifier.is_alive():
                self.volume_modifier = VolumeModifierThread(self.volume)
            if event.detail == 122:
                self.volume_modifier.delta = -3
            elif event.detail == 123:
                self.volume_modifier.delta = +3
            elif event.detail == 121:
                self.volume_modifier.toggle_mute()
                self.volume_modifier.stop()
            if not self.volume_modifier.is_alive() and \
                    event.detail in [122, 123]:
                self.volume_modifier.start()
        elif event.type == X.KeyRelease:
            self.stop()
コード例 #2
0
ファイル: listener.py プロジェクト: hobarrera/volctl2
class MouseButtonListener(BaseXListener):
    """
    Thread that listens to mouse buttons presses.
    """

    def run(self):
        self.listen(device_events=(X.ButtonPress, X.ButtonRelease))

    def processEvent(self, event):
        if event.detail not in [10, 13]:
            return
        if event.type == X.ButtonPress:
            if not self.volume_modifier.is_alive():
                self.volume_modifier = VolumeModifierThread(self.volume)
            if event.detail == 10:
                self.volume_modifier.delta = -3
            elif event.detail == 13:
                self.volume_modifier.delta = +3
            if not self.volume_modifier.is_alive():
                self.volume_modifier.start()
        elif event.type == X.ButtonRelease:
            self.stop()