48 lines
1.0 KiB
Python
Executable File
48 lines
1.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import json
|
|
import subprocess
|
|
|
|
icons = {
|
|
"firefox": "",
|
|
"kitty": "",
|
|
"code": "",
|
|
"nemo": "",
|
|
"discord": "",
|
|
"spotify": "",
|
|
}
|
|
|
|
def get_windows():
|
|
result = subprocess.run(["hyprctl", "clients", "-j"], stdout=subprocess.PIPE)
|
|
return json.loads(result.stdout)
|
|
|
|
def get_workspaces():
|
|
result = subprocess.run(["hyprctl", "workspaces", "-j"], stdout=subprocess.PIPE)
|
|
return json.loads(result.stdout)
|
|
|
|
def main():
|
|
windows = get_windows()
|
|
workspaces = get_workspaces()
|
|
|
|
ws_icons = {}
|
|
|
|
for ws in workspaces:
|
|
ws_id = ws["id"]
|
|
ws_icons[ws_id] = []
|
|
|
|
for win in windows:
|
|
app = win["class"].lower()
|
|
ws_id = win["workspace"]["id"]
|
|
icon = icons.get(app, "?")
|
|
if icon not in ws_icons[ws_id]:
|
|
ws_icons[ws_id].append(icon)
|
|
|
|
output = " ".join(
|
|
f"{ws}:{''.join(ws_icons[ws])}" for ws in sorted(ws_icons.keys())
|
|
)
|
|
|
|
print(output)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|