From f83ad913be9b3e955879249095d9fe809442eb50 Mon Sep 17 00:00:00 2001 From: elkowar <5300871+elkowar@users.noreply.github.com> Date: Wed, 18 Aug 2021 16:21:04 +0200 Subject: [PATCH] Clean up example bar --- README.md | 2 +- YUCK_MIGRATION.md | 2 +- crates/simplexpr/src/eval.rs | 2 +- examples/eww-bar/eww.scss | 8 +++---- examples/eww-bar/eww.yuck | 44 ++++++++++++++++++++++++------------ 5 files changed, 36 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index d3d700b..899a2e9 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ YUCK IS ALIVE! After months of waiting, the new configuration language has now b This also means that XML is no longer supported from this point onwards. If you want to keep using the latest releases of eww, you'll need to migrate your config over to yuck. -The steps to migrate can be found in [the migration guide](YUCK_MIGRATION.md) +The steps to migrate can be found in [the migration guide](YUCK_MIGRATION.md). Additionally, a couple _amazing_ people have started to work on an [automatic converter](https://github.com/undefinedDarkness/ewwxml) that can turn your old eww.xml into the new yuck format! diff --git a/YUCK_MIGRATION.md b/YUCK_MIGRATION.md index d46d90c..8ba66f0 100644 --- a/YUCK_MIGRATION.md +++ b/YUCK_MIGRATION.md @@ -19,7 +19,7 @@ The fields and structure of the `defwindow` block as been adjusted to better ref the options provided by the displayserver that is being used. The major changes are: - The `screen` field is now called `monitor` -- `reserve` and `geometry` are now structured slightly differently +- `reserve` and `geometry` are now structured slightly differently (see [here](./docs/src/configuration.md#creating-your-first-window)) To see how exactly the configuration now looks, check the [respective documentation](./docs/src/configuration.md#creating-your-first-window) diff --git a/crates/simplexpr/src/eval.rs b/crates/simplexpr/src/eval.rs index 13ba3f4..1b278d2 100644 --- a/crates/simplexpr/src/eval.rs +++ b/crates/simplexpr/src/eval.rs @@ -141,7 +141,7 @@ impl SimplExpr { SimplExpr::Concat(span, elems) => { let mut output = String::new(); for elem in elems { - let result = dbg!(elem.eval(values))?; + let result = elem.eval(values)?; output.push_str(&result.0); } Ok(DynVal(output, *span)) diff --git a/examples/eww-bar/eww.scss b/examples/eww-bar/eww.scss index 845e38f..efa2a50 100644 --- a/examples/eww-bar/eww.scss +++ b/examples/eww-bar/eww.scss @@ -16,13 +16,13 @@ color: #ffd5cd; } -.slider-vol scale trough highlight { +.metric scale trough highlight { all: unset; background-color: #D35D6E; color: #000000; border-radius: 10px; } -.slider-vol scale trough { +.metric scale trough { all: unset; background-color: #4e4e4e; border-radius: 50px; @@ -31,13 +31,13 @@ margin-left: 10px; margin-right: 20px; } -.slider-ram scale trough highlight { +.metric scale trough highlight { all: unset; background-color: #D35D6E; color: #000000; border-radius: 10px; } -.slider-ram scale trough { +.metric scale trough { all: unset; background-color: #4e4e4e; border-radius: 50px; diff --git a/examples/eww-bar/eww.yuck b/examples/eww-bar/eww.yuck index 844d12e..346661c 100644 --- a/examples/eww-bar/eww.yuck +++ b/examples/eww-bar/eww.yuck @@ -6,8 +6,15 @@ (defwidget sidestuff [] (box :class "sidestuff" :orientation "h" :space-evenly false :halign "end" - (slider-vol) - (slider-ram) + (metric :label "🔊" + :value volume + :onchange "amixer -D pulse sset Master {}%") + (metric :label "" + :value EWW_RAM + :onchange "") + (metric :label "💾" + :value {round((1 - (EWW_DISK["/"].free / EWW_DISK["/"].total)) * 100, 0)} + :onchange "") time)) (defwidget workspaces [] @@ -27,27 +34,34 @@ (button :onclick "wmctrl -s 8" 9))) (defwidget music [] - (box :class "music" :orientation "h" :space-evenly false :halign "center" + (box :class "music" + :orientation "h" + :space-evenly false + :halign "center" '🎵${music}')) -(defwidget slider-vol [] - (box :class "slider-vol" :orientation "h" :space-evenly "false" - (box :class "label-vol" "🔊" - (scale :min 0 :max 101 :value volume :onchange "amixer -D pulse sset Master {}%")))) -(defwidget slider-ram [] - (box :orientation "h" :class "slider-ram" :space-evenly false - (box :class "label-ram" "" - (scale :min 0 :max 101 :active false :value EWW_RAM)))) +(defwidget metric [label value onchange] + (box :orientation "h" + :class "metric" + :space-evenly false + (box :class "label" label) + (scale :min 0 + :max 101 + :active {onchange != ""} + :value value + :onchange onchange))) +(defpoll music :interval "5s" + "playerctl metadata --format '{{ artist }} - {{ title }}' || true") +(defpoll volume :interval "1s" + "scripts/getvol") -(defpoll music :interval "5s" "playerctl metadata --format '{{ artist }} - {{ title }}' || true") -(defpoll volume :interval "1s" "scripts/getvol") - -(defpoll time :interval "10s" "date '+%H:%M %b %d, %Y'") +(defpoll time :interval "10s" + "date '+%H:%M %b %d, %Y'") (defwindow bar :monitor 0