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

@ -9,6 +9,7 @@ $accent: #f6a8cf;
* { * {
all: unset; all: unset;
font-family: "Quicksand Medium";
} }
@mixin segment { @mixin segment {
@ -19,18 +20,17 @@ $accent: #f6a8cf;
.bar { .bar {
background-color: $background; background-color: $background;
font-family: "Quicksand Medium";
color: $foreground; color: $foreground;
font-size: 13px; font-size: 13px;
padding: 3px 10px; padding: 3px 0px;
} }
tooltip { tooltip {
background-color: rgba(0,0,0,0.8); background-color: rgba(22, 16, 30, 0.9);
font-family: "JetBrains Mono"; border-radius: 5px;
font-size: 12px; font-size: 13px;
} }
.detail { .detail {
@ -45,7 +45,7 @@ tooltip {
} }
.bar-window { .bar-window {
margin-left: 4px; margin-left: 14px;
.detail { .detail {
margin-top: 1px; margin-top: 1px;
@ -71,12 +71,9 @@ tooltip {
.bar-music { .bar-music {
@include segment; @include segment;
padding-left: 3px; padding: 0px 2px;
padding-right: 10px;
.progress { .progress {
margin-right: 5px;
.back { .back {
color: $background-scale; color: $background-scale;
} }
@ -86,6 +83,12 @@ tooltip {
} }
} }
.symbol.stopped {
font-size: 15px;
color: $foreground-alt;
margin-left: -2px;
}
.symbol.paused { .symbol.paused {
font-size: 12px; font-size: 12px;
margin-left: 2px; margin-left: 2px;
@ -96,6 +99,11 @@ tooltip {
margin-top: 1px; margin-top: 1px;
} }
.bar-music-meta {
margin-left: 6px;
margin-right: 10px;
}
.bar-artist { .bar-artist {
margin-top: 1px; margin-top: 1px;
margin-bottom: -2px; margin-bottom: -2px;
@ -247,12 +255,19 @@ scale trough {
} }
} }
.bar-idleinhibit { .bar-power {
margin-left: 3px; font-size: 18px;
margin-right: 4px; margin-left: 4px;
color: $disabled; margin-right: 10px;
color: #f7768e;
}
&.active { .power {
color: #f7768e; font-size: 36px;
button > box {
background-color: $background;
border-radius: 8px;
margin: 5px;
} }
} }

View file

@ -28,13 +28,13 @@
(defwidget bar_workspace_button [workspace] (defwidget bar_workspace_button [workspace]
(eventbox :onclick "hyprctl dispatch workspace ${workspace.id}" (eventbox :onclick "hyprctl dispatch workspace ${workspace.id}"
(overlay (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.windows > 0 ? "occupied" : "empty"
} ${workspace.previous > 0 ? "previous-occupied" : "previous-empty" } ${workspace.previous > 0 ? "previous-occupied" : "previous-empty"
} ${workspace.next > 0 ? "next-occupied" : "next-empty"}" } ${workspace.next > 0 ? "next-occupied" : "next-empty"}"
(label :text "${workspace.id}")) (label :text {workspace.id}))
(box :visible {workspace.id == current_workspace} (box :visible {workspace.id == current_workspace}
(label :text "${workspace.id}"))))) (label :text {workspace.id})))))
(defwidget bar_workspaces [] (defwidget bar_workspaces []
(eventbox :onscroll "scripts/change-active-workspace {} ${current_workspace}" (eventbox :onscroll "scripts/change-active-workspace {} ${current_workspace}"
@ -66,20 +66,17 @@
(deflisten mpris :initial "{}" (deflisten mpris :initial "{}"
"scripts/mpris-metadata") "scripts/mpris-metadata")
(defwidget bar_music [width artist-limit title-limit] (defwidget bar_music [artist-limit title-limit]
(eventbox :onclick "playerctl play-pause" (eventbox :onclick "playerctl play-pause"
(box :class "bar-music segment" (box :class "bar-music"
:orientation "h" :orientation "h"
:width width
:space-evenly false :space-evenly false
(box :class "progress" (box :class "progress"
(overlay (overlay
(circular-progress :class "back" (circular-progress :class "back"
:value 100 :value 100
:width 25 :width 25
:thickness 2 :thickness 2)
:start-at 75
:clockwise true)
(circular-progress :class "front" (circular-progress :class "front"
:value {(mpris.position ?: 0) == 0 || :value {(mpris.position ?: 0) == 0 ||
(mpris.duration ?: 0) == 0 ? 0 : (mpris.duration ?: 0) == 0 ? 0 :
@ -89,19 +86,24 @@
:thickness 2 :thickness 2
:start-at 75 :start-at 75
:clockwise true) :clockwise true)
(label :class "symbol ${mpris.status == "Playing" ? "playing" : "paused"}" (label :class "symbol ${(mpris.title ?: "") == "" || (mpris.status ?: "Stopped") == "Stopped" ? "stopped" :
:text {mpris.status == "Playing" ? "󰏤" : ""}))) mpris.status == "Playing" ? "playing" : "paused"}"
(box :orientation "v" :text {(mpris.title ?: "") == "" || (mpris.status ?: "Stopped") == "Stopped" ? "" :
:space-evenly false mpris.status == "Playing" ? "󰏤" : ""})))
:visible {(mpris.title ?: "") != "" && (mpris.status ?: "Stopped") != "Stopped"} (revealer :transition "slideright"
(label :class "bar-artist detail" :duration "800ms"
:halign "start" :reveal {(mpris.title ?: "") != "" && (mpris.status ?: "Stopped") != "Stopped"}
:limit-width artist-limit (box :orientation "v"
:text {mpris.artist ?: ""}) :class "bar-music-meta"
(label :halign "bar-title" :space-evenly false
:limit-width title-limit (label :class "bar-artist detail"
:text {mpris.title ?: ""}))))) :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) ;; Scales (Volume + Brightness)
@ -222,21 +224,67 @@
:tooltip {ethernet != "{}" ? "${ethernet.name} (${ethernet.device})" : :tooltip {ethernet != "{}" ? "${ethernet.name} (${ethernet.device})" :
wifi != "{}" ? "${wifi.name} (${wifi.device})" : ""} wifi != "{}" ? "${wifi.name} (${wifi.device})" : ""}
(label :class "symbol" (label :class "symbol"
:text {wifi != "{}" ? "󰤨" : ethernet != "{}" ? "󰈁" : "󰤮"}))) :text {wifi != "{}" ? "󰤨" : ethernet != "{}" ? "󰈀" : "󰤮"})))
(defwidget bar_bluetooth [] (defwidget bar_bluetooth []
(box :class "bar-bluetooth ${bluetooth == "{}" ? "disabled" : ""}" (box :class "bar-bluetooth ${bluetooth == "{}" ? "disabled" : ""}"
(label :text {bluetooth != "{}" ? "󰂯" : "󰂲"}))) (label :text {bluetooth != "{}" ? "󰂯" : "󰂲"})))
;; Idle Inhibitor ;; Power Menu
(defpoll idleinhibit :interval "10s" :initial "0" (defpoll idleinhibit :interval "10s" :initial "0"
"pgrep -c -f wayland\"\"-idle-inhibitor || true") "pgrep -c -f wayland\"\"-idle-inhibitor || true")
(defwidget bar_idleinhibit [] (defwidget bar_power []
(eventbox :onclick "scripts/toggle-idle-inhibit && ${EWW_CMD} poll idleinhibit" (eventbox :onclick "${EWW_CMD} active-windows | grep -q power \
(box :class "bar-idleinhibit ${idleinhibit > 0 ? "active" : ""}" && ${EWW_CMD} close power || ${EWW_CMD} open power"
(label :text {idleinhibit > 0 ? "󰈈" : "󰛑"})))) (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 ;; Separator
@ -290,7 +338,7 @@
(bar_ram) (bar_ram)
(bar_battery) (bar_battery)
(bar_sep) (bar_sep)
(bar_idleinhibit))) (bar_power)))
(defwidget fire_bar_layout [] (defwidget fire_bar_layout []
(centerbox :class "bar" (centerbox :class "bar"
@ -366,7 +414,7 @@
(defwindow fire_bar (defwindow fire_bar
:monitor 0 :monitor 0
:geometry (geometry :width "100%" :geometry (geometry :width "100%"
:height "3%" :height "35px"
:anchor "top center") :anchor "top center")
:namespace "eww-bar" :namespace "eww-bar"
:stacking "fg" :stacking "fg"
@ -377,7 +425,7 @@
(defwindow earth_bar (defwindow earth_bar
:monitor 0 :monitor 0
:geometry (geometry :width "100%" :geometry (geometry :width "100%"
:height "3%" :height "35px"
:anchor "top center") :anchor "top center")
:namespace "eww-bar" :namespace "eww-bar"
:stacking "fg" :stacking "fg"

View file

@ -93,7 +93,6 @@ in {
bind = [ bind = [
"$mod, Return, exec, $terminal" "$mod, Return, exec, $terminal"
"$mod, D, exec, $menu" "$mod, D, exec, $menu"
"$mod Shift, E, exec, ${scripts}/exit"
"$mod, M, exec, hyprlock --immediate" "$mod, M, exec, hyprlock --immediate"
# Emacs Everywhere # Emacs Everywhere

View file

@ -1,4 +0,0 @@
#!/usr/bin/env bash
pkill -0 swaynag || \
swaynag -t exit -m "Do you really want to exit?" \
-B "Reboot" "reboot" -B "Shutdown" "poweroff" -b "Exit" "hyprctl dispatch exit"

View file

@ -9,19 +9,6 @@
imv imv
]; ];
xdg.configFile."swaynag/config".text = ''
font=JetBrainsMono 10
layer=top
[exit]
background=111320D0
text=a9b1d6
border-bottom=7BC5E4
border-bottom-size=1
button-background=282E49F0
button-border-size=2
'';
# Hyprlock # Hyprlock
programs.hyprlock.enable = true; programs.hyprlock.enable = true;