feat: EWW power menu

This commit is contained in:
Kiana Sheibani 2025-02-25 00:48:57 -05:00
parent 99d593dfe5
commit 7a4b7cd6cc
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
5 changed files with 110 additions and 65 deletions

View file

@ -28,13 +28,13 @@
(defwidget bar_workspace_button [workspace]
(eventbox :onclick "hyprctl dispatch workspace ${workspace.id}"
(overlay
(box :class "segment workspace-button ${workspace.id == current_workspace ? "current" : ""
(box :class "workspace-button ${workspace.id == current_workspace ? "current" : ""
} ${workspace.windows > 0 ? "occupied" : "empty"
} ${workspace.previous > 0 ? "previous-occupied" : "previous-empty"
} ${workspace.next > 0 ? "next-occupied" : "next-empty"}"
(label :text "${workspace.id}"))
(label :text {workspace.id}))
(box :visible {workspace.id == current_workspace}
(label :text "${workspace.id}")))))
(label :text {workspace.id})))))
(defwidget bar_workspaces []
(eventbox :onscroll "scripts/change-active-workspace {} ${current_workspace}"
@ -66,20 +66,17 @@
(deflisten mpris :initial "{}"
"scripts/mpris-metadata")
(defwidget bar_music [width artist-limit title-limit]
(defwidget bar_music [artist-limit title-limit]
(eventbox :onclick "playerctl play-pause"
(box :class "bar-music segment"
(box :class "bar-music"
:orientation "h"
:width width
:space-evenly false
(box :class "progress"
(overlay
(circular-progress :class "back"
:value 100
:width 25
:thickness 2
:start-at 75
:clockwise true)
:thickness 2)
(circular-progress :class "front"
:value {(mpris.position ?: 0) == 0 ||
(mpris.duration ?: 0) == 0 ? 0 :
@ -89,19 +86,24 @@
:thickness 2
:start-at 75
:clockwise true)
(label :class "symbol ${mpris.status == "Playing" ? "playing" : "paused"}"
:text {mpris.status == "Playing" ? "󰏤" : ""})))
(box :orientation "v"
:space-evenly false
:visible {(mpris.title ?: "") != "" && (mpris.status ?: "Stopped") != "Stopped"}
(label :class "bar-artist detail"
:halign "start"
:limit-width artist-limit
:text {mpris.artist ?: ""})
(label :halign "bar-title"
:limit-width title-limit
:text {mpris.title ?: ""})))))
(label :class "symbol ${(mpris.title ?: "") == "" || (mpris.status ?: "Stopped") == "Stopped" ? "stopped" :
mpris.status == "Playing" ? "playing" : "paused"}"
:text {(mpris.title ?: "") == "" || (mpris.status ?: "Stopped") == "Stopped" ? "" :
mpris.status == "Playing" ? "󰏤" : ""})))
(revealer :transition "slideright"
:duration "800ms"
:reveal {(mpris.title ?: "") != "" && (mpris.status ?: "Stopped") != "Stopped"}
(box :orientation "v"
:class "bar-music-meta"
:space-evenly false
(label :class "bar-artist detail"
:halign "start"
:limit-width artist-limit
:text {mpris.artist ?: ""})
(label :class "bar-title"
:halign "start"
:limit-width title-limit
:text {mpris.title ?: ""}))))))
;; Scales (Volume + Brightness)
@ -222,21 +224,67 @@
:tooltip {ethernet != "{}" ? "${ethernet.name} (${ethernet.device})" :
wifi != "{}" ? "${wifi.name} (${wifi.device})" : ""}
(label :class "symbol"
:text {wifi != "{}" ? "󰤨" : ethernet != "{}" ? "󰈁" : "󰤮"})))
:text {wifi != "{}" ? "󰤨" : ethernet != "{}" ? "󰈀" : "󰤮"})))
(defwidget bar_bluetooth []
(box :class "bar-bluetooth ${bluetooth == "{}" ? "disabled" : ""}"
(label :text {bluetooth != "{}" ? "󰂯" : "󰂲"})))
;; Idle Inhibitor
;; Power Menu
(defpoll idleinhibit :interval "10s" :initial "0"
"pgrep -c -f wayland\"\"-idle-inhibitor || true")
(defwidget bar_idleinhibit []
(eventbox :onclick "scripts/toggle-idle-inhibit && ${EWW_CMD} poll idleinhibit"
(box :class "bar-idleinhibit ${idleinhibit > 0 ? "active" : ""}"
(label :text {idleinhibit > 0 ? "󰈈" : "󰛑"}))))
(defwidget bar_power []
(eventbox :onclick "${EWW_CMD} active-windows | grep -q power \
&& ${EWW_CMD} close power || ${EWW_CMD} open power"
(box :class "bar-power"
(label :text "⏻"))))
(defwindow power
:monitor 0
:geometry (geometry
:width "375px"
:height "150px"
:anchor "top right")
:namespace "eww-bar"
:stacking "fg"
:exclusive false
:focusable false
(eventbox :onhoverlost "${EWW_CMD} close power"
(box :class "power"
:orientation "v"
(box :orientation "h"
(button :onclick "systemctl suspend"
:tooltip "Sleep"
(box :style "color: #9aa5ce;"
(label :text "󰤄")))
(button :onclick "hyprlock --immediate &"
:tooltip "Lock"
(box :style "color: #cfc9c2;"
(label :text "")))
(button :onclick "hyprctl dispatch exit"
:tooltip "Log Out"
(box :style "color: #7dcfff; padding-left: 0.3ex;"
(label :text "")))
(button :onclick "reboot"
:tooltip "Reboot"
(box :style "color: #e0af68;"
(label :text "")))
(button :onclick "poweroff"
:tooltip "Shutdown"
(box :style "color: #f7768e; font-size: 1.35em; padding-bottom: 0.15ex;"
(label :text "⏼"))))
(box
:orientation "h"
(box) (box) (box) (box)
(button :onclick "scripts/toggle-idle-inhibit && ${EWW_CMD} poll idleinhibit"
:tooltip "Idle Inhibitor: ${idleinhibit > 0 ? "On" : "Off"}"
(box :style "padding-right: 0.5ex; ${idleinhibit > 0 ?
"color: #ff9e64" :
"color: #565f89; padding-top: 0.3ex;"}"
(label :text {idleinhibit > 0 ? "󰈈" : "󰛑"})))))))
;; Separator
@ -290,7 +338,7 @@
(bar_ram)
(bar_battery)
(bar_sep)
(bar_idleinhibit)))
(bar_power)))
(defwidget fire_bar_layout []
(centerbox :class "bar"
@ -366,7 +414,7 @@
(defwindow fire_bar
:monitor 0
:geometry (geometry :width "100%"
:height "3%"
:height "35px"
:anchor "top center")
:namespace "eww-bar"
:stacking "fg"
@ -377,7 +425,7 @@
(defwindow earth_bar
:monitor 0
:geometry (geometry :width "100%"
:height "3%"
:height "35px"
:anchor "top center")
:namespace "eww-bar"
:stacking "fg"