eww: Better workspaces

This commit is contained in:
2024-05-15 23:22:39 +02:00
parent f4b52e2836
commit 6540833edc
3 changed files with 39 additions and 18 deletions

View File

@ -31,18 +31,23 @@ window {
border-radius: 30px; border-radius: 30px;
padding-top: 3px; padding-top: 3px;
padding-bottom: 5px; padding-bottom: 5px;
margin-top: 3px; margin-bottom: 6px;
margin-bottom: 3px; transition: border-color 0.5s;
box-shadow: 0 0px 5px 1px #06060b;
transition: all 1s;
} }
.workspace.active { .workspace.active {
border: solid $highlight2 2px; border: solid $highlight2 2px;
} }
.workspace:hover {
background-color: $lowlight2;
}
.workspace:active {
background-color: $highlight2;
}
.workspaces { .workspaces {
margin-top: 10px;
margin-bottom: 10px; margin-bottom: 10px;
} }

View File

@ -33,7 +33,7 @@
(defwidget bottom [] (defwidget bottom []
(box :orientation "v" (box :orientation "v"
:valign "end" :valign "end"
:class "bottom" :class "bottom"
:space-evenly false :space-evenly false
(vpn) (vpn)
(speaker) (speaker)
@ -49,11 +49,27 @@
(box :orientation "v" (box :orientation "v"
:valign "start" :valign "start"
:class "workspaces" :class "workspaces"
:space-evenly: false :space-evenly: false
(for workspace in workspaces_json ; can't use a for loop here because that breaks css animations
(button :visible {workspace.monitor == monitor} :class 'workspace ${workspace.class}' (workspace :n 1)
(label :text '${workspace.id}')) (workspace :n 2)
))) (workspace :n 3)
(workspace :n 4)
(workspace :n 5)
(workspace :n 6)
(workspace :n 7)
(workspace :n 8)
(workspace :n 9)
(workspace :n 10)
(workspace :n 11)
(workspace :n 12)
))
(defwidget workspace [n]
(button :visible {jq(workspaces, '.["${n}"] != null')}
:class 'workspace ${workspaces[n].class}'
(label :text n))
)
(defwidget speaker [] (defwidget speaker []
(eventbox (eventbox
@ -61,7 +77,7 @@
:onhoverlost "${EWW_CMD} update show_volume=false" :onhoverlost "${EWW_CMD} update show_volume=false"
(box :orientation "v" (box :orientation "v"
:class "thingy volbox ${show_volume ? "active" : ""}" :class "thingy volbox ${show_volume ? "active" : ""}"
:space-evenly false :space-evenly false
(revealer :transition "slidedown" (revealer :transition "slidedown"
:reveal show_volume :reveal show_volume
(scale :orientation "v" (scale :orientation "v"
@ -83,7 +99,7 @@
(button :valign "end" (button :valign "end"
:class "vpn thingy ${vpn_status.class}" :class "vpn thingy ${vpn_status.class}"
:onclick "${vpn_status.on_click}" :onclick "${vpn_status.on_click}"
:tooltip "${vpn_status.tooltip}" :tooltip "${vpn_status.tooltip}"
(label :text "${vpn_status.icon}") (label :text "${vpn_status.icon}")
)) ))
@ -100,7 +116,7 @@
(box :orientation "v" (box :orientation "v"
:valign "end" :valign "end"
:class "thingy" :class "thingy"
:visible {bat_charge != ""} :visible {bat_charge != ""}
(label :text "BAT") (label :text "BAT")
(circular-progress (circular-progress
:thickness 4.0 :thickness 4.0
@ -110,7 +126,6 @@
bat_charge < 15 ? "battery-gauge low" : bat_charge < 15 ? "battery-gauge low" :
"battery-gauge" "battery-gauge"
} }
;:style {bat_charge < 15 ? "color: red;" : ""}
) )
;(label :text "${bat_charge}%") ;(label :text "${bat_charge}%")
)) ))
@ -138,7 +153,7 @@
(button :orientation "v" (button :orientation "v"
:valign "end" :valign "end"
:class "thingy pwrbtn clickable" :class "thingy pwrbtn clickable"
:onclick "${EWW_CMD} open --toggle pwrctl" :onclick "${EWW_CMD} open --toggle pwrctl"
(label :text "⏻") (label :text "⏻")
)) ))
@ -160,7 +175,7 @@
(defvar show_volume false) (defvar show_volume false)
(defpoll workspaces_json :interval "1s" "eww-workspaces") (defpoll workspaces :interval "1s" "eww-workspaces")
(defpoll volume_out :interval "1s" "pamixer --get-volume") (defpoll volume_out :interval "1s" "pamixer --get-volume")
(defpoll vpn_status :interval "1s" "mullvad-status") (defpoll vpn_status :interval "1s" "mullvad-status")
(defpoll current_minute :interval "1s" "date +%M") (defpoll current_minute :interval "1s" "date +%M")

View File

@ -5,5 +5,6 @@ let active = (hyprctl activeworkspace -j | from json | get id)
hyprctl workspaces -j | hyprctl workspaces -j |
from json | from json |
sort-by id | sort-by id |
each {|w| {id: $w.id monitor: $w.monitorID class: (if ($w.id == $active) {"active"} else {""}) }} | each {|w| {$w.id: {monitor: $w.monitorID class: (if ($w.id == $active) {"active"} else {""}) }}} |
reduce {|a, b| $a | merge $b } |
to json to json