Skip to content

Commit

Permalink
Add NotAvailable value to Memory widget
Browse files Browse the repository at this point in the history
Provides a new value, `NotAvailable`, as an alternative to `Used`. The
latter takes account of buffers and caches.
  • Loading branch information
elParaguayo committed May 14, 2024
1 parent a00b174 commit 2d5c7f3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libqtile/widget/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Memory(base.ThreadPoolText):
- ``MemTotal``: Total amount of memory.
- ``MemFree``: Amount of memory free.
- ``Available``: Amount of memory available.
- ``NotAvailable``: Equal to ``MemTotal`` - ``MemAvailable``
- ``MemPercent``: Memory in use as a percentage.
- ``Buffers``: Buffer amount.
- ``Active``: Active memory.
Expand All @@ -49,6 +50,7 @@ class Memory(base.ThreadPoolText):
Widget requirements: psutil_.
.. _psutil: https://pypi.org/project/psutil/
"""

defaults = [
Expand All @@ -74,6 +76,7 @@ def poll(self):
val["MemTotal"] = mem.total / self.calc_mem
val["MemFree"] = mem.free / self.calc_mem
val["Available"] = mem.available / self.calc_mem
val["NotAvailable"] = (mem.total - mem.available) / self.calc_mem
val["MemPercent"] = mem.percent
val["Buffers"] = mem.buffers / self.calc_mem
val["Active"] = mem.active / self.calc_mem
Expand All @@ -85,4 +88,5 @@ def poll(self):
val["SwapPercent"] = swap.percent
val["mm"] = self.measure_mem
val["ms"] = self.measure_swap

return self.format.format(**val)

0 comments on commit 2d5c7f3

Please sign in to comment.