nixpkgs/pkgs/applications/window-managers/way-cooler/bar.diff

38 lines
1.2 KiB
Diff
Raw Normal View History

--- bar.py.txt.orig 2017-12-05 18:10:20.108569182 +0300
+++ ./bar.py.txt 2017-12-10 21:42:10.622781945 +0300
@@ -5,6 +5,7 @@ import datetime
import json
from time import sleep
from pydbus import SessionBus
+from glob import glob
BUS = SessionBus()
LAYOUT = BUS.get(bus_name='org.way-cooler', object_path='/org/way_cooler/Layout')
@@ -32,7 +33,7 @@ def main():
output += func()
print(output)
sys.stdout.flush()
- sleep(.1)
+ sleep(1)
def get_workspaces(layout_json):
"""Gets the workspace names from the layout json"""
@@ -49,9 +50,14 @@ def get_time():
return datetime.datetime.now().strftime(' %a %b %d %H:%M ')
def get_battery():
- with open("/sys/class/power_supply/BAT0/capacity", "r") as f:
- bat = f.readlines()
- return bat[0].strip() + "% Battery"
+ try:
+ [path] = glob("/sys/class/power_supply/BAT?/capacity")
+ with open(path, "r") as f:
+ bat = f.readlines()
+ result = bat[0].strip() + "% Battery"
+ except Exception:
+ result = ""
+ return result
def format_workspaces(layout, workspaces, active_workspace):
workspaces = " " + workspaces.replace(" ", " ") + " "