nixpkgs/pkgs/applications/window-managers/way-cooler/bar.diff
gnidorah b9851a975e Make less known wayland compositors usable (#32285)
* bemenu: init at 2017-02-14

* velox: 2015-11-03 -> 2017-07-04

* orbment, velox: don't expose subprojects

the development of orbment and velox got stuck
their subprojects (bemenu, dmenu-wayland, st-wayland) don't work correctly outside of parent projects
so hide them to not confuse people
swc and wld libraries are unpopular and unlike wlc are not used by anything except velox

* pythonPackages.pydbus: init at 0.6.0

* way-cooler: 0.5.2 -> 0.6.2

* nixos/way-cooler: add module

* dconf module: use for wayland

non-invasive approach for #31293
see discussion at #32210

* sway: embed LD_LIBRARY_PATH for #32755

* way-cooler: switch from buildRustPackage to buildRustCrate #31150
2017-12-21 16:16:19 +00:00

38 lines
1.2 KiB
Diff

--- 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(" ", " ") + " "