From a40ba18272112e180205910f5c8007e8b1ecbd0d Mon Sep 17 00:00:00 2001 From: facetoe Date: Sun, 11 Jan 2015 10:10:31 +0800 Subject: [PATCH] Allow users to scroll through interfaces. --- i3pystatus/network.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/i3pystatus/network.py b/i3pystatus/network.py index f11da78..9d021e9 100644 --- a/i3pystatus/network.py +++ b/i3pystatus/network.py @@ -289,6 +289,8 @@ class Network(IntervalModule, ColorRangeModule): on_leftclick = "nm-connection-editor" on_rightclick = "cycle_interface" + on_upscroll = ['cycle_interface', 1] + on_downscroll = ['cycle_interface', -1] def init(self): # Don't require importing basiciw unless using the functionality it offers. @@ -311,10 +313,10 @@ class Network(IntervalModule, ColorRangeModule): self.colors = self.get_hex_color_range(self.start_color, self.end_color, int(self.upper_limit)) self.kbs_arr = [0.0] * self.graph_width - def cycle_interface(self): + def cycle_interface(self, increment=1): interfaces = [i for i in netifaces.interfaces() if i not in self.ignore_interfaces] if self.interface in interfaces: - next_index = (interfaces.index(self.interface) + 1) % len(interfaces) + next_index = (interfaces.index(self.interface) + increment) % len(interfaces) self.interface = interfaces[next_index] elif len(interfaces) > 0: self.interface = interfaces[0]