Re-added battlestation to roci config

This commit is contained in:
Ezri 2025-03-13 17:25:16 -06:00
parent 47d093f95f
commit 4ac47e3300
Signed by: ezri
GPG Key ID: 058A78E5680C6F24
5 changed files with 157 additions and 45 deletions

View File

@ -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]

View File

@ -48,27 +48,12 @@
:halign "start"
:space-evenly false
:spacing 0
(label :class "offline"
:visible {network--data
["network"]
[device]
["offline"]
}
(label :class "highlight"
:visible {!device.online}
: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 "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"

View File

@ -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()),
}
),

View File

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

View File

@ -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": [