parsing tags

This commit is contained in:
Piotr Miller
2021-10-27 13:14:38 +02:00
parent 10a4d65d4d
commit ed0316afa6
3 changed files with 15 additions and 19 deletions

View File

@@ -19,7 +19,6 @@ dwl_data_file = None
dwl_instances = []
app_dirs = []
name2icon_dict = {}
dwl_data = {}
commands = {
"light": False,

View File

@@ -117,22 +117,10 @@ def check_tree():
def check_dwl_data(*args):
print("SIGUSR1")
"""global dwl_timestamp
timestamp = datetime.now()
diff = (timestamp - dwl_timestamp).total_seconds() * 1000
if diff > 50:
common.dwl_data = load_json(common.dwl_data_file)
if common.dwl_data:
print(diff)
for item in common.dwl_instances:
item.refresh(common.dwl_data)
dwl_timestamp = datetime.now()"""
common.dwl_data = load_json(common.dwl_data_file)
if common.dwl_data:
dwl_data = load_json(common.dwl_data_file)
if dwl_data:
for item in common.dwl_instances:
item.refresh(common.dwl_data)
item.refresh(dwl_data)
return True

View File

@@ -13,7 +13,11 @@ class DwlTags(Gtk.EventBox):
def __init__(self, output, dwl_data):
Gtk.EventBox.__init__(self)
self.output = output
# move to settings later
self.tags = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
self.title_limit = 55
self.box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
self.add(self.box)
self.label = Gtk.Label()
@@ -25,14 +29,19 @@ class DwlTags(Gtk.EventBox):
if dwl_data:
try:
data = dwl_data[self.output]
tags = data["tags"]
tags_string = data["tags"]
tags = tags_string.split()
non_empty_output_tags = int(tags[0])
active_output_tag = int(tags[1])
current_win_on_output_tags = int(tags[2])
print(tags)
layout = data["layout"]
title = data["title"]
if len(title) > self.title_limit:
title = title[:self.title_limit - 1]
# selmon = data["selmon"] == "1"
print("{} {} {}".format(tags, layout, title))
self.label.set_text("{} {} {}".format(tags, layout, title))
print("{} {} {}".format(tags_string, layout, title))
self.label.set_text("{} {} {}".format(tags_string, layout, title))
except KeyError:
print("No data found for output {}".format(self.output))