From 1fccc404efafff312e2e4a47f1e5c6be6270d0b5 Mon Sep 17 00:00:00 2001 From: James Andariese Date: Sat, 30 Mar 2024 09:30:52 -0500 Subject: [PATCH] initial import --- LICENSE | 9 ++++ README.md | 5 +++ eww.scss | 76 +++++++++++++++++++++++++++++++ eww.yuck | 97 ++++++++++++++++++++++++++++++++++++++++ scripts/scroll_volume | 9 ++++ scripts/track_mute | 7 +++ scripts/track_volume | 7 +++ scripts/track_workspace | 7 +++ scripts/track_workspaces | 63 ++++++++++++++++++++++++++ 9 files changed, 280 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 eww.scss create mode 100644 eww.yuck create mode 100755 scripts/scroll_volume create mode 100755 scripts/track_mute create mode 100755 scripts/track_volume create mode 100755 scripts/track_workspace create mode 100755 scripts/track_workspaces diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6ec0357 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2024 cascade + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..30d9bc3 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# `eww.yuck` and friends + +My personal eww config. + +Install by linking or cloning to ~/.config/eww diff --git a/eww.scss b/eww.scss new file mode 100644 index 0000000..dff867e --- /dev/null +++ b/eww.scss @@ -0,0 +1,76 @@ +// Mostly defaults -- scroll to CUSTOMIZATIONS + +* { + all: unset; //Unsets everything so you can style everything from scratch +} + +//Global Styles +.bar { + background-color: #3a3a3a; + color: #b0b4bc; + padding: 0px; + font-family: ComicShannsMono Nerd Font Mono +} + +// Styles on classes (see eww.yuck for more information) + +.sidestuff slider { + all: unset; + color: #ffd5cd; +} + +.metric scale trough highlight { + all: unset; + background-color: #D35D6E; + color: #000000; + border-radius: 10px; +} +.metric scale trough { + all: unset; + background-color: #4e4e4e; + border-radius: 50px; + min-height: 3px; + min-width: 50px; + margin-left: 10px; + margin-right: 20px; +} +.metric scale trough highlight { + all: unset; + background-color: #D35D6E; + color: #000000; + border-radius: 10px; +} +.metric scale trough { + all: unset; + background-color: #4e4e4e; + border-radius: 50px; + min-height: 3px; + min-width: 50px; + margin-left: 10px; + margin-right: 20px; +} +.label-ram { + font-size: large; +} + +// CUSTOMIZATIONS + +.workspaces button { + min-width: 25px; +} + +.workspaces button:hover { + color: #FFDDCE; +} + +button.active { + color: #000000; + //justify: center; + // text-align: center; + background-color: #AA75A9 +} + +button.urgent { + color: #000000; + background-color: #FF5577 +} diff --git a/eww.yuck b/eww.yuck new file mode 100644 index 0000000..7bb506d --- /dev/null +++ b/eww.yuck @@ -0,0 +1,97 @@ +(defwidget bar [] + (centerbox :orientation "h" + (leftstuff) + (music) + (rightstuff))) + +(defwidget rightstuff [] + (box :class "rightstuff" :orientation "h" :space-evenly false :halign "end" + (eventbox :onclick "pamixer -t" + :onscroll "scripts/scroll_volume {}" + (metric :label {muted ? "🔇" : volume > 90 ? "🔊" : volume > 0 ? "🔉" : "🔈"} + :value volume + :onchange "pamixer --set-volume {}")) + (metric :label "" + :value {EWW_RAM.used_mem_perc} + :onchange "") + (metric :label "💾" + :value {round((1 - (EWW_DISK["/"].free / EWW_DISK["/"].total)) * 100, 0)} + :onchange "") + time + ;systray + )) + +(defwidget leftstuff [] + (box :class "leftstuff" :orientation "h" :space-evenly false :halign "start" + (workspaces) + (scratches))) + +(defwidget workspaces [] + (eventbox + :onscroll "swaymsg workspace $(echo {} | sed -e 's/up/prev/' -e 's/down/next/')" + (box :class "workspaces" + :orientation "h" + :halign "start" + :spacing 0 + (for w in { workspaces.workspaces } + (button :width 20 + :onclick "swaymsg workspace ${w?.name ?: '??'}" + :class {w?.class} {w?.name ?: '??'} ))))) + +(defwidget scratches [] + (eventbox :class "scratches" + :onscroll "swaymsg scratchpad show" + (overlay + (button :width 40 + :onclick "swaymsg scratchpad show" "" ) + (label :text {workspaces.exposed_scratch_count > 0 ? "📂" : "📁"} + :class "folder ${workspaces.exposed_scratch_count > 0 ? "open" : "closed"}" + :yalign 1) + (label :text `${jq(workspaces, '[.exposed_scratch_count, .scratches[].window_count]|add')}` + :yalign 0.1 )))) + +(defwidget music [] + (box :class "music" + :orientation "h" + :space-evenly false + :halign "center" + {music != "" ? "🎵${music}" : ""})) + + +(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))) + +(deflisten music :initial "" + "playerctl --follow metadata --format '{{ artist }} - {{ title }}' || true") + +(deflisten volume + "scripts/track_volume") + +(deflisten muted + "scripts/track_mute") + +(deflisten workspace :initial "1" `scripts/track_workspace`) +(deflisten workspaces :initial `{"workspaces":[],"scratches":[]}` `scripts/track_workspaces`) + +(defpoll time :interval "1s" + "date '+%H:%M:%S %b %d, %Y'") + +(defwindow bar + :monitor 0 + :windowtype "dock" + :geometry (geometry :x "0%" + :y "0%" + :width "100%" + :height "30px" + :anchor "top center") + :exclusive true + :reserve (struts :side "top" :distance "30px") + (bar)) diff --git a/scripts/scroll_volume b/scripts/scroll_volume new file mode 100755 index 0000000..85e2c30 --- /dev/null +++ b/scripts/scroll_volume @@ -0,0 +1,9 @@ +#!/bin/sh + +if [ "$1" = up ];then + pamixer -i 5 +elif [ "$1" = down ];then + pamixer -d 5 +else + pamixer --set-volume $1 +fi diff --git a/scripts/track_mute b/scripts/track_mute new file mode 100755 index 0000000..938d735 --- /dev/null +++ b/scripts/track_mute @@ -0,0 +1,7 @@ +#!/bin/sh + +pactl subscribe | while read -r ;do + case "$REPLY" in + *change*) pamixer --get-mute ;; + esac +done diff --git a/scripts/track_volume b/scripts/track_volume new file mode 100755 index 0000000..0155bf9 --- /dev/null +++ b/scripts/track_volume @@ -0,0 +1,7 @@ +#!/bin/sh + +pactl subscribe | while read -r ;do + case "$REPLY" in + *change*) pamixer --get-volume | grep -E '^[0-9]+$';; + esac +done diff --git a/scripts/track_workspace b/scripts/track_workspace new file mode 100755 index 0000000..d99f36a --- /dev/null +++ b/scripts/track_workspace @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +swaymsg -t subscribe -m '[ "workspace" ]' | jq --unbuffered '.current.num' | while read -r;do + if [ "$REPLY" != "null" ];then + echo "$REPLY" + fi +done diff --git a/scripts/track_workspaces b/scripts/track_workspaces new file mode 100755 index 0000000..fc984f2 --- /dev/null +++ b/scripts/track_workspaces @@ -0,0 +1,63 @@ +#!/usr/bin/env bash + +poll() { + swaymsg -t get_tree | + jq -c --unbuffered '. + # prep the output var + | {} as $out + + # find the count of scratch windows that are exposed + | [.. | select(.type=="workspace" and .num == null)? | .focus[]] as $scratch_windows + | [.. | select(.type=="workspace" and .num)? | .focus[]] as $exposed_windows + | ($exposed_windows - ($exposed_windows - $scratch_windows)) as $exposed_scratch + | ($out | .exposed_scratch = $exposed_scratch) as $out + | ($out | .exposed_scratch_count = ($exposed_scratch | length)) as $out + + # get and save the current workspace name + | (.. | select(.current_workspace)? | .current_workspace) as $cws + + # now, loop over all workspaces by using the recursive descent operator (..) + # and select all the workspaces (.type == "workspace") + | [ (.. | select(.type=="workspace")?) + + # if its a con or a floating_con, include it in the window count + | (.window_count = ([.. | select(.type == "con" or .type == "floating_con")?] | length)) + + # and delete all the extraneous info + | del(.rect,.deco_rect,.window_rect,.geometry,.nodes,.floating_nodes) + + # add a default class + | (.class = ["workspace-switcher"]) + + # and add active class to the current workspace + | (if (.name == $cws) then .class += ["active"] | .current = true else .current = false end) + + # add urgent if its urgent + | (if (.urgent) then .class += ["urgent"] end) + + # now join the classes + | .class |= join(" ") + + # and save to $all for further processing into $out + ] as $all + + # add .workspaces to $out for anything that has a workspace number + | ($out | .workspaces = [$all | .[] | select(.num)?]) as $out + + # add .scratches to $out for any workspace that does _not_ have a number + # (these are distinguished by being scratch but also cant be reached by next/prev) + | ($out | .scratches = [$all | .[] | select(.num == null)]) as $out + + # now that weve built up $out, we will return it. + | $out + ' +} +poll +[ ${1-x} == '-d' ] && exit 0 + +swaymsg -t subscribe -m '[ "workspace", "window" ]' | + jq --unbuffered -c '.' | + while read -r EVENT;do + poll + done +