From e04868b5d0b222ada91d8401bca1fd9b1285f105 Mon Sep 17 00:00:00 2001 From: vikingowl Date: Sat, 8 Mar 2025 17:44:11 +0100 Subject: [PATCH] added new widgets --- .config/eww/eww.scss | 1 + .config/eww/eww.yuck | 6 ++- .config/eww/scripts/getvol | 12 +++++ .config/eww/widgets.scss | 7 ++- .config/eww/widgets.yuck | 7 ++- .config/eww/widgets/hypr_activewindow.scss | 9 ++++ .config/eww/widgets/hypr_activewindow.yuck | 32 ++++++++++++++ .config/eww/widgets/hypr_workspaces.scss | 35 +++++++++++++++ .config/eww/widgets/hypr_workspaces.yuck | 24 ++++++++++ .config/eww/widgets/swaync.scss | 13 ++++++ .config/eww/widgets/swaync.yuck | 19 ++++++++ .config/eww/widgets/sysmon.scss | 19 ++++++++ .config/eww/widgets/sysmon.yuck | 51 ++++++++++++++++++++++ .config/eww/widgets/volume.scss | 12 +++++ .config/eww/widgets/volume.yuck | 17 ++++++++ 15 files changed, 261 insertions(+), 3 deletions(-) create mode 100644 .config/eww/scripts/getvol create mode 100644 .config/eww/widgets/hypr_activewindow.scss create mode 100644 .config/eww/widgets/hypr_activewindow.yuck create mode 100644 .config/eww/widgets/hypr_workspaces.scss create mode 100644 .config/eww/widgets/hypr_workspaces.yuck create mode 100644 .config/eww/widgets/swaync.scss create mode 100644 .config/eww/widgets/swaync.yuck create mode 100644 .config/eww/widgets/sysmon.scss create mode 100644 .config/eww/widgets/sysmon.yuck create mode 100644 .config/eww/widgets/volume.scss create mode 100644 .config/eww/widgets/volume.yuck diff --git a/.config/eww/eww.scss b/.config/eww/eww.scss index 531cc74..d7b4e1d 100644 --- a/.config/eww/eww.scss +++ b/.config/eww/eww.scss @@ -7,6 +7,7 @@ tooltip { background: #2E3440; color: #E5E6E7; + padding: 3px 1rem; border-radius: 1.5rem 1rem; border: 1px solid #6F7175; } diff --git a/.config/eww/eww.yuck b/.config/eww/eww.yuck index 14efb51..c44cbe1 100644 --- a/.config/eww/eww.yuck +++ b/.config/eww/eww.yuck @@ -46,7 +46,8 @@ :space-evenly true :spacing 5 :halign 'start' - (loremText :text "Workspaces") + (hypr_workspaces) + (hypr_active_window) ) ) @@ -57,6 +58,7 @@ :space-evenly false :spacing 5 (media) + (sysmon) ) ) @@ -68,8 +70,10 @@ :spacing 5 :halign 'end' (hyprsunset) + (volume) (datetime) (stray) + (swaync) ) ) diff --git a/.config/eww/scripts/getvol b/.config/eww/scripts/getvol new file mode 100644 index 0000000..4e4275d --- /dev/null +++ b/.config/eww/scripts/getvol @@ -0,0 +1,12 @@ +#!/bin/sh + +if command -v pamixer &>/dev/null; then + if [ true == $(pamixer --get-mute) ]; then + echo 0 + exit + else + pamixer --get-volume + fi +else + amixer -D pulse sget Master | awk -F '[^0-9]+' '/Left:/{print $3}' +fi diff --git a/.config/eww/widgets.scss b/.config/eww/widgets.scss index 03bd18b..836f93e 100644 --- a/.config/eww/widgets.scss +++ b/.config/eww/widgets.scss @@ -1,5 +1,10 @@ +@import 'widgets/lorem-text'; @import 'widgets/media'; @import 'widgets/datetime.scss'; @import 'widgets/systray'; @import 'widgets/hyprsunset'; -@import 'widgets/lorem-text'; +@import 'widgets/hypr_activewindow.scss'; +@import 'widgets/hypr_workspaces.scss'; +@import 'widgets/sysmon.scss'; +@import 'widgets/swaync.scss'; +@import 'widgets/volume.scss'; diff --git a/.config/eww/widgets.yuck b/.config/eww/widgets.yuck index 874b828..30a4b75 100644 --- a/.config/eww/widgets.yuck +++ b/.config/eww/widgets.yuck @@ -1,5 +1,10 @@ +(include "widgets/lorem-text.yuck") (include "widgets/media.yuck") (include "widgets/datetime.yuck") (include "widgets/systray.yuck") (include "widgets/hyprsunset.yuck") -(include "widgets/lorem-text.yuck") +(include "widgets/hypr_workspaces.yuck") +(include "widgets/hypr_activewindow.yuck") +(include "widgets/sysmon.yuck") +(include "widgets/swaync.yuck") +(include "widgets/volume.yuck") diff --git a/.config/eww/widgets/hypr_activewindow.scss b/.config/eww/widgets/hypr_activewindow.scss new file mode 100644 index 0000000..b80c64c --- /dev/null +++ b/.config/eww/widgets/hypr_activewindow.scss @@ -0,0 +1,9 @@ +.activewindow{ + background: lightgreen; + color: black; + + &--xwayland{ + background: maroon; + color: white; + } +} diff --git a/.config/eww/widgets/hypr_activewindow.yuck b/.config/eww/widgets/hypr_activewindow.yuck new file mode 100644 index 0000000..67ebb1c --- /dev/null +++ b/.config/eww/widgets/hypr_activewindow.yuck @@ -0,0 +1,32 @@ +(deflisten activewindow :initial "..." "hyprman -a 2>>/tmp/eww_hyprman_activewindow.log") + +(defvar windowIcons + `{ + "generic": "", + "spotify": "", + "mpv": "", + "firefox": "", + "chromium": "", + "zen": "", + "Alacritty": "", + "steam": "󰓓", + "discord": "󰙯" + }`) + +(defwidget windowIcon [] + (image + :icon-size: 12 + :icon {activewindow.class})) + +(defwidget hypr_active_window [] + (tooltip + (label :text {activewindow.title}) + (box + :class "activewindow${activewindow.xwayland == true ? '--xwayland' : ''}" + :halign "left" + :valign "center" + :spacing 3 + (label + :limit-width 25 + :unindent true + :text "${windowIcons[activewindow.class] ?: windowIcons['generic']} ${activewindow.class}")))) diff --git a/.config/eww/widgets/hypr_workspaces.scss b/.config/eww/widgets/hypr_workspaces.scss new file mode 100644 index 0000000..91eb0ed --- /dev/null +++ b/.config/eww/widgets/hypr_workspaces.scss @@ -0,0 +1,35 @@ +.workspaces { + /* Green */ + $light: #bad012; + $dark: #53730a; + + /* Orange */ + //$light: #fde10e; + //$dark: #ff6520; + + background: $dark; + padding: 3px 1rem; + + &--ws { + border-radius: 50%; + font-family: 'Symbols Nerd Font Mono'; + border: 1px solid blue; + color: black; + + &--label { + font-size: 0.7rem; + } + + &--active { + background: $light; + color: $dark; + border-color: $light; + } + + &--inactive { + background: $dark; + color: $dark; + border-color: $light; + } + } +} diff --git a/.config/eww/widgets/hypr_workspaces.yuck b/.config/eww/widgets/hypr_workspaces.yuck new file mode 100644 index 0000000..374a785 --- /dev/null +++ b/.config/eww/widgets/hypr_workspaces.yuck @@ -0,0 +1,24 @@ +(deflisten workspaces :initial "" "hyprman -w 2>>/tmp/eww_hyprman_workspaces.log") + +(defvar workspaceIcons '{ + "empty": "", + "full": "", + "focused": "󱓻" +}') + +(defwidget hypr_workspaces [] + (box + :class "workspaces" + :space-evenly false + :spacing 3 + (for workspace in workspaces + (eventbox + :height 20 + :width 20 + :onclick "hyprctl dispatch workspace ${workspace.id}" + :cursor "pointer" + :tooltip "${workspace.name}" + :class "workspaces--ws ${workspace.active == true ? 'workspaces--ws--active' : 'workspaces--ws--inactive'}" + (label + :class "workspaces--ws--label" + :text "${workspace.windows > 0 ? workspaceIcons.full : workspaceIcons.empty}"))))) diff --git a/.config/eww/widgets/swaync.scss b/.config/eww/widgets/swaync.scss new file mode 100644 index 0000000..a2e2392 --- /dev/null +++ b/.config/eww/widgets/swaync.scss @@ -0,0 +1,13 @@ +.swaync{ + background: aqua; + color: black; + &--dnd{ + background: rosybrown; + color: black; + } + &--inhib{ + background: indianred; + color: black; + } +} + diff --git a/.config/eww/widgets/swaync.yuck b/.config/eww/widgets/swaync.yuck new file mode 100644 index 0000000..69bca87 --- /dev/null +++ b/.config/eww/widgets/swaync.yuck @@ -0,0 +1,19 @@ +(deflisten notification :initial '{ "count": 0, "dnd": false, "visible": false, "inhibited": false }' "swaync-client -s") + +(defvar swaync_icon_act "󰀠") +(defvar swaync_icon_inh "󰚎") +(defvar swaync_icon_dnd "󰀣") + +(defwidget swaync [] + (eventbox + :class "swaync${notification.dnd == true ? " swaync--dnd" : ""}${notification.inhibited == true ? " swaync--inhib" : ""}" + :cursor "pointer" + :onclick "swaync-client -t" + :onmiddleclick "swaync-client -d" + :onrightclick "swaync-client -C" + (box + :orientation "horizontal" + :spacing 3 + :space-evenly false + (label :text "${notification.dnd == true ? swaync_icon_dnd : notification.inhibited == true ? swaync_icon_inh : swaync_icon_act}") + (label :text "${notification.count}")))) diff --git a/.config/eww/widgets/sysmon.scss b/.config/eww/widgets/sysmon.scss new file mode 100644 index 0000000..50bb8ab --- /dev/null +++ b/.config/eww/widgets/sysmon.scss @@ -0,0 +1,19 @@ +.sysmon{ + background: transparent; + color: black; +} +.danger{ + color: red +} +.ram{ + background: tan; +} +.disk{ + background: mediumturquoise; +} +.cpu{ + background: lightgreen; +} +.net{ + background: plum; +} diff --git a/.config/eww/widgets/sysmon.yuck b/.config/eww/widgets/sysmon.yuck new file mode 100644 index 0000000..b3adf31 --- /dev/null +++ b/.config/eww/widgets/sysmon.yuck @@ -0,0 +1,51 @@ +(defvar netiface "eno1") + +(defwidget sysmon [] + (box + :class 'sysmon' + :space-evenly false + :spacing 1 + (cpu) + (ram) + (disk) + (net))) + +(defwidget ram [] + (tooltip + :class 'ram ${EWW_RAM.used_mem_perc > 90 ? 'danger' : ''}' + (label :text " ${round(EWW_RAM.free_swap/1000000000, 2)} GB/${round(EWW_RAM.total_swap/1000000000, 2)} GB") + (label :text " ${round(EWW_RAM.used_mem/1000000000, 2)} GB/${round(EWW_RAM.total_mem/1000000000, 2)} GB"))) + +(defwidget disk [] + (tooltip + :class 'disk ${EWW_DISK["/"].used_perc > 90 ? 'danger' : ''}' + (label :text " ${round(EWW_DISK["/"].free/1000000000, 2)} GB /${round(EWW_DISK["/"].total/1000000000, 2)} GB") + (label :text " ${round(EWW_DISK["/"].used_perc,2)}%"))) + +(defwidget cpu [] + (tooltip + :class 'cpu' + (box :orientation "vertical" + (for cpu in {EWW_CPU.cores} + (box + :orientation "horizontal" + :space-evenly false + :spacing 10 + (circular-progress + :thickness 5 + :start-at 75 + :value {cpu.usage}) + (label + :limit-width 6 + :show-truncated false + :text "${cpu.core}: ") + (label :text "${cpu.freq} Hz ${cpu.usage}%")))) + (label :text " ${round(EWW_CPU.avg, 2)}%"))) + +(defwidget net [] + (box + :class 'net' + :space-evenly false + (label :text "") + (label :text " ${round(EWW_NET[netiface].NET_UP * 8 / 1000000, 2)} Mbit") + (label :text " ${round(EWW_NET[netiface].NET_DOWN * 8 / 1000000, 2)} Mbit"))) diff --git a/.config/eww/widgets/volume.scss b/.config/eww/widgets/volume.scss new file mode 100644 index 0000000..16d4813 --- /dev/null +++ b/.config/eww/widgets/volume.scss @@ -0,0 +1,12 @@ +.sourcevol{ + background: steelblue; + color: black; +} +.sinkvol{ + background: slateblue; + color: black; +} +.muted{ + background: tomato; + color: white; +} diff --git a/.config/eww/widgets/volume.yuck b/.config/eww/widgets/volume.yuck new file mode 100644 index 0000000..f5f55a8 --- /dev/null +++ b/.config/eww/widgets/volume.yuck @@ -0,0 +1,17 @@ +(defpoll sourcevol :interval "1s" `wpctl get-volume @DEFAULT_SOURCE@ | awk -F ' ' '{print $2}'`) +(defpoll sourcemute :interval "1s" `wpctl get-volume @DEFAULT_SOURCE@ | awk -F ' ' '{print $3}'`) +(defpoll sinkvol :interval "200ms" `wpctl get-volume @DEFAULT_SINK@ | awk -F ' ' '{print $2}'`) +(defpoll sinkmute :interval "1s" `wpctl get-volume @DEFAULT_SINK@ | awk -F ' ' '{print $3}'`) + +(defwidget volume [] + (box + :space-evenly false + :spacing 3 + (eventbox + :class "sourcevol${sourcemute == "[MUTED]" ? " muted" : ""}" + :onclick "wpctl set-mute @DEFAULT_SOURCE@ toggle" + (label :text "${sourcemute == "[MUTED]" ? "󰍭" : "󰍬"} ${sourcevol}")) + (eventbox + :class "sinkvol${sinkmute == "[MUTED]" ? " muted" : ""}" + :onclick "wpctl set-mute @DEFAULT_SINK@ toggle" + (label :text "${sinkmute == "[MUTED]" ? "󰟎" : "󰋋"} ${sinkvol}"))))