;(include "./windows/netWindow.yuck") (defpoll ipaddress :initial "getting info..." :interval "30s" `./scripts/netinfo.sh 3`) (defpoll interface :initial "getting info..." :interval "30s" `./scripts/netinfo.sh 1`) (defpoll contype :initial "x" :interval "30s" `./scripts/netinfo.sh 1 | cut -c 1`) (defpoll nameserver :initial "getting info..." :interval "30s" `cat /etc/resolv.conf | grep "nameserver" | awk '{print $2}'`) (defpoll vpnstatus :initial "3" :interval "30s" `./scripts/vpninfo.sh`) (deflisten hostname :initial "getting info..." `cat /etc/hostname`) ; netWindow ; ---------------------------------- ; | content | ; | -------------------- | ; | | topContent | | ; | ||infobox hostname|| | ; | | | | ; | -------------------- | ; | | centerContent | | ; | | IF | IP | DNS | | ; | | | | ; | -------------------- | ; | | ; ---------------------------------- (defwidget header [] (box :orientation "h" :class "header" ;:halign "center" :valign "start" (button :class "infobutton" :valign "center" :halign "start" :onclick "pypr toggle networkinfo && hyprctl dispatch bringactivetotop" "") (box :valign "start":orientation "v" :halign "center" :class "namebox" (label :valign "start" :halign "end" :text "ネットワーク" :class "name") (label :valign "start" :halign "end" :text "[Network]" :class "translation")) (button :class "exitbutton" :valign "center" :halign "end" :onclick "eww close network" "") )) (defwidget topcontent [] (box :orientation "h" :class "topcontent" :valign "center" (box :orientation "v" (box :halign "start" :width 65 :class "neticon" {contype == "e" ? "󰈀" : contype == "w" ? "" : ""}) (box :halign "start" :class "device" :class "nettext" {contype == "e" ? "Wired" : contype == "w" ? "Wireless" : "Unknown connection type"}) );) (infobox :halign "start" :class "hostname" :name "Hostname:" :info hostname))) (defwidget content [] (box :orientation "v" :class "content" :halign "end" (header) (topcontent) (centercontent) (lowercontent) (bottomcontent))) (defwidget centercontent [] (box :orientation "h" :class "centercontent" :halign "end" :valign "center" (infobox :name "Interface:" :info interface) (infobox :name "IP Address:" :info ipaddress) (infobox :name "DNS Server:" :info nameserver) )) (defwidget lowercontent[] (box :orientation "h" :class "lowercontent" (vpncontent) (netcontent))) (defwidget netcontent[] (box :orientation "h" :class "netcontent" :halign "center" :valign "center" (netbox :type "Download":dev interface :speed {EWW_NET[interface].NET_DOWN}) (netbox :type "Upload":dev interface :speed {EWW_NET[interface].NET_UP}))) (defwidget vpncontent[] (box :orientation "v" :class "vpncontent" :halign "center" :valign "center" (label :text "VPN Status:") (box :width 65 :class "vpnicon" { vpnstatus == 1 ? "󱚨" : vpnstatus == 2 ? "󰣫" : "󰍀" }) (box :width 65 { vpnstatus == 1 ? "Connected" : vpnstatus == 2 ? "Tailscale" : "Disconnected" }))) (defwidget bottomcontent [] (box :orientation "h" :class "bottomcontent" :halign "end" :valign "end" (nmsettings))) (defwidget infobox [name info] (box :orientation "v" :class "infobox" ;:halign "center" ;:valign "center" (infolabel :text name) (infolabel :text info))) (defwidget nmsettings [] (box :orientation "horizontal" :class "buttons" :halign "end" :valign "end" (button :onclick "pypr toggle network && hyprctl dispatch bringactivetotop" "Open Connection Editor"))) ;; Labels: (defwidget infolabel [text] (label :text text :class "infolabel" ;:halign "center" ;:valign "center" )) ;;* ;(defwidget headlabel [text] ; (label :text text :class "headlabel" ; :halign "center" ; :valign "center")) ;(defwidget sublabel [text] ;(label :text text :class "sublabel" ; :halign "center" ; :valign "center")) ;*/ (defwidget netbox [type dev speed] (box :orientation "v" :class "netbox" :halign "center" :valign "center" (infolabel :text type) (netGraph :speed speed) (box :width 65 {speed / 1000000 > 0.5 ? "${round(speed / 1000000, 0)} Mbit/s" : speed / 1000 > 0.5 ? "${round(speed / 1000, 0)} Kbit/s" : "${round(speed, 0)} bit/s"}))) (defwidget netGraph [speed] (graph :class "netgraph" :value speed :time-range "30s")) (defwindow network :class network_window :monitor 1 :geometry (geometry :x "20px" :y "0px" :width "560px" :height "80%" :anchor "right center") :stacking "fg" ;:reserve (struts :distance "10px" :side "top") ;;only for x11 ;:windowtype "dock" ;;only for x11 ;:wm-ignore false ;;only for x11 ;(header) (content))