Module progress: added states

This commit is contained in:
Rémi Dupré 2018-09-07 17:14:40 +02:00
parent 56426ee0a6
commit 384f23c34f
No known key found for this signature in database
GPG key ID: 88498F75F2DBC639
2 changed files with 16 additions and 1 deletions

View file

@ -40,7 +40,7 @@ class Module(bumblebee.engine.Module):
) )
str_format = self.parameter("format", '{bar} {cmd} {arg}') str_format = self.parameter("format", '{bar} {cmd} {arg}')
return "" + str_format.format( return str_format.format(
bar = bar, bar = bar,
pid = widget.get("pid"), pid = widget.get("pid"),
cmd = widget.get("cmd"), cmd = widget.get("cmd"),
@ -54,6 +54,8 @@ class Module(bumblebee.engine.Module):
return self.parameter("placeholder", 'n/a') return self.parameter("placeholder", 'n/a')
def update_progress_info(self, widget): def update_progress_info(self, widget):
"""Update widget's informations about the copy"""
# These regex extracts following groups: # These regex extracts following groups:
# 1. pid # 1. pid
# 2. command # 2. command
@ -89,3 +91,13 @@ class Module(bumblebee.engine.Module):
except Exception: except Exception:
return False return False
def state(self, widget):
if self._active():
return "copying"
return "pending"
def _active(self):
"""Checks wether a copy is running or not"""
raw = bumblebee.util.execute("progress -q")
return bool(raw)

View file

@ -138,5 +138,8 @@
}, },
"taskwarrior": { "taskwarrior": {
"prefix": "  " "prefix": "  "
},
"progress": {
"copying": { "prefix": "" }
} }
} }