dotfiles
bugabingas dorkfiles
owned by bugabinga
Cache Ironbar workspace watcher state
5bb31c253741382dadc05a6110687549d7a8b5c3
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
Browse filesCompare with HEAD
Changed files (1)
ironbar/scripts/workspaces-watch.py
Modified+18 / −2 text lines
30 30 last_vars:
dict[
str,
str]
= {}
32 +color_vars:
dict[
str,
str]
= {}
33 36 def css_vars() ->
dict[
str,
str]:
37 + global color_mtime, color_vars
34 38 config_home
= Path(os.environ.get(
"XDG_CONFIG_HOME", Path.home()
/ ".config"))
39 + path
= config_home
/ "ironbar" / "nugu.css" 40 + mtime
= path.stat().st_mtime_ns
41 + if mtime
== color_mtime:
35 43 colors:
dict[
str,
str]
= {}
36 - for line
in (config_home
/ "ironbar" / "nugu.css").read_text().splitlines():
44 + for line
in path.read_text().splitlines():
37 45 if ":" not in line:
39 47 name, value
= line.strip().rstrip(
";").split(
":",
1)
41 49 value
= value.strip()
42 50 if name.startswith(
"--")
and value.startswith(
"#"):
43 51 colors[name[
2:]]
= value
47 57 def hypr_dir() ->
str:
58 + global hypr_socket_dir
60 + return hypr_socket_dir
48 61 sig
= os.environ.get(
"HYPRLAND_INSTANCE_SIGNATURE")
50 63 result
= subprocess.run((
"hyprctl",
"instances",
"-j"), text
=True, capture_output
=True, check
=False)
51 64 instances
= json.loads(result.stdout
or "[]")
52 65 sig
= instances[
0][
"instance"]
53 - return f"{os.environ[
'XDG_RUNTIME_DIR']}
/hypr/{sig}
" 66 + hypr_socket_dir
= f"{os.environ[
'XDG_RUNTIME_DIR']}
/hypr/{sig}
" 67 + return hypr_socket_dir
56 70 def hypr_cmd(command:
str) ->
str:
106 120 def watch() ->
None:
121 + global hypr_socket_dir
125 140 if line.startswith(EVENT_PREFIXES):
127 142 except Exception:
143 + hypr_socket_dir
= ""