aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-03-10 11:04:51 +0100
committerMattias Andrée <maandree@kth.se>2017-03-10 11:04:51 +0100
commit218792a672aafe2971181b17e4b124c36ef6486e (patch)
tree3fb782d5ccdb02d33fe93559cc4e24d92faf0301 /src
parentfix powersupply (diff)
downloadxpybar-218792a672aafe2971181b17e4b124c36ef6486e.tar.gz
xpybar-218792a672aafe2971181b17e4b124c36ef6486e.tar.bz2
xpybar-218792a672aafe2971181b17e4b124c36ef6486e.tar.xz
Improve lid plugin1.19
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/lid.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/plugins/lid.py b/src/plugins/lid.py
index ed25bf8..29555d3 100644
--- a/src/plugins/lid.py
+++ b/src/plugins/lid.py
@@ -30,12 +30,15 @@ class Lid:
'''
Check whether the lid is open
- @param :bool? `True` if the lid is open,
- `False` if the lid is closed,
- `None` if there is no lid, or if the
- computer does not report the lid's state
+ @param :dict<str, bool> A map from the ID:s of the lids (you probably just
+ have one or zero) to `True` for open and `False`
+ for closed.
'''
- if not os.path.exists('/proc/acpi/button/lid/LID/state'):
- return None
- with open('/proc/acpi/button/lid/LID/state', 'rb') as file:
- return 'open' in file.read().decode('utf-8', 'strict')
+ ret = {}
+ for lid in os.listdir('/proc/acpi/button/lid/'):
+ try:
+ with open('/proc/acpi/button/lid/%s/state' % lid, 'rb') as file:
+ ret[lid] = 'open' in file.read().decode('utf-8', 'strict')
+ except:
+ pass
+ return ret