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

View file

@ -6,6 +6,7 @@ import socket
import struct
import json
import traceback
import time
from typing import List
@ -19,7 +20,14 @@ magic = b"i3-ipc"
msg_header = struct.Struct("II")
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():
reply_magic = s.recv(6)
@ -90,6 +98,7 @@ def print_state():
global state_mode
print(f"""{format_workspaces(state_workspaces)}
mode|string|{state_mode}
sway_running|bool|true
""", flush=True)
print_state()