From 48850415d830262ad0d9eb96ec3e50a6279c3747 Mon Sep 17 00:00:00 2001 From: elkowar <5300871+elkowar@users.noreply.github.com> Date: Tue, 10 Aug 2021 18:35:08 +0200 Subject: [PATCH] add eww bar --- eww-bar/.config/eww-bar/audio.sh | 10 ++ eww-bar/.config/eww-bar/eww.scss | 79 ++++++++++++++++ eww-bar/.config/eww-bar/eww.yuck | 103 +++++++++++++++++++++ eww-bar/.config/eww-bar/workspaces.sh | 34 +++++++ nvim/.config/nvim/fnl/dots/plugins/lsp.fnl | 1 + 5 files changed, 227 insertions(+) create mode 100644 eww-bar/.config/eww-bar/audio.sh create mode 100644 eww-bar/.config/eww-bar/eww.scss create mode 100644 eww-bar/.config/eww-bar/eww.yuck create mode 100755 eww-bar/.config/eww-bar/workspaces.sh diff --git a/eww-bar/.config/eww-bar/audio.sh b/eww-bar/.config/eww-bar/audio.sh new file mode 100644 index 0000000..2b9fc13 --- /dev/null +++ b/eww-bar/.config/eww-bar/audio.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + + + + +speaker_sink_id=$(pamixer --list-sinks | grep "Komplete_Audio_6" | awk '{print $1}') +game_sink_id=$(pamixer --list-sinks | grep "stereo-game" | awk '{print $1}') + +volume=$(pamixer --get-volume) + diff --git a/eww-bar/.config/eww-bar/eww.scss b/eww-bar/.config/eww-bar/eww.scss new file mode 100644 index 0000000..e8ff173 --- /dev/null +++ b/eww-bar/.config/eww-bar/eww.scss @@ -0,0 +1,79 @@ +* { + all: unset; +} + +window { + background: #282828; + color: #ebdbb2; + + & > * { + margin: 3px; + } +} + +.workspaces { + button { + background: none; + margin: 3px; + &.inactive { + color: #888974; + } + &.active { + color: #8ec07c; + } + &.occupied { + font-size: 1.01rem; + } + &.empty { + font-size: 0.8rem; + } + } +} + +.segment-top { + margin-top: 10px; +} + +.segment-bottom { + margin-bottom: 10px; +} + +.volume-metric { + background-color: #1d2021; + color: #ebdbb2; + padding: 0; + + .volume-top > scale { + margin-bottom: 5px; + } + + slider { + all: unset; + } + + scale trough highlight { + all: unset; + background-color: #8ec07c; + border-bottom-right-radius: 5px; + } + scale trough { + all: unset; + background-color: #1d2021; + min-width: 34px; + min-height: 2px; + } +} + +.large-symbol { + font-size: 0.8em; +} + +.metric { + background-color: #1d2021; + padding: 5px 2px; +} + +.time { + padding-top: 7px; + padding-bottom: 7px; +} diff --git a/eww-bar/.config/eww-bar/eww.yuck b/eww-bar/.config/eww-bar/eww.yuck new file mode 100644 index 0000000..93cc10b --- /dev/null +++ b/eww-bar/.config/eww-bar/eww.yuck @@ -0,0 +1,103 @@ +(defwidget bar [screen] + (box :orientation "v" + (box + (box :valign "start" + :halign "center" + :class "segment-top" + (top :screen screen))) + (box + (box :valign "center" + :class "middle" + (middle))) + (box + (box :valign "end" + :class "segment-bottom" + (bottom))))) + + + +(defwidget top [] + (workspaces :wsp_yuck {screen == 0 ? workspaces_0_yuck : screen == 1 ? workspaces_1_yuck : workspaces_2_yuck})) + +(defwidget workspaces [wsp_yuck] + (literal :content wsp_yuck)) + +(defwidget middle [] (time)) +(defwidget time [] + (box :orientation "v" + :class "metric time" + hour min sec)) + +(defwidget bottom [] + (box :orientation "v" + :valign "end" + :space-evenly true + :spacing "5" + (volume) + (box :class "metric" :orientation "v" + (large-sym :sym "" ) "${round((1 - (EWW_DISK["/"].free / EWW_DISK["/"].total)) * 100, 0)}%") + (box :class "metric" :orientation "v" + "" "${round(EWW_RAM, 0)}%") + (box :class "metric" :orientation "v" + "" "${round(EWW_CPU_USAGE.avg, 0)}%") + (box :class "metric" + (date)))) + +(defwidget volume [] + (box :class "volume-metric" + :orientation "v" + :space-evenly false + :valign "fill" + :vexpand false + (scale :orientation "h" + :min 0 + :max 100 + :onchange "pamixer --set-volume $(echo {} | sed 's/\\..*//g')" + :value volume) + (box :orientation "v" + :valign "fill" + :vexpand true + (large-sym :sym "🎧") + "${volume}%"))) + + +(defwidget large-sym [sym] + (label :class "large-symbol" :text sym)) + +(defwidget date [] + (box :orientation "v" + :halign "center" + day_word day month year)) + +(deflisten volume + ` + pamixer --get-volume; + pactl subscribe | grep --line-buffered "Event 'change' on sink " | while read -r evt; + do pamixer --get-volume; + done`) + +(defpoll hour :interval "1s" "date +%H") +(defpoll min :interval "1s" "date +%M") +(defpoll sec :interval "1s" "date +%S") + +(defpoll day_word :interval "10m" "date +%a") +(defpoll day :interval "10m" "date +%d") +(defpoll month :interval "1h" "date +%m") +(defpoll year :interval "1h" "date +%y") + +(deflisten workspaces_0_yuck "./workspaces.sh 0") +(deflisten workspaces_1_yuck "./workspaces.sh 1") +(deflisten workspaces_2_yuck "./workspaces.sh 2") + +(defwindow bar_1 + :monitor 1 + :geometry (geometry :x 0 :y 0 :width "40px" :height "100%") + :anchor "top left" + :reserve (struts :distance "40px" :side "left") + (bar :screen 1)) +(defwindow bar_2 + :monitor 2 + :geometry (geometry :x 0 :y 0 :width "40px" :height "100%") + :anchor "top left" + :reserve (struts :distance "40px" :side "left") + (bar :screen 2)) diff --git a/eww-bar/.config/eww-bar/workspaces.sh b/eww-bar/.config/eww-bar/workspaces.sh new file mode 100755 index 0000000..71c1478 --- /dev/null +++ b/eww-bar/.config/eww-bar/workspaces.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +monitor="$1" + +gib_workspace_names() { + wmctrl -d \ + | awk '{ print $1 " " $2 " " $9 }' \ + | grep -v NSP \ + | grep "${monitor}_" +} + +gib_workspace_yuck() { + gib_workspace_names | while read -r id active name; do + name="${name#*_}" + if [ "$active" == '*' ]; then + active_class="active" + else + active_class="inactive" + fi + + if wmctrl -l | grep --regexp '.*\s\+'"$id"'\s\+.*' >/dev/null; then + button_class="occupied" + button_name="◆" + else + button_class="empty" + button_name="◇" + fi + echo -n '(button :class "'$button_class' '$active_class'" :onclick "wmctrl -s '$id'" "'$button_name'")' + done +} + +xprop -spy -root _NET_CURRENT_DESKTOP | while read -r; do + echo '(box :orientation "v" :class "workspaces" :space-evenly true :halign "start" :valign "center" :vexpand true '"$(gib_workspace_yuck)"')' +done diff --git a/nvim/.config/nvim/fnl/dots/plugins/lsp.fnl b/nvim/.config/nvim/fnl/dots/plugins/lsp.fnl index 1c4ab32..0480e03 100644 --- a/nvim/.config/nvim/fnl/dots/plugins/lsp.fnl +++ b/nvim/.config/nvim/fnl/dots/plugins/lsp.fnl @@ -61,6 +61,7 @@ (init-lsp :hls {:settings {:languageServerHaskell {:formattingProvider "stylish-haskell"}}}) (init-lsp :ocamllsp) (init-lsp :vimls) +(init-lsp :gopls) (init-lsp :bashls) (init-lsp :erlangls) (init-lsp :yamlls)