From 4ac47e3300a279582a8668f2a538c4706e7ecf1a Mon Sep 17 00:00:00 2001 From: Ezri Date: Thu, 13 Mar 2025 17:25:16 -0600 Subject: [PATCH] Re-added battlestation to roci config --- .config/eww/eww.yuck | 4 +- .config/eww/modules/network.yuck | 67 ++++++++++------ .config/eww/scripts/network.py | 36 +++++---- .config/eww/windows.yuck | 18 ++++- .../sway/workspaces.json##hostname.rocinante | 77 ++++++++++++++++++- 5 files changed, 157 insertions(+), 45 deletions(-) diff --git a/.config/eww/eww.yuck b/.config/eww/eww.yuck index 0d17c2e..2e5db15 100644 --- a/.config/eww/eww.yuck +++ b/.config/eww/eww.yuck @@ -70,8 +70,8 @@ :stacking "fg" (centerbox :orientation "h" :class "bar root" - (hostname-leftalign) - (sway-workspace :group {group}) + (hostname-and-workspace-leftalign :workspace-group {group}) + "" (laptop-details-rightalign :battery {battery} ))) (defwindow laptopsidebar [group battery side] diff --git a/.config/eww/modules/network.yuck b/.config/eww/modules/network.yuck index a92f2cd..d9bc668 100644 --- a/.config/eww/modules/network.yuck +++ b/.config/eww/modules/network.yuck @@ -48,27 +48,12 @@ :halign "start" :space-evenly false :spacing 0 - (label :class "offline" - :visible {network--data - ["network"] - [device] - ["offline"] - } - :text "offline") - (label :visible {network--data - ["network"] - [device] - ["connecting"] - } - :class "highlight" - :text "connecting...") - (label :visible {network--data - ["network"] - [device] - ["online"] - } - :class "special" - :text "${network--data['wifi']['ssid']}"))) + (label :class "highlight" + :visible {!device.online} + :text "offline") + (label :class "special" + :visible {device.online} + :text {network--data.wifi.ssid}))) (defwidget network--lan [device] @@ -76,7 +61,7 @@ :halign "start" :space-evenly false :spacing 0 - (label :class "offline" + (label :class "highlight" :visible {!device.online} :text "offline") (label :visible {device.online} @@ -127,9 +112,29 @@ :halign "center" :space-evenly false :spacing 10 - (network--lan :device {network--data.default_interface})) + (network--lan :device {network--data.default_interface} + :visible {!network--data.wifi.default})) "communications"))) +(defwidget wifi [] + (box :orientation "v" + :halign "start" + :space-evenly false + :spacing 0 + :visible {network--data != ''} + (box :orientation "h" + :halign "center" + :space-evenly false + :spacing 10 + (label :class "offline" + :text "offline" + :visible {!network--data.wifi.connected}) + (label :class "special" + :text {network--data.wifi.ssid} + :visible {network--data.wifi.connected})) + "network")) + + (defwidget network--public-ip [] (centerbox :orientation "h" @@ -325,6 +330,22 @@ (label :text {network--data.gateway} :class "special" :visible {network--data.have_gateway}))) + (centerbox :orientation "h" + :halign "start" + :spacing 10 + :width 200 + :space-evenly false + (box :halign "start" + :class "nebula" + "Wireless:") + "" + (box :halign "end" + (label :text "Offline" + :class "offline nebula" + :visible {!network--data.wifi.connected}) + (label :text {network--data.wifi.ssid} + :class "special" + :visible {network--data.wifi.connected}))) (centerbox :orientation "h" :halign "start" :class "nebula" diff --git a/.config/eww/scripts/network.py b/.config/eww/scripts/network.py index 3ed863f..9ea0ef4 100755 --- a/.config/eww/scripts/network.py +++ b/.config/eww/scripts/network.py @@ -120,6 +120,15 @@ def get_gateways(): return result +def get_ssid(): + + cmd = ['iwgetid', '-r'] + result = run(cmd, stdout=PIPE, stderr=PIPE) + if result.returncode == 0: + return result.stdout.decode('utf-8').strip() + else: + return None + def interface_status(interface: str, gw): """Get the status of an interface.""" @@ -196,22 +205,6 @@ def format_time(time: datetime) -> dict[str, str | int]: "unix": int(time.timestamp()), } - -# system_bus = dbus.SystemBus() -# networkd = system_bus.get_object( -# "org.freedesktop.network1", "/org/freedesktop/network1" -# ) -# manager = dbus.Interface(networkd, "org.freedesktop.network1.Manager") - - -# def get_dbus_interfaces(): -# for iface in INTERFACES_TO_WATCH: -# dbus_object = system_bus.get_object( -# "org.freedesktop.network1", manager.GetLinkByName(iface) -# ) -# dbus_interface = dbus.Interface(dbus_object, "org.freedesktop.network1.Link") -# yield dbus_interface - runtime_dir = os.environ.get("XDG_RUNTIME_DIR", "/tmp") @@ -284,6 +277,12 @@ while True: default_route_iface_data = interface_status(default_route, gw) + ssid = get_ssid() + if ssid is None: + wifi_connected = False + else: + wifi_connected = True + print( json.dumps( { @@ -297,6 +296,11 @@ while True: "have_default_route": default_route is not None, "gateway": str(hop), "have_gateway": hop is not None, + "wifi": { + "ssid": ssid, + "connected": wifi_connected, + "default": default_route == "wlan0" + }, "last_update": format_time(datetime.now()), } ), diff --git a/.config/eww/windows.yuck b/.config/eww/windows.yuck index 13a27bc..6dade84 100644 --- a/.config/eww/windows.yuck +++ b/.config/eww/windows.yuck @@ -59,9 +59,10 @@ :space-evenly false :spacing 20 :class "rightbox" - (vpn-network) (mpris2) + (vpn-network) (network) + (wifi) (system-memory) (system-cpu-avg) (clock))) @@ -90,16 +91,27 @@ :class "rightbox" (system-name))) +(defwidget hostname-and-workspace-leftalign [workspace-group] + (box :orientation "h" + :halign "start" + :valign "center" + :space-evenly false + :spacing 20 + :class "leftbox" + (transform :translate-y "-2px" + (system-name)) + (sway-workspace :group {workspace-group}))) + (defwidget laptop-details-rightalign [?battery] (box :orientation "h" :halign "end" :space-evenly false :spacing 20 :class "rightbox" + (mpris2) (vpn-network) (network) - (system-battery :battery {battery ?: "BAT1"}) - (audio) + (wifi) (clock))) diff --git a/.config/sway/workspaces.json##hostname.rocinante b/.config/sway/workspaces.json##hostname.rocinante index 6dde097..5b42a67 100644 --- a/.config/sway/workspaces.json##hostname.rocinante +++ b/.config/sway/workspaces.json##hostname.rocinante @@ -32,7 +32,7 @@ { "index": 5, "name": "discord", - "exec": "discord", + "exec": "vesktop", "program_name": "discord" }, { @@ -253,6 +253,81 @@ } } }, + "battlestation": { + "primary": "center", + "outputs": [ + { + "names": ["eDP-1"], + "group": "builtin", + "position": [0, 600], + "eww_windows": { + "laptopbar": { + "battery": "BAT1" + }, + "laptopsidebar": { + "battery": "BAT1", + "side": "left" + } + }, + "mode": "2256x1504 scale 1.5" + }, + { + "make": "ASUSTek COMPUTER INC", + "model": "VG245", + "serial": "L7LMQS132447", + "group": "left", + "position": [1504, 200], + "mode": "1920x1080@75Hz", + "eww_windows": { + "desktop-leftbar": {}, + "sidebar": { + "side": "left" + } + } + }, + { + "make": "ASUSTek COMPUTER INC", + "model": "VG32AQA1A", + "serial": "S5LMQS033656", + "group": "center", + "position": [3424, 0], + "mode": "2560x1440@165Hz", + "eww_windows": ["desktop-mainbar"] + }, + { + "make": "ASUSTek COMPUTER INC", + "model": "VG245", + "serial": "L6LMQS065439", + "group": "right", + "position": [5984, 200], + "mode": "1920x1080@75Hz", + "eww_windows": { + "desktop-rightbar": {}, + "sidebar": { + "side": "right" + } + } + } + ], + "groups": { + "builtin": { + "workspaces": [21, 22], + "reverse": false + }, + "left": { + "workspaces": [6, 2, 3, 4, 5], + "reverse": true + }, + "center": { + "workspaces": [1, 7, 8, 9, 10, 11, 12, 13, 14, 15], + "reverse": false + }, + "right": { + "workspaces": [16, 17, 19, 18, 20, 13], + "reverse": false + } + } + }, "portable": { "primary": "builtin", "outputs": [