From 600b12aac9b8ee544147c52da39bd53d5798d8e0 Mon Sep 17 00:00:00 2001 From: Ultrabug Date: Thu, 30 Apr 2015 15:16:55 +0200 Subject: whatismyip module: add a negative cache timeout for quicker check when offline --- py3status/modules/whatismyip.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/py3status/modules/whatismyip.py b/py3status/modules/whatismyip.py index c44d7ea..cac4a0f 100644 --- a/py3status/modules/whatismyip.py +++ b/py3status/modules/whatismyip.py @@ -9,6 +9,7 @@ Configuration parameters: - format_online : what to display when online - hide_when_offline: hide the module output when offline (default False) - mode: default mode to display is 'ip' or 'status' (click to toggle) + - negative_cache_timeout: how often to check again when offline - timeout : how long before deciding we're offline @author ultrabug @@ -31,6 +32,7 @@ class Py3status: format_online = '●' hide_when_offline = False mode = 'ip' + negative_cache_timeout = 2 timeout = 5 def on_click(self, i3s_output_list, i3s_config, event): @@ -57,11 +59,12 @@ class Py3status: """ """ ip = self._get_my_ip() - response = {'cached_until': time() + self.cache_timeout} + response = {'cached_until': time() + self.negative_cache_timeout} if ip is None and self.hide_when_offline: response['full_text'] = '' elif ip is not None: + response['cached_until'] = time() + self.cache_timeout if self.mode == 'ip': response['full_text'] = self.format.format(ip=ip) else: -- cgit v1.3