Compare commits

...

3 commits

2 changed files with 49 additions and 12 deletions

View file

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

View file

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