nixos-config/common/eww/eww.yuck

199 lines
3.5 KiB
Text

(deflisten workspaces-status
:initial "[]"
"./listen/niri/workspaces"
)
(deflisten window-title "./listen/niri/window-title")
(deflisten notifications-status
:initial '{"dnd": false, "count": 0}'
"swaync-client --subscribe"
)
(deflisten audio-status
"./listen/audio"
)
(defvar workspaces-icon '{
"admin": "",
"everything": "",
"apps": ""
}')
(defvar notifications-icon '{
"nothing": "",
"new": "",
"dnd": ""
}')
(defvar battery-icon '[
{ "Discharging": "󰂎", "Charging": "󰢟" },
{ "Discharging": "󰁺", "Charging": "󰢜" },
{ "Discharging": "󰁻", "Charging": "󰂆" },
{ "Discharging": "󰁼", "Charging": "󰂇" },
{ "Discharging": "󰁽", "Charging": "󰂈" },
{ "Discharging": "󰁾", "Charging": "󰢝" },
{ "Discharging": "󰁿", "Charging": "󰂉" },
{ "Discharging": "󰂀", "Charging": "󰢞" },
{ "Discharging": "󰂁", "Charging": "󰂊" },
{ "Discharging": "󰂂", "Charging": "󰂋" },
{ "Discharging": "󰁹", "Charging": "󰂅", "Full": "󱟢" }
]')
(defvar audio-icon '[
{ "muted": "a", "unmuted": "b" },
{ "muted": "c", "unmuted": "d" }
]')
(defwidget workspaces []
(box
:class "workspaces"
(for workspace in {workspaces-status}
(eventbox
:onclick "niri msg action focus-workspace ${workspace.idx}"
:width 25
:class "${workspace.is_active ? " workspace-active" : ""}"
"${"${workspaces-icon?.[workspace.name]}" ?: ""} "
)
)
)
)
(defwidget window-title []
(box (label
:limit-width 80
:text "${window-title ?: ""}"
))
)
(defwidget notifications []
(box (eventbox
:onclick "swaync-client --toggle-panel"
:onmiddleclick "swaync-client --close-all"
:onrightclick "swaync-client --toggle-dnd"
:width 25
(label
:class "icons"
:text "${notifications-status.dnd
? "${notifications-icon.dnd}"
: notifications-status.count > 0
? "${notifications-icon.new}"
: "${notifications-icon.nothing}"} ${notifications-status.count}"
)
))
)
(defwidget time []
"${formattime(EWW_TIME, "%Y-%m-%d")} ${formattime(EWW_TIME, "%H:%M:%S")}"
)
(defwidget tray []
(box (systray
:icon-size 15
:spacing 10
))
)
(defwidget audio []
(label
:text ""
)
)
(defwidget battery []
(label
:text "${battery-icon[round((EWW_BATTERY.BAT0.capacity - 5) / 10, 0) - 1][EWW_BATTERY.BAT0.status]} ${EWW_BATTERY.BAT0.capacity}"
)
)
(defwindow dock_ahrc-laptop
:monitor 0
:geometry (geometry
:x "0"
:y "0"
:width "100%"
:height "30px"
:anchor "bottom center"
)
:stacking "fg"
:exclusive true
(centerbox
:class "main"
(box
:class "left"
:halign "start"
:space-evenly false
(workspaces)
(window-title)
)
(box
:class "middle"
:space-evenly false
(tray)
(time)
(notifications)
)
(box
:class "right"
:halign "end"
:space-evenly false
(audio)
(battery)
)
)
)
(defwindow dock_ahrc-pc
:monitor 0
:geometry (geometry
:x "0"
:y "0"
:width "100%"
:height "30px"
:anchor "bottom center"
)
:stacking "fg"
:exclusive true
(centerbox
:class "main"
(box
:class "left"
:halign "start"
:space-evenly false
(workspaces)
(window-title)
)
(box
:class "middle"
:space-evenly false
(tray)
(time)
(notifications)
)
(box
:class "right"
:halign "end"
:space-evenly false
""
)
)
)