Compare commits

..

3 commits

2 changed files with 49 additions and 12 deletions

View file

@ -19,10 +19,15 @@
)
(deflisten network
:initial '{"state":"disconnected","infos":{}}'
:initial '{"state":"disconnect"}'
"listen/network"
)
(deflisten notifications
:initial '{}'
"swaync-client --subscribe"
)
(defvar battery-icon '{
"unknown": "",
"critical": "",
@ -43,13 +48,19 @@
"tethering": "󰕓"
}')
(defvar notifications-icon '{
"nothing": "󰂚",
"new": "󱅫",
"dnd": "󰂛"
}')
(defwidget workspaces []
(eventbox :onscroll "action/hyprland/nearby-workspace {}"
(eventbox :onscroll 'action/hyprland/nearby-workspace "{}"'
(box :class "workspaces"
(for workspace in {workspaces.used}
(eventbox
:class "workspace-button ${workspace == workspaces.current ? "workspace-current" : ""}"
:onclick "hyprctl dispatch workspace ${workspace}"
:onclick 'hyprctl dispatch workspace "${workspace}"'
(box :width 25 "${workspace}")
)
)
@ -75,9 +86,37 @@
"${formattime(EWW_TIME, "%Y-%m-%d")} ${formattime(EWW_TIME, "%H:%M:%S")}"
)
(defwidget notifications []
(box (eventbox
:class "module"
:onclick 'swaync-client --toggle-panel'
:onrightclick 'swaync-client --toggle-dnd'
"${
notifications.dnd == true
? notifications-icon["dnd"]
: notifications.count > 0
? notifications-icon["new"]
: notifications-icon["nothing"]
} ${notifications.count}"
))
)
; (defwidget sound [] "")
(defwidget network []
"${network.state == "wireless" ? "${network-icon["wifi-${network.infos.signal}"]} ${network.infos.ssid}" : "${network-icon[network.state]}"}"
"${
network.state == "wireless"
? network-icon["wifi-${network.wifi.signal}"]
: network-icon[network.state]
} ${
network.state == "disconnected"
? "no network" :
network.state == "ethernet"
? "wired" :
network.state == "wireless"
? network.wifi.ssid : ''
}"
)
(defwidget battery []
@ -107,7 +146,9 @@
:space-evenly false
:class "middle"
(tray) (time)
(tray)
(time)
(notifications)
)
(box
:halign "end"

View file

@ -26,31 +26,27 @@ wifi_strength() {
}
print_infos() {
printf \{
if [ -n "$1" ]; then
route_line=$(ip route show dev "$1" | awk '($1 == "default") { print }')
printf '"ip":"%s","gateway":"%s"' \
printf ',"ip":{"local":"%s","gateway":"%s"}' \
"$(echo "$route_line" | awk '{ print $7 }')" \
"$(echo "$route_line" | awk '{ print $3 }')"
if [ "$state" = wireless ]; then
signal=$(iw dev "$1" link | awk '($1 == "signal:") { print $2}')
printf ',"signal":"%s","ssid":"%s"' \
printf ',"wifi":{"signal":"%s","ssid":"%s"}' \
"$(wifi_strength "$signal")" \
"$(iw dev wlan0 info | grep '^\s*ssid ' | xargs | cut -d \ -f 2-)"
fi
fi
printf '}\n'
}
print_network_status() {
device=$(ip route | awk '($1 == "default") { print $5 }')
state=$(print_state "$device")
printf '{"state":"%s","infos":%s}\n' \
printf '{"state":"%s"%s}\n' \
"$state" \
"$(print_infos "$device")"
}