[yambar.sway] Don't spam placeholders when sway isn't running

This commit is contained in:
Midgard 2024-05-25 19:35:25 +02:00
parent 90a5adf6d4
commit 65d4f50269
Signed by untrusted user who does not match committer: midgard
GPG key ID: 511C112F1331BBB4
2 changed files with 112 additions and 99 deletions

View file

@ -94,7 +94,11 @@ bar:
ws_focused: &ws_focused {foreground: *col_fg, <<: *ws_common} ws_focused: &ws_focused {foreground: *col_fg, <<: *ws_common}
ws_visible: &ws_visible {foreground: *col_visible_ws, <<: *ws_common} ws_visible: &ws_visible {foreground: *col_visible_ws, <<: *ws_common}
content: content:
- list: - map:
conditions:
~sway_running: {empty: {}}
default:
list:
spacing: 0 spacing: 0
items: items:
- map: - map:

View file

@ -6,6 +6,7 @@ import socket
import struct import struct
import json import json
import traceback import traceback
import time
from typing import List from typing import List
@ -19,7 +20,14 @@ magic = b"i3-ipc"
msg_header = struct.Struct("II") msg_header = struct.Struct("II")
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
s.connect(os.getenvb(b"SWAYSOCK")) SWAYSOCK = os.getenvb(b"SWAYSOCK")
if not SWAYSOCK:
while True:
# print("\n".join(result), flush=True)
print("sway_running|bool|false\n", flush=True)
time.sleep(60 * 60 * 60)
s.connect(SWAYSOCK)
def recv(): def recv():
reply_magic = s.recv(6) reply_magic = s.recv(6)
@ -90,6 +98,7 @@ def print_state():
global state_mode global state_mode
print(f"""{format_workspaces(state_workspaces)} print(f"""{format_workspaces(state_workspaces)}
mode|string|{state_mode} mode|string|{state_mode}
sway_running|bool|true
""", flush=True) """, flush=True)
print_state() print_state()