[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,104 +94,108 @@ 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:
spacing: 0 conditions:
items: ~sway_running: {empty: {}}
- map: default:
default: {string: {text: "{ws0}", <<: *ws_default}} list:
conditions: spacing: 0
ws0_state == unused: {empty: {}} items:
ws0_state == focused: {string: {text: "{ws0}", <<: *ws_focused}} - map:
ws0_state == visible: {string: {text: "{ws0}", <<: *ws_visible}} default: {string: {text: "{ws0}", <<: *ws_default}}
- map: {default: {empty: {}}, conditions: {ws1_new_monitor: *monitor_sep}} conditions:
- map: ws0_state == unused: {empty: {}}
default: {string: {text: "{ws1}", <<: *ws_default}} ws0_state == focused: {string: {text: "{ws0}", <<: *ws_focused}}
conditions: ws0_state == visible: {string: {text: "{ws0}", <<: *ws_visible}}
ws1_state == unused: {empty: {}} - map: {default: {empty: {}}, conditions: {ws1_new_monitor: *monitor_sep}}
ws1_state == focused: {string: {text: "{ws1}", <<: *ws_focused}} - map:
ws1_state == visible: {string: {text: "{ws1}", <<: *ws_visible}} default: {string: {text: "{ws1}", <<: *ws_default}}
- map: {default: {empty: {}}, conditions: {ws2_new_monitor: *monitor_sep}} conditions:
- map: ws1_state == unused: {empty: {}}
default: {string: {text: "{ws2}", <<: *ws_default}} ws1_state == focused: {string: {text: "{ws1}", <<: *ws_focused}}
conditions: ws1_state == visible: {string: {text: "{ws1}", <<: *ws_visible}}
ws2_state == unused: {empty: {}} - map: {default: {empty: {}}, conditions: {ws2_new_monitor: *monitor_sep}}
ws2_state == focused: {string: {text: "{ws2}", <<: *ws_focused}} - map:
ws2_state == visible: {string: {text: "{ws2}", <<: *ws_visible}} default: {string: {text: "{ws2}", <<: *ws_default}}
- map: {default: {empty: {}}, conditions: {ws3_new_monitor: *monitor_sep}} conditions:
- map: ws2_state == unused: {empty: {}}
default: {string: {text: "{ws3}", <<: *ws_default}} ws2_state == focused: {string: {text: "{ws2}", <<: *ws_focused}}
conditions: ws2_state == visible: {string: {text: "{ws2}", <<: *ws_visible}}
ws3_state == unused: {empty: {}} - map: {default: {empty: {}}, conditions: {ws3_new_monitor: *monitor_sep}}
ws3_state == focused: {string: {text: "{ws3}", <<: *ws_focused}} - map:
ws3_state == visible: {string: {text: "{ws3}", <<: *ws_visible}} default: {string: {text: "{ws3}", <<: *ws_default}}
- map: {default: {empty: {}}, conditions: {ws4_new_monitor: *monitor_sep}} conditions:
- map: ws3_state == unused: {empty: {}}
default: {string: {text: "{ws4}", <<: *ws_default}} ws3_state == focused: {string: {text: "{ws3}", <<: *ws_focused}}
conditions: ws3_state == visible: {string: {text: "{ws3}", <<: *ws_visible}}
ws4_state == unused: {empty: {}} - map: {default: {empty: {}}, conditions: {ws4_new_monitor: *monitor_sep}}
ws4_state == focused: {string: {text: "{ws4}", <<: *ws_focused}} - map:
ws4_state == visible: {string: {text: "{ws4}", <<: *ws_visible}} default: {string: {text: "{ws4}", <<: *ws_default}}
- map: {default: {empty: {}}, conditions: {ws5_new_monitor: *monitor_sep}} conditions:
- map: ws4_state == unused: {empty: {}}
default: {string: {text: "{ws5}", <<: *ws_default}} ws4_state == focused: {string: {text: "{ws4}", <<: *ws_focused}}
conditions: ws4_state == visible: {string: {text: "{ws4}", <<: *ws_visible}}
ws5_state == unused: {empty: {}} - map: {default: {empty: {}}, conditions: {ws5_new_monitor: *monitor_sep}}
ws5_state == focused: {string: {text: "{ws5}", <<: *ws_focused}} - map:
ws5_state == visible: {string: {text: "{ws5}", <<: *ws_visible}} default: {string: {text: "{ws5}", <<: *ws_default}}
- map: {default: {empty: {}}, conditions: {ws6_new_monitor: *monitor_sep}} conditions:
- map: ws5_state == unused: {empty: {}}
default: {string: {text: "{ws6}", <<: *ws_default}} ws5_state == focused: {string: {text: "{ws5}", <<: *ws_focused}}
conditions: ws5_state == visible: {string: {text: "{ws5}", <<: *ws_visible}}
ws6_state == unused: {empty: {}} - map: {default: {empty: {}}, conditions: {ws6_new_monitor: *monitor_sep}}
ws6_state == focused: {string: {text: "{ws6}", <<: *ws_focused}} - map:
ws6_state == visible: {string: {text: "{ws6}", <<: *ws_visible}} default: {string: {text: "{ws6}", <<: *ws_default}}
- map: {default: {empty: {}}, conditions: {ws7_new_monitor: *monitor_sep}} conditions:
- map: ws6_state == unused: {empty: {}}
default: {string: {text: "{ws7}", <<: *ws_default}} ws6_state == focused: {string: {text: "{ws6}", <<: *ws_focused}}
conditions: ws6_state == visible: {string: {text: "{ws6}", <<: *ws_visible}}
ws7_state == unused: {empty: {}} - map: {default: {empty: {}}, conditions: {ws7_new_monitor: *monitor_sep}}
ws7_state == focused: {string: {text: "{ws7}", <<: *ws_focused}} - map:
ws7_state == visible: {string: {text: "{ws7}", <<: *ws_visible}} default: {string: {text: "{ws7}", <<: *ws_default}}
- map: {default: {empty: {}}, conditions: {ws8_new_monitor: *monitor_sep}} conditions:
- map: ws7_state == unused: {empty: {}}
default: {string: {text: "{ws8}", <<: *ws_default}} ws7_state == focused: {string: {text: "{ws7}", <<: *ws_focused}}
conditions: ws7_state == visible: {string: {text: "{ws7}", <<: *ws_visible}}
ws8_state == unused: {empty: {}} - map: {default: {empty: {}}, conditions: {ws8_new_monitor: *monitor_sep}}
ws8_state == focused: {string: {text: "{ws8}", <<: *ws_focused}} - map:
ws8_state == visible: {string: {text: "{ws8}", <<: *ws_visible}} default: {string: {text: "{ws8}", <<: *ws_default}}
- map: {default: {empty: {}}, conditions: {ws9_new_monitor: *monitor_sep}} conditions:
- map: ws8_state == unused: {empty: {}}
default: {string: {text: "{ws9}", <<: *ws_default}} ws8_state == focused: {string: {text: "{ws8}", <<: *ws_focused}}
conditions: ws8_state == visible: {string: {text: "{ws8}", <<: *ws_visible}}
ws9_state == unused: {empty: {}} - map: {default: {empty: {}}, conditions: {ws9_new_monitor: *monitor_sep}}
ws9_state == focused: {string: {text: "{ws9}", <<: *ws_focused}} - map:
ws9_state == visible: {string: {text: "{ws9}", <<: *ws_visible}} default: {string: {text: "{ws9}", <<: *ws_default}}
- map: {default: {empty: {}}, conditions: {ws10_new_monitor: *monitor_sep}} conditions:
- map: ws9_state == unused: {empty: {}}
default: {string: {text: "{ws10}", <<: *ws_default}} ws9_state == focused: {string: {text: "{ws9}", <<: *ws_focused}}
conditions: ws9_state == visible: {string: {text: "{ws9}", <<: *ws_visible}}
ws10_state == unused: {empty: {}} - map: {default: {empty: {}}, conditions: {ws10_new_monitor: *monitor_sep}}
ws10_state == focused: {string: {text: "{ws10}", <<: *ws_focused}} - map:
ws10_state == visible: {string: {text: "{ws10}", <<: *ws_visible}} default: {string: {text: "{ws10}", <<: *ws_default}}
- map: {default: {empty: {}}, conditions: {ws11_new_monitor: *monitor_sep}} conditions:
- map: ws10_state == unused: {empty: {}}
default: {string: {text: "{ws11}", <<: *ws_default}} ws10_state == focused: {string: {text: "{ws10}", <<: *ws_focused}}
conditions: ws10_state == visible: {string: {text: "{ws10}", <<: *ws_visible}}
ws11_state == unused: {empty: {}} - map: {default: {empty: {}}, conditions: {ws11_new_monitor: *monitor_sep}}
ws11_state == focused: {string: {text: "{ws11}", <<: *ws_focused}} - map:
ws11_state == visible: {string: {text: "{ws11}", <<: *ws_visible}} default: {string: {text: "{ws11}", <<: *ws_default}}
- map: conditions:
default: ws11_state == unused: {empty: {}}
- {empty: {left-margin: 5}} ws11_state == focused: {string: {text: "{ws11}", <<: *ws_focused}}
- string: ws11_state == visible: {string: {text: "{ws11}", <<: *ws_visible}}
text: "{mode}" - map:
left-margin: 5 default:
right-margin: 5 - {empty: {left-margin: 5}}
deco: - string:
background: text: "{mode}"
color: 9c5842d8 left-margin: 5
conditions: right-margin: 5
mode == default: {empty: {}} deco:
background:
color: 9c5842d8
conditions:
mode == default: {empty: {}}
- mem: - mem:
poll-interval: 1500 poll-interval: 1500

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()