Skip to content

Commit

Permalink
Let widget hdd crash if there is a problem with the device
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-lnx authored and tych0 committed Apr 28, 2024
1 parent f0a2fc0 commit 1f62b9b
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions libqtile/widget/hdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,14 @@ def __init__(self, **config):

def poll(self):
variables = dict()
# Field index 9 contains the number of milliseconds the device has been performing I/O operations
with open(self.path) as f:
io_ticks = int(f.read().split()[9])

try:
# Field index 9 contains the number of milliseconds the device has been performing I/O operations
with open(self.path) as f:
io_ticks = int(f.read().split()[9])
variables["HDDPercent"] = round(
max(min(((io_ticks - self._prev) / self.update_interval) / 10, 100.0), 0.0), 1
)

variables["HDDPercent"] = round(
max(min(((io_ticks - self._prev) / self.update_interval) / 10, 100.0), 0.0), 1
)

self._prev = io_ticks

except IOError:
variables["HDDPercent"] = 0
self._prev = io_ticks

return self.format.format(**variables)

0 comments on commit 1f62b9b

Please sign in to comment.