diff --git a/bumblebee/modules/ping.py b/bumblebee/modules/ping.py index 469871a..e19d603 100644 --- a/bumblebee/modules/ping.py +++ b/bumblebee/modules/ping.py @@ -30,6 +30,11 @@ def get_rtt(module, widget): )) for line in res.split("\n"): + if line.startswith( "{} packets transmitted".format( widget.get( "rtt-probes" ) ) ): + m = re.search( r'(\d+)% packet loss', line ) + + widget.set( 'packet-loss', m.group(1) ) + if not line.startswith("rtt"): continue m = re.search(r'([0-9\.]+)/([0-9\.]+)/([0-9\.]+)/([0-9\.]+)\s+(\S+)', line) @@ -51,16 +56,18 @@ class Module(bumblebee.engine.Module): widget.set("rtt-timeout", self.parameter("timeout", 5.0)) widget.set("rtt-avg", 0.0) widget.set("rtt-unit", "") + widget.set('packet-loss', 0) self._next_check = 0 def rtt(self, widget): if widget.get("rtt-unreachable"): return "{}: unreachable".format(widget.get("address")) - return "{}: {:.1f}{}".format( + return "{}: {:.1f}{} ({}%)".format( widget.get("address"), widget.get("rtt-avg"), - widget.get("rtt-unit") + widget.get("rtt-unit"), + widget.get( 'packet-loss' ) ) def state(self, widget): diff --git a/bumblebee/modules/sensors.py b/bumblebee/modules/sensors.py index d76d10e..4f1a879 100644 --- a/bumblebee/modules/sensors.py +++ b/bumblebee/modules/sensors.py @@ -11,6 +11,9 @@ Parameters: """ import re +import decimal + +from subprocess import call import bumblebee.input import bumblebee.output @@ -36,10 +39,21 @@ class Module(bumblebee.engine.Module): return temperature + def get_mhz( self ): + output = open( '/proc/cpuinfo' ).read() + m = re.search( r"cpu MHz\s+:\s+(\d+)", output ) + mhz = int( m.group( 1 ) ) + + if mhz < 1000: + return "{} MHz".format( mhz ) + else: + return "%.1f GHz" % ( decimal.Decimal( mhz ) / 1000 ) + def temperature(self, _): - return self._temperature + return u"{}°c @ {}".format( self._temperature, self._mhz ) def update(self, widgets): self._temperature = self.get_temp() + self._mhz = self.get_mhz() # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/bumblebee/modules/weather.py b/bumblebee/modules/weather.py index 01420e3..92a2745 100644 --- a/bumblebee/modules/weather.py +++ b/bumblebee/modules/weather.py @@ -51,6 +51,27 @@ class Module(bumblebee.engine.Module): return u"?" return u"{}°{}".format(self._temperature, self._unit_suffix()) + def state( self, widget ): + if self._valid: + if "thunderstorm" in self._weather: + return [ 'thunder' ] + elif "drizzle" in self._weather: + return [ 'rain' ] + elif "rain" in self._weather: + return [ 'rain' ] + elif "snow" in self._weather: + return [ 'snow' ] + elif "sleet" in self._weather: + return [ 'sleet' ] + elif "clear" in self._weather: + return [ 'clear' ] + elif "cloud" in self._weather: + return [ 'clouds' ] + else: + return [] + + return [] + def update(self, widgets): timestamp = int(time.time()) if self._nextcheck < int(time.time()): @@ -67,6 +88,7 @@ class Module(bumblebee.engine.Module): weather_url = "{url}&q={city}".format(url=weather_url, city=self._location) weather = json.loads(requests.get(weather_url).text) self._temperature = int(weather['main']['temp']) + self._weather = weather['weather'][0]['main'].lower() self._valid = True except RequestException: self._valid = False diff --git a/themes/icons/awesome-fonts.json b/themes/icons/awesome-fonts.json index 7ce09e9..bf95f55 100644 --- a/themes/icons/awesome-fonts.json +++ b/themes/icons/awesome-fonts.json @@ -5,8 +5,9 @@ }, "date": { "prefix": "" }, "time": { "prefix": "" }, + "datetime": { "prefix": "" }, "memory": { "prefix": "" }, - "cpu": { "prefix": "" }, + "cpu": { "prefix": "" }, "disk": { "prefix": "" }, "dnf": { "prefix": "" }, "pacman": { "prefix": "" }, @@ -79,7 +80,7 @@ "on": { "prefix": " "}, "off": { "prefix": " " } }, "redshift": { - "day": { "prefix": "" }, "night": { "prefix": "" }, "transition": { "prefix": "" } + "day": { "prefix": "" }, "night": { "prefix": "" }, "transition": { "prefix": "" } }, "sensors": { "prefix": "" @@ -107,5 +108,12 @@ }, "publicip": { "prefix": "  " + }, + "weather": { + "clouds": { "prefix": "" }, + "rain": { "prefix": "" }, + "snow": { "prefix": "" }, + "clear": { "prefix": "" }, + "thunder": { "prefix": "" } } }