don't count lines
This commit is contained in:
@@ -96,7 +96,7 @@ def main():
|
||||
os.remove(output_file)
|
||||
|
||||
# read stdin, parse data, save in json format
|
||||
change = False
|
||||
"""change = False
|
||||
for line in fileinput.input():
|
||||
parts = line.split()
|
||||
|
||||
@@ -134,7 +134,50 @@ def main():
|
||||
if change:
|
||||
with open(output_file, 'w') as fp:
|
||||
json.dump(data, fp, indent=4)
|
||||
subprocess.Popen("pkill -f -usr1 nwg-panel", shell=True)"""
|
||||
|
||||
# read stdin, parse data, save in json format
|
||||
cnt = 0
|
||||
for line in fileinput.input():
|
||||
parts = line.split()
|
||||
|
||||
output = parts[0]
|
||||
if output not in data:
|
||||
data[output] = {}
|
||||
|
||||
if parts[1] == "title":
|
||||
if len(parts) >= 3:
|
||||
title = ' '.join(parts[2:])
|
||||
if "title" not in data[output] or data[output]["title"] != title:
|
||||
data[output]["title"] = title
|
||||
cnt += 1
|
||||
else:
|
||||
if "title" not in data[output] or data[output]["title"] != "":
|
||||
data[output]["title"] = ""
|
||||
cnt += 1
|
||||
|
||||
elif parts[1] == "selmon":
|
||||
if "selmon" not in data[output] or data[output]["selmon"] != parts[2]:
|
||||
data[output]["selmon"] = parts[2]
|
||||
cnt += 1
|
||||
|
||||
elif parts[1] == "tags":
|
||||
tags = line.split("{} tags".format(output))[1].strip()
|
||||
if "tags" not in data[output] or data[output]["tags"] != tags:
|
||||
data[output]["tags"] = tags
|
||||
cnt += 1
|
||||
|
||||
elif parts[1] == "layout":
|
||||
if "layout" not in data[output] or data[output]["layout"] != parts[2]:
|
||||
data[output]["layout"] = parts[2]
|
||||
cnt += 1
|
||||
|
||||
if cnt == num_lines:
|
||||
with open(output_file, 'w') as fp:
|
||||
json.dump(data, fp, indent=4)
|
||||
|
||||
subprocess.Popen("pkill -f -usr1 nwg-panel", shell=True)
|
||||
cnt = 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@@ -118,7 +118,7 @@ def check_tree():
|
||||
|
||||
def check_dwl_data(*args):
|
||||
print("SIGUSR1")
|
||||
global dwl_timestamp
|
||||
"""global dwl_timestamp
|
||||
timestamp = datetime.now()
|
||||
diff = (timestamp - dwl_timestamp).total_seconds() * 1000
|
||||
if diff > 50:
|
||||
@@ -127,7 +127,12 @@ def check_dwl_data(*args):
|
||||
print(diff)
|
||||
for item in common.dwl_instances:
|
||||
item.refresh(common.dwl_data)
|
||||
dwl_timestamp = datetime.now()
|
||||
dwl_timestamp = datetime.now()"""
|
||||
|
||||
common.dwl_data = load_json(common.dwl_data_file)
|
||||
if common.dwl_data:
|
||||
for item in common.dwl_instances:
|
||||
item.refresh(common.dwl_data)
|
||||
|
||||
return True
|
||||
|
||||
|
Reference in New Issue
Block a user