From 65002822934d2e3974ff0db70d2724fbc2c9a652 Mon Sep 17 00:00:00 2001 From: Niklas Kapelle Date: Mon, 27 Nov 2023 00:34:43 +0100 Subject: [PATCH] added eww config --- .config/eww/eww.scss | 33 +++++++++++ .config/eww/eww.yuck | 20 +++++++ .config/eww/modules/bar/bar.scss | 6 ++ .config/eww/modules/bar/bar.yuck | 33 +++++++++++ .config/eww/modules/clock/clock.scss | 3 + .config/eww/modules/clock/clock.yuck | 14 +++++ .../modules/notifications/notifications.scss | 3 + .../modules/notifications/notifications.yuck | 18 ++++++ .../eww/modules/playerctl/playerctl-volume.sh | 7 +++ .config/eww/modules/playerctl/playerctl.scss | 3 + .config/eww/modules/playerctl/playerctl.yuck | 20 +++++++ .config/eww/modules/volume/scroll-volume.sh | 8 +++ .config/eww/modules/volume/set-volume.sh | 3 + .config/eww/modules/volume/volume.scss | 23 ++++++++ .config/eww/modules/volume/volume.sh | 8 +++ .config/eww/modules/volume/volume.yuck | 57 +++++++++++++++++++ .../modules/workspace/get-active-workspace.sh | 10 ++++ .../workspace/scroll-current-workspace.sh | 17 ++++++ .config/eww/modules/workspace/workspace.scss | 17 ++++++ .config/eww/modules/workspace/workspace.yuck | 33 +++++++++++ .config/eww/modules/workspace/workspaces.sh | 9 +++ 21 files changed, 345 insertions(+) create mode 100644 .config/eww/eww.scss create mode 100644 .config/eww/eww.yuck create mode 100644 .config/eww/modules/bar/bar.scss create mode 100644 .config/eww/modules/bar/bar.yuck create mode 100644 .config/eww/modules/clock/clock.scss create mode 100644 .config/eww/modules/clock/clock.yuck create mode 100644 .config/eww/modules/notifications/notifications.scss create mode 100644 .config/eww/modules/notifications/notifications.yuck create mode 100755 .config/eww/modules/playerctl/playerctl-volume.sh create mode 100644 .config/eww/modules/playerctl/playerctl.scss create mode 100644 .config/eww/modules/playerctl/playerctl.yuck create mode 100755 .config/eww/modules/volume/scroll-volume.sh create mode 100755 .config/eww/modules/volume/set-volume.sh create mode 100644 .config/eww/modules/volume/volume.scss create mode 100755 .config/eww/modules/volume/volume.sh create mode 100644 .config/eww/modules/volume/volume.yuck create mode 100755 .config/eww/modules/workspace/get-active-workspace.sh create mode 100755 .config/eww/modules/workspace/scroll-current-workspace.sh create mode 100644 .config/eww/modules/workspace/workspace.scss create mode 100644 .config/eww/modules/workspace/workspace.yuck create mode 100755 .config/eww/modules/workspace/workspaces.sh diff --git a/.config/eww/eww.scss b/.config/eww/eww.scss new file mode 100644 index 0000000..34e1b9e --- /dev/null +++ b/.config/eww/eww.scss @@ -0,0 +1,33 @@ +@import "/home/niklas/.cache/wal/colors.scss"; + +$bg: $background; +$fg: $foreground; +$border: $color2; +$text: $color6; +$focus: $color3; + +$hight: 1.5rem; + +* { + all: unset; +} + +@mixin pill{ + border: 1px solid $border; + border-radius: 24;; + padding: 0.1rem 0.5rem; + margin: 0 0.5rem; + background-color: $focus; + min-height: $hight; +} + +.pill{ + @include pill; +} + +@import "modules/bar/bar.scss"; +@import "modules/clock/clock.scss"; +@import "modules/playerctl/playerctl.scss"; +@import "modules/volume/volume.scss"; +@import "modules/workspace/workspace.scss"; +@import "modules/notifications/notifications.scss" diff --git a/.config/eww/eww.yuck b/.config/eww/eww.yuck new file mode 100644 index 0000000..635d8de --- /dev/null +++ b/.config/eww/eww.yuck @@ -0,0 +1,20 @@ +(defwindow bar + :monitor 0 + :geometry (geometry :x "0%" + :y "0%" + :width "100%" + :height "10px" + :anchor "top center") + :stacking "fg" + :exclusive true + :namepspace "eww" + + (bar) +) + +(include "modules/bar/bar.yuck") +(include "modules/clock/clock.yuck") +(include "modules/playerctl/playerctl.yuck") +(include "modules/volume/volume.yuck") +(include "modules/workspace/workspace.yuck") +(include "modules/notifications/notifications.yuck") diff --git a/.config/eww/modules/bar/bar.scss b/.config/eww/modules/bar/bar.scss new file mode 100644 index 0000000..9128577 --- /dev/null +++ b/.config/eww/modules/bar/bar.scss @@ -0,0 +1,6 @@ +.bar-widget { + background-color: $bg; + font-size: 16px; + color: $text; + padding: 0.2rem 0; +} diff --git a/.config/eww/modules/bar/bar.yuck b/.config/eww/modules/bar/bar.yuck new file mode 100644 index 0000000..0cc28fc --- /dev/null +++ b/.config/eww/modules/bar/bar.yuck @@ -0,0 +1,33 @@ +(defwidget bar [] + (box + :class "bar-widget" + :orientation "h" + :space-evenly true + + (box + :orientation "h" + :space-evenly false + :halign "start" + + (workspaces) + ) + + (box + :orientation "h" + :space-evenly false + :halign "center" + + (playerctl) + ) + + (box + :orientation "h" + :space-evenly false + :halign "end" + + (volume_slider) + (clock) + (notifications) + ) + ) +) diff --git a/.config/eww/modules/clock/clock.scss b/.config/eww/modules/clock/clock.scss new file mode 100644 index 0000000..3f0daea --- /dev/null +++ b/.config/eww/modules/clock/clock.scss @@ -0,0 +1,3 @@ +.clock { + @include pill; +} diff --git a/.config/eww/modules/clock/clock.yuck b/.config/eww/modules/clock/clock.yuck new file mode 100644 index 0000000..d841658 --- /dev/null +++ b/.config/eww/modules/clock/clock.yuck @@ -0,0 +1,14 @@ +(defpoll time + :interval "1s" + :initial "0" + + "date +%H:%M" +) + +(defwidget clock [] + + (label + :class "clock" + :text {time} + ) +) diff --git a/.config/eww/modules/notifications/notifications.scss b/.config/eww/modules/notifications/notifications.scss new file mode 100644 index 0000000..bd4e585 --- /dev/null +++ b/.config/eww/modules/notifications/notifications.scss @@ -0,0 +1,3 @@ +.notifications { + @include pill; +} diff --git a/.config/eww/modules/notifications/notifications.yuck b/.config/eww/modules/notifications/notifications.yuck new file mode 100644 index 0000000..45e89d6 --- /dev/null +++ b/.config/eww/modules/notifications/notifications.yuck @@ -0,0 +1,18 @@ +(deflisten swaync + :initial "{}" + + "swaync-client -swb" +) + +(defwidget notifications [] + + (button + :class "notifications" + :onclick "swaync-client -t -sw" + :onrightclick "swaync-client -d -sw" + + (label + :text "${swaync.text}" + ) + ) +) \ No newline at end of file diff --git a/.config/eww/modules/playerctl/playerctl-volume.sh b/.config/eww/modules/playerctl/playerctl-volume.sh new file mode 100755 index 0000000..621ecab --- /dev/null +++ b/.config/eww/modules/playerctl/playerctl-volume.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +if [[ $1 == "down" ]]; then + playerctl --player=spotify,%any volume 0.05- +elif [[ $1 == "up" ]]; then + playerctl --player=spotify,%any volume 0.05+ +fi diff --git a/.config/eww/modules/playerctl/playerctl.scss b/.config/eww/modules/playerctl/playerctl.scss new file mode 100644 index 0000000..19bbfd1 --- /dev/null +++ b/.config/eww/modules/playerctl/playerctl.scss @@ -0,0 +1,3 @@ +.playerctl { + @include pill; +} diff --git a/.config/eww/modules/playerctl/playerctl.yuck b/.config/eww/modules/playerctl/playerctl.yuck new file mode 100644 index 0000000..c31517a --- /dev/null +++ b/.config/eww/modules/playerctl/playerctl.yuck @@ -0,0 +1,20 @@ +(deflisten playerctl + :initial "" + + "playerctl --player=spotify,%any -f '{{title}} - {{artist}}' metadata -F" +) + +(defwidget playerctl [] + + (eventbox + :onscroll "modules/playerctl/playerctl-volume.sh {}" + :onmiddleclick "hyprctl dispatch togglespecialworkspace spotify" + :onclick "playerctl --player=spotify,%any play-pause" + :onrightclick "playerctl --player=spotify,%any next" + + (label + :class "playerctl" + :text {playerctl} + ) + ) +) \ No newline at end of file diff --git a/.config/eww/modules/volume/scroll-volume.sh b/.config/eww/modules/volume/scroll-volume.sh new file mode 100755 index 0000000..07404c0 --- /dev/null +++ b/.config/eww/modules/volume/scroll-volume.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [[ $1 == "up" ]]; then + wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+ +elif [[ $1 == "down" ]]; then + wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- +fi + diff --git a/.config/eww/modules/volume/set-volume.sh b/.config/eww/modules/volume/set-volume.sh new file mode 100755 index 0000000..577bfa6 --- /dev/null +++ b/.config/eww/modules/volume/set-volume.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +wpctl set-volume @DEFAULT_AUDIO_SINK@ $1% diff --git a/.config/eww/modules/volume/volume.scss b/.config/eww/modules/volume/volume.scss new file mode 100644 index 0000000..68d2e45 --- /dev/null +++ b/.config/eww/modules/volume/volume.scss @@ -0,0 +1,23 @@ +.volume { + @include pill; +} + +.volume_slider { + min-width: 6rem; + + trough, + highlight { + min-height: 0.5rem; + border-radius: 25px; + border: 1px solid $border; + } + + + trough { + background-color: $bg; + } + + highlight { + background-color: $focus; + } +} diff --git a/.config/eww/modules/volume/volume.sh b/.config/eww/modules/volume/volume.sh new file mode 100755 index 0000000..61c5e17 --- /dev/null +++ b/.config/eww/modules/volume/volume.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print int($2 * 100)}' + +pactl subscribe | rg --line-buffered "on sink" | while read -r _; do + wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print int($2 * 100)}' +done + diff --git a/.config/eww/modules/volume/volume.yuck b/.config/eww/modules/volume/volume.yuck new file mode 100644 index 0000000..e8099bc --- /dev/null +++ b/.config/eww/modules/volume/volume.yuck @@ -0,0 +1,57 @@ +(deflisten volume + :initial 100 + + "modules/volume/volume.sh" +) + +(defwidget volume [] + + (eventbox + :onscroll "modules/volume/scroll-volume.sh {}" + + (label + :class "volume" + :text "${volume}%" + ) + ) +) + +(defvar vol_reveal false) + +(defwidget volume_slider [] + (eventbox + :onhover "eww update vol_reveal=true" + :onhoverlost "eww update vol_reveal=false" + :onscroll "modules/volume/scroll-volume.sh {}" + + (box + :space-evenly false + :orientation "h" + :spacing "3" + + (button + :class "pill" + + (label + :text "${volume}%" + + ) + ) + (revealer + :transition "slideleft" + :reveal vol_reveal + + (scale + :class "volume_slider" + :value volume + :orientation "h" + :min 0 + :max 101 + :onchange "modules/volume/set-volume.sh {}" + + ) + ) + ) + + ) +) diff --git a/.config/eww/modules/workspace/get-active-workspace.sh b/.config/eww/modules/workspace/get-active-workspace.sh new file mode 100755 index 0000000..e326206 --- /dev/null +++ b/.config/eww/modules/workspace/get-active-workspace.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +hyprctl monitors -j | jq '.[] | select(.focused) | .activeWorkspace.id' + + +socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | sed -u -n -e '/^workspace>>/ s/^workspace>>//p' -e '/^focusedmon>>/ s/^focusedmon>>//p' + +#socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | +# stdbuf -o0 awk -F '>>|,' -e '/^workspace>>/ {print $2}' -e '/^focusedmon>>/ {print $3}' + diff --git a/.config/eww/modules/workspace/scroll-current-workspace.sh b/.config/eww/modules/workspace/scroll-current-workspace.sh new file mode 100755 index 0000000..3b54cb6 --- /dev/null +++ b/.config/eww/modules/workspace/scroll-current-workspace.sh @@ -0,0 +1,17 @@ +#!/bin/bash +direction=$1 +current=$2 + +exit 0 # For the time being this script only exist to keep current_workspace from being lazy + +if [[ $direction == "down" ]]; then + target=$(($current+1)) + if [[ $target == 11 ]]; then + exit 0 + fi + hyprctl dispatch workspace $target +elif [[ $direction == "up" ]]; then + target=$(($current-1)) + hyprctl dispatch workspace $target +fi + diff --git a/.config/eww/modules/workspace/workspace.scss b/.config/eww/modules/workspace/workspace.scss new file mode 100644 index 0000000..4da13c7 --- /dev/null +++ b/.config/eww/modules/workspace/workspace.scss @@ -0,0 +1,17 @@ +.workspaces { + margin-left: 0.2rem; + + min-height: $hight; + + border: 1px solid $border; + border-radius: 24px; + + .workspace { + padding: 0 0.5rem; + border-radius: 24px; + } + + .active { + background-color: $focus; + } +} \ No newline at end of file diff --git a/.config/eww/modules/workspace/workspace.yuck b/.config/eww/modules/workspace/workspace.yuck new file mode 100644 index 0000000..88bf662 --- /dev/null +++ b/.config/eww/modules/workspace/workspace.yuck @@ -0,0 +1,33 @@ +(deflisten workspaces + :initial "[]" + + "modules/workspace/workspaces.sh" +) + +(deflisten current_workspace + :initial "1" + + "modules/workspace/get-active-workspace.sh" +) + +(defwidget workspaces [] + (eventbox + :onscroll "modules/workspace/scroll-current-workspace.sh {} ${current_workspace}" + + (box + :orientation "h" + :space-evenly false + :class "workspaces" + :hexpand true + + (for workspace in workspaces + (button + :class "workspace ${current_workspace == workspace.id ? "active" : ""}" + :onclick "hyprctl dispatch workspace ${workspace.id}" + + "${workspace.id}" + ) + ) + ) + ) +) diff --git a/.config/eww/modules/workspace/workspaces.sh b/.config/eww/modules/workspace/workspaces.sh new file mode 100755 index 0000000..ac5d055 --- /dev/null +++ b/.config/eww/modules/workspace/workspaces.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +CMD="sort_by(.id) | [ .[] | select(.id > 0)]" + +hyprctl workspaces -j | jq -c "$CMD" + +socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do + hyprctl workspaces -j | jq -c "$CMD" +done