2023-07-04 20:24:29 +02:00
|
|
|
;; Variables
|
|
|
|
(defvar power false)
|
|
|
|
(defvar show-date false)
|
|
|
|
(defvar show-volume false)
|
|
|
|
(defvar volume-muted false)
|
|
|
|
|
2023-07-10 13:42:25 +02:00
|
|
|
(defvar ha-now-playing "ha-now-playing --host home.datarift.nl --token-file /run/secrets/ha_now_playing_token --entity media_player.sonos_woonkamer")
|
2023-07-04 20:24:29 +02:00
|
|
|
;; Polls
|
|
|
|
(defpoll volume-current
|
|
|
|
:initial 0
|
|
|
|
:interval "1s"
|
|
|
|
`pamedia get -b`)
|
|
|
|
|
|
|
|
;; Listen
|
|
|
|
(deflisten sonos-now-playing
|
|
|
|
:initial "{\"muted\":false,\"text\":\"\"}"
|
2023-07-10 13:42:25 +02:00
|
|
|
`ha-now-playing --host home.datarift.nl --token-file /run/secrets/ha_now_playing_token --entity media_player.sonos_woonkamer`)
|
2023-07-04 20:24:29 +02:00
|
|
|
|
|
|
|
(deflisten wm-info
|
|
|
|
:initial "{\"workspaces\":[],\"mode\":\"default\",\"title\":\"\"}"
|
2023-07-10 13:42:25 +02:00
|
|
|
`./scripts/workspaces.nu`)
|
2023-07-04 20:24:29 +02:00
|
|
|
|
|
|
|
;; Widgets
|
|
|
|
(defwidget mode []
|
|
|
|
(box :space-evenly false
|
|
|
|
:spacing 2
|
|
|
|
:class "mode"
|
|
|
|
(label :class "icon"
|
|
|
|
:visible {wm-info.mode != "default"}
|
|
|
|
:text "")
|
|
|
|
(label :visible {wm-info.mode != "default"}
|
|
|
|
:text {wm-info.mode})))
|
|
|
|
|
|
|
|
(defwidget workspaces []
|
|
|
|
(box :space-evenly false
|
|
|
|
:spacing 5
|
|
|
|
:class "workspaces"
|
|
|
|
(box :space-evenly false
|
|
|
|
:spacing 0
|
|
|
|
(for ws in {wm-info.workspaces}
|
|
|
|
(button :onclick "swaymsg workspace ${ws.name}"
|
|
|
|
:class "ws${ws.visible ? ' visible' : ''}${ws.focused ? ' focused' : ''}${ws.urgent ? ' urgent' : ''}"
|
|
|
|
(box :space-evenly false
|
|
|
|
:spacing 2
|
|
|
|
(label :class "icon small"
|
|
|
|
:visible {!ws.focused && !ws.urgent}
|
|
|
|
:text "")
|
|
|
|
(label :class "icon small"
|
|
|
|
:visible {ws.focused}
|
|
|
|
:text "")
|
|
|
|
(label :class "icon small"
|
|
|
|
:visible {ws.urgent}
|
|
|
|
:text "")
|
|
|
|
(label :text "${ws.name}"))))
|
|
|
|
(mode))))
|
|
|
|
|
|
|
|
;; (defwidget workspaces []
|
|
|
|
;; (box :space-evenly false
|
|
|
|
;; :spacing 5
|
|
|
|
;; :class "workspaces"
|
|
|
|
;; (label :text {wm-info.title})))
|
|
|
|
|
|
|
|
(defwidget ha-now-playing []
|
|
|
|
(eventbox :onclick "${ha-now-playing} play-pause"
|
|
|
|
:onrightclick "${ha-now-playing} ${sonos-now-playing.muted ? 'unmute' : 'mute'}"
|
|
|
|
:onscroll "${ha-now-playing} volume-{}"
|
2023-07-10 13:42:25 +02:00
|
|
|
:active true
|
|
|
|
:halign "start"
|
2023-07-04 20:24:29 +02:00
|
|
|
(box :class "ha-now-playing"
|
|
|
|
:space-evenly false
|
|
|
|
:spacing 2
|
|
|
|
(label :class "icon"
|
|
|
|
:text "")
|
|
|
|
(label :text {sonos-now-playing.text}))))
|
|
|
|
|
|
|
|
(defwidget date-time []
|
|
|
|
(eventbox :onclick "${EWW_CMD} update show-date=${!show-date}"
|
|
|
|
:cursor "pointer"
|
|
|
|
(box :class "time"
|
|
|
|
:space-evenly false
|
|
|
|
:spacing 2
|
|
|
|
(label :visible {!show-date}
|
|
|
|
:class "icon"
|
|
|
|
:text "")
|
|
|
|
(label :visible {!show-date}
|
|
|
|
:text "${formattime(EWW_TIME, '%H:%M:%S')}")
|
|
|
|
(label :visible show-date
|
|
|
|
:class "icon"
|
|
|
|
:text "")
|
|
|
|
(label :visible show-date
|
|
|
|
:text "${formattime(EWW_TIME, '%a, %d %b %Y')}"))))
|
|
|
|
|
|
|
|
|
|
|
|
(defwidget memory []
|
|
|
|
(box :class "memory"
|
|
|
|
:space-evenly false
|
|
|
|
:spacing 2
|
|
|
|
:tooltip "${round(EWW_RAM.used_mem / 1024 / 1024 / 1024, 2)}GiB / ${round(EWW_RAM.total_mem / 1024 / 1024 / 1024, 2)}GiB used"
|
|
|
|
(label :class "icon"
|
|
|
|
:text "")
|
|
|
|
(label :text "${round(EWW_RAM.used_mem_perc, 1)}%")))
|
|
|
|
|
|
|
|
(defwidget cpu []
|
|
|
|
(box :class "cpu"
|
|
|
|
:space-evenly false
|
|
|
|
:spacing 2
|
|
|
|
:tooltip {jq(EWW_CPU, "reduce .cores[] as $core (\"\"; . + $core.core + \": \" + ($core.usage | tostring) + \"%\\n\") | {tooltip:.}").tooltip}
|
|
|
|
(label :class "icon"
|
|
|
|
:text "")
|
|
|
|
(label :text "${round(EWW_CPU.avg, 2)}%")))
|
|
|
|
|
|
|
|
(defwidget temperature []
|
|
|
|
(box :class "temperature"
|
|
|
|
:space-evenly false
|
|
|
|
:spacing 2
|
2023-09-06 17:00:41 +02:00
|
|
|
:tooltip {jq(EWW_TEMPS, ". | to_entries | reduce .[] as $temp (\"\"; . + $temp.key + \": \" + ($temp.value | tostring) + \"\\n\") | {tooltip:.}").tooltip}
|
2023-07-04 20:24:29 +02:00
|
|
|
(label :class "icon"
|
|
|
|
:text "")
|
|
|
|
(label :text "${round(EWW_TEMPS.ZENPOWER_TDIE, 1)}°C")))
|
|
|
|
|
|
|
|
(defwidget volume []
|
|
|
|
(eventbox :onhover "${EWW_CMD} update show-volume=true"
|
|
|
|
:onhoverlost "${EWW_CMD} update show-volume=false"
|
|
|
|
:onclick "pamedia mute"
|
|
|
|
:onmiddleclick "helvum"
|
|
|
|
:onrightclick "pavucontrol"
|
|
|
|
:tooltip "Volume: ${volume-current}%"
|
|
|
|
:cursor "pointer"
|
|
|
|
(box :space-evenly false
|
|
|
|
:spacing 5
|
|
|
|
:class "volume"
|
|
|
|
(revealer :transition "slideleft"
|
|
|
|
:reveal show-volume
|
|
|
|
:duration "550ms"
|
|
|
|
(scale :class "volume-bar"
|
|
|
|
:flipped true
|
|
|
|
:value volume-current
|
|
|
|
:orientation "h"
|
|
|
|
:min 0
|
|
|
|
:max 101
|
|
|
|
:round-digits 0
|
|
|
|
:tooltip "Volume: ${volume-current}%"
|
|
|
|
:onchange "pamedia set {}"))
|
|
|
|
(label :class "icon"
|
|
|
|
:visible {!volume-muted}
|
|
|
|
:text "")
|
|
|
|
(label :class "icon"
|
|
|
|
:visible volume-muted
|
|
|
|
:text ""))))
|
|
|
|
|
|
|
|
(defwidget control []
|
|
|
|
(box :class "control"
|
|
|
|
:space-evenly false
|
|
|
|
:spacing 2
|
|
|
|
(volume)
|
|
|
|
(cpu)
|
|
|
|
(temperature)
|
|
|
|
(memory)))
|
|
|
|
|
|
|
|
(defwidget power []
|
|
|
|
(eventbox :onhover "${EWW_CMD} update power=true"
|
|
|
|
:onhoverlost "${EWW_CMD} update power=false"
|
|
|
|
:cursor "pointer"
|
|
|
|
(box :space-evenly false
|
|
|
|
:class "powermenu"
|
|
|
|
(revealer :transition "slideleft"
|
|
|
|
:reveal power
|
|
|
|
:duration "550ms"
|
|
|
|
(box :orientation "h"
|
|
|
|
:space-evenly false
|
|
|
|
|
|
|
|
(button :class "button-reboot"
|
|
|
|
:tooltip "Reboot"
|
|
|
|
:onclick "systemctl reboot" "")
|
|
|
|
|
|
|
|
(button :class "button-quit"
|
|
|
|
:tooltip "Logout"
|
|
|
|
:onclick "i3-msg exit" "")
|
|
|
|
|
|
|
|
(button :class "button-hibernate"
|
|
|
|
:tooltip "Hibernate"
|
|
|
|
:onclick "systemctl hibernate" "")))
|
|
|
|
|
|
|
|
(button :class "button-shutdown"
|
|
|
|
:tooltip "Shutdown"
|
|
|
|
:onclick "systemctl shutdown" ""))))
|
|
|
|
|
2023-10-23 08:10:43 +02:00
|
|
|
(defwidget headset []
|
|
|
|
(button :space-evenly false
|
|
|
|
:class "headset-button"
|
|
|
|
:click "headsetcontrol -s 128"
|
|
|
|
:onrightclick "headsetcontrol -s 0"
|
|
|
|
" "))
|
|
|
|
|
2023-07-04 20:24:29 +02:00
|
|
|
(defwidget title []
|
|
|
|
(label :text {wm-info.title}))
|
|
|
|
|
2023-09-29 11:52:45 +02:00
|
|
|
(defwidget left [is-home]
|
2023-07-04 20:24:29 +02:00
|
|
|
(box :orientation "h"
|
|
|
|
:halign "start"
|
2023-07-10 13:42:25 +02:00
|
|
|
:space-evenly false
|
|
|
|
:spacing 5
|
2023-07-04 20:24:29 +02:00
|
|
|
(workspaces)
|
2023-09-29 11:52:45 +02:00
|
|
|
(ha-now-playing
|
|
|
|
:visible is-home)))
|
2023-07-04 20:24:29 +02:00
|
|
|
|
|
|
|
(defwidget right []
|
|
|
|
(box :orientation "h"
|
|
|
|
:space-evenly false
|
|
|
|
:halign "end"
|
|
|
|
(date-time)
|
|
|
|
(power)))
|
|
|
|
|
|
|
|
(defwidget end []
|
|
|
|
(box :orientation "h"
|
|
|
|
:halign "end"
|
|
|
|
:space-evenly false
|
2023-10-23 08:10:43 +02:00
|
|
|
(children)
|
2023-07-04 20:24:29 +02:00
|
|
|
(control)
|
|
|
|
(right)))
|
|
|
|
|
|
|
|
(defwidget bar []
|
|
|
|
(box :class "eww_bar"
|
|
|
|
:orientation "h"
|
|
|
|
:hexpand false
|
|
|
|
:vexpand false
|
|
|
|
(centerbox
|
2023-09-29 11:52:45 +02:00
|
|
|
(left :is-home true)
|
|
|
|
(title)
|
|
|
|
(end))))
|
|
|
|
|
|
|
|
(defwidget bar-work-left []
|
|
|
|
(box :class "eww_bar"
|
|
|
|
:orientation "h"
|
|
|
|
:hexpand false
|
|
|
|
:vexpand false
|
|
|
|
(centerbox
|
|
|
|
(left :is-home false)
|
2023-07-04 20:24:29 +02:00
|
|
|
(title)
|
2023-10-23 08:10:43 +02:00
|
|
|
(end
|
|
|
|
(headset)))))
|
2023-07-04 20:24:29 +02:00
|
|
|
|
|
|
|
;; Bar windows
|
2023-07-10 13:42:25 +02:00
|
|
|
(defwindow bar-home
|
2023-07-04 20:24:29 +02:00
|
|
|
:geometry (geometry :x "0"
|
|
|
|
:y "0"
|
|
|
|
:width "100%"
|
2023-07-19 14:07:16 +02:00
|
|
|
:height "32px"
|
2023-07-04 20:24:29 +02:00
|
|
|
:anchor "top center")
|
|
|
|
:stacking "fg"
|
|
|
|
:monitor 0
|
|
|
|
:reserve (struts :distance "47px"
|
|
|
|
:side "top")
|
|
|
|
:wm-ignore false
|
|
|
|
:hexpand false
|
|
|
|
:vexpand false
|
|
|
|
:exclusive true
|
|
|
|
(bar))
|
2023-09-29 11:52:45 +02:00
|
|
|
|
|
|
|
(defwindow bar-work
|
|
|
|
:geometry (geometry :x "0"
|
|
|
|
:y "0"
|
|
|
|
:width "100%"
|
|
|
|
:height "32px"
|
|
|
|
:anchor "top center")
|
|
|
|
:stacking "fg"
|
|
|
|
:monitor 0
|
|
|
|
:exclusive true
|
|
|
|
:hexpand false
|
|
|
|
:vexpand false
|
|
|
|
(bar-work-left))
|