Add some example eww widgets for testing

This commit is contained in:
Evie Litherland-Smith 2023-07-11 09:31:51 +01:00
parent 960bba92ff
commit b0ea979ed5
19 changed files with 67 additions and 356 deletions

View file

@ -1,56 +0,0 @@
* {
all: unset; //Unsets everything so you can style everything from scratch
}
//Global Styles
.bar {
background-color: #3a3a3a;
color: #b0b4bc;
padding: 10px;
}
// 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;
}
.workspaces button:hover {
color: #D35D6E;
}
// vim:ft=scss

View file

@ -1,77 +0,0 @@
(defwidget bar []
(centerbox :orientation "h"
(workspaces)
(music)
(sidestuff)))
(defwidget sidestuff []
(box :class "sidestuff" :orientation "h" :space-evenly false :halign "end"
(metric :label "󰕾 "
:value volume
:onchange "amixer -D pulse sset Master {}%")
(metric :label "󰍛 "
:value {EWW_RAM.used_mem_perc}
:onchange "")
(metric :label " "
:value {round((1 - (EWW_DISK["/"].free / EWW_DISK["/"].total)) * 100, 0)}
:onchange "")
time))
(deflisten workspaces :initial "[]" "bash ~/.config/eww/scripts/get-workspaces")
(deflisten current_workspace :initial "1" "bash ~/.config/eww/scripts/get-active-workspace")
(defwidget workspaces []
(eventbox :onscroll "bash ~/.config/eww/scripts/change-active-workspace {} ${current_workspace}" :class "workspaces-widget"
(box :space-evenly true
(label :text "${workspaces}${current_workspace}" :visible false)
(for workspace in workspaces
(eventbox :onclick "hyprctl dispatch workspace ${workspace.id}"
(box :class "workspace-entry ${workspace.id == current_workspace ? "current" : ""} ${workspace.windows > 0 ? "occupied" : "empty"}"
(label :text "${workspace.id}")
)
)
)
)
)
)
(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")
(defpoll volume :interval "1s"
"scripts/getvol")
(defpoll time :interval "10s"
"date '+%H:%M %b %d, %Y'")
(defwindow bar
:monitor 0
:windowtype "dock"
:geometry (geometry :x "0%"
:y "0%"
:width "90%"
:anchor "top center")
:reserve (struts :side "top" :distance "4%")
(bar))
;; vim:ft=yuck

View file

@ -1,21 +0,0 @@
#!/usr/bin/env bash
function clamp {
min=$1
max=$2
val=$3
python -c "print(max($min, min($val, $max)))"
}
direction=$1
current=$2
if test "$direction" = "down"
then
target=$(clamp 1 10 $(($current+1)))
echo "jumping to $target"
hyprctl dispatch workspace $target
elif test "$direction" = "up"
then
target=$(clamp 1 10 $(($current-1)))
echo "jumping to $target"
hyprctl dispatch workspace $target
fi

View file

@ -1,3 +0,0 @@
#!/usr/bin/env bash
hyprctl monitors -j | jq --raw-output .[0].activeWorkspace.id
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | stdbuf -o0 grep '^workspace>>' | stdbuf -o0 awk -F '>>|,' '{print $2}'

View file

@ -1,11 +0,0 @@
#!/usr/bin/env bash
spaces (){
WORKSPACE_WINDOWS=$(hyprctl workspaces -j | jq 'map({key: .id | tostring, value: .windows}) | from_entries')
seq 1 10 | jq --argjson windows "${WORKSPACE_WINDOWS}" --slurp -Mc 'map(tostring) | map({id: ., windows: ($windows[.]//0)})'
}
spaces
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do
spaces
done

View file

@ -1,2 +0,0 @@
#!/bin/sh
printf "%.0f\n" $(free -m | grep Mem | awk '{print ($3/$2)*100}')

View file

@ -1,2 +0,0 @@
#!/bin/sh
amixer -D pulse sget Master | grep 'Left:' | awk -F'[][]' '{ print $2 }' | tr -d '%' | head -1

View file

@ -1,3 +1 @@
@import "./powermenu/eww.scss"
// vim:ft=scss // vim:ft=scss

View file

@ -1,3 +1,24 @@
(include "./powermenu/eww.yuck") (deflisten workspaces :initial "[]" "bash ~/.config/eww/scripts/get-workspaces")
(deflisten current_workspace :initial "1" "bash ~/.config/eww/scripts/get-active-workspace")
(defwidget workspaces []
(eventbox :onscroll "bash ~/.config/eww/scripts/change-active-workspace {} ${current_workspace}" :class "workspaces-widget"
(box :space-evenly true
(label :text "${workspaces}${current_workspace}" :visible false)
(for workspace in workspaces
(eventbox :onclick "hyprctl dispatch workspace ${workspace.id}"
(box :class "workspace-entry ${workspace.id == current_workspace ? "current" : ""} ${workspace.windows > 0 ? "occupied" : "empty"}"
(label :text "${workspace.id}")
)
)
)
)
)
)
(deflisten window :initial "..." "sh ~/.config/eww/scripts/get-window-title")
(defwidget window_w []
(box
(label :text "${window}"
)
)
)
;; vim:ft=yuck ;; vim:ft=yuck

View file

@ -1,69 +0,0 @@
$surface-darkgrey: #20252b;
$surface-fg: #949494;
$surface-lightgrey: #3d464e;
$surface-grey: #2b3238;
$surface-red: #f87070;
* { all: unset; }
.layout-box {
font-family: Phosphor, Koulen;
background-repeat: no-repeat;
background-size: contain;
padding: 5em;
color: rgba($surface-fg, 0.8);
}
.net-box,
.bat-box,
.tm-box {
label {
font-size: 2em;
}
}
.close-btn {
font-size: 2em;
&:hover {
color: $surface-red;
}
}
.btns-box {
font-size: 2.5em;
button {
padding: 0.4em;
border-radius: 0.1em;
background-color: rgba($surface-darkgrey, 0.3);
&:hover {
transition: 200ms linear background-color, border-radius;
background-color: rgba($surface-lightgrey, 0.6);
}
&:first-child {
color: rgba($surface-red, 0.8);
}
}
}
.sep {
font-size: 1em;
padding-top: 0.15em;
padding-left: 0.2em;
padding-right: 0.2em;
font-family: Iosevka;
font-weight: 400;
}
.sundial-lbl {
font-size: 1.5em;
font-weight: bold;
border-radius: 0.2em;
padding: 0.4em;
padding-bottom: 0.5em;
font-family: "Poiret One";
}
// vim:ft=scss

View file

@ -1,109 +0,0 @@
(defwindow powermenu
:monitor 0
:stacking "fg"
:windowtype "normal"
:wm-ignore true
:geometry (geometry :width "100%" :height "100%")
(powermenu_layout))
(defpoll time :interval "5s"
:initial `date +'{"hour":"%H","min":"%M"}'`
`date +'{"hour":"%H","min":"%M"}'`)
(defpoll net :interval "100s"
:initial `N/A`
`nmcli -t -f SIGNAL,ACTIVE device wifi \
| awk -F':' '{if($2=="yes")print$1}'`)
(defpoll eth :interval "100s"
:initial `N/A`
`nmcli -t -f TYPE,STATE device status \
| awk -F':' '{if($2=="connected")print$1}'`)
(defwidget powermenu_layout []
(box :class "layout-box" :space-evenly false :orientation "vertical"
:style "background-image: url('./powermenu/wallpaper')"
(box :valign "start" :space-evenly false :spacing 25
(_sundial)
(_battery :status {EWW_BATTERY.BAT0.status}
:battery {EWW_BATTERY.BAT0.capacity})
(_network :strength net :offline "󰤭 " :excellent "󰤨 " :good "󰤥 "
:okay "󰤢 " :slow "󰤟 ")
(_network_ethernet :name eth)
(label :text "|" :class "sep")
(button :onclick "eww close powermenu" :class "close-btn" ""))
(box :space-evenly false :hexpand true :vexpand true
(box :spacing 15 :class "tm-box" :space-evenly false
:valign "end" :halign "start"
(label :text "󰥔 ")
(label :text "${time.hour} ${time.min}"))
(_buttons :shutdown "poweroff" :reboot "reboot"
:logout "loginctl kill-session self"
:shutdown_icon "󰐥 " :reboot_icon "󰤁 "
:logout_icon "󰍃 "))))
(defwidget _battery [battery status]
(box :class "bat-box" :space-evenly false :spacing 8
(label :text {
status == 'Charging' ? "󰂄" :
battery < 10 ? "󰁺" :
battery < 20 ? "󰁻" :
battery < 30 ? "󰁼" :
battery < 40 ? "󰁽" :
battery < 50 ? "󰁾" :
battery < 60 ? "󰁿" :
battery < 70 ? "󰂀" :
battery < 80 ? "󰂁" :
battery < 90 ? "󰂂" :
"󰁹"})))
(defwidget _network [strength offline excellent
good okay slow]
(box :class "net-box"
:space-evenly false
:spacing 8
(label :text {strength == "" ? offline :
strength < 26 ? slow :
strength < 51 ? okay :
strength < 76 ? good : excellent})))
(defwidget _network_ethernet [name]
(box :class "net-box"
:space-evenly false
:spacing 8
(label :text {name == "ethernet" ? "󰈁 " : "󰈂 "})))
(defwidget _buttons [shutdown shutdown_icon reboot
reboot_icon logout logout_icon]
(box :class "btns-box" :spacing 5
:vexpand true :hexpand true
:valign "end" :halign "end"
:space-evenly false
(button :onclick shutdown shutdown_icon)
(button :onclick reboot reboot_icon)
(button :onclick logout logout_icon)))
(defwidget _sundial []
(label :class "sundial-lbl" :halign "end" :hexpand true
:text {time.hour >= 2 && time.hour <= 4 ? "Early Morning" :
time.hour <= 5 ? "Dawn" :
time.hour >= 6
&& (time.hour <= 8 && time.min <= 59)
? "Morning" :
time.hour >= 9
&& (time.hour <= 11 && time.min <= 59)
? "Late Morning" :
time.hour == 12 && time.min <= 29
? "Midday" :
time.hour >= 12 && time.hour <= 16
? "Afternoon" :
time.hour > 16 && time.hour <= 17
? "Late Afternoon" :
(time.hour >= 17 && time.min <= 1)
|| (time.hour <= 18 && time.min <= 20)
? "Early Evening" :
time.hour >= 18 && time.hour <= 19
? "Dusk" :
time.hour > 19 && time.hour <= 21
? "Late Evening" :
time.hour > 21 ? "Night" : "Midnight"}))
;; vim:ft=yuck

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

View file

@ -0,0 +1,21 @@
#! /bin/bash
function clamp {
min=$1
max=$2
val=$3
python -c "print(max($min, min($val, $max)))"
}
direction=$1
current=$2
if test "$direction" = "down"
then
target=$(clamp 1 10 $(($current+1)))
echo "jumping to $target"
hyprctl dispatch workspace "$target"
elif test "$direction" = "up"
then
target=$(clamp 1 10 $(($current-1)))
echo "jumping to $target"
hyprctl dispatch workspace "$target"
fi

View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
hyprctl monitors -j | jq '.[] | select(.focused) | .activeWorkspace.id'
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - |\
stdbuf -o0 awk -F '>>|,' -e '/^workspace>>/ {print $2}' -e '/^focusedmon>>/ {print $3}'

View file

@ -0,0 +1,3 @@
#!/bin/sh
hyprctl activewindow -j | jq --raw-output .title
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | stdbuf -o0 awk -F '>>|,' '/^activewindow>>/{print $3}'

View file

@ -0,0 +1,11 @@
#!/bin/bash
spaces (){
WORKSPACE_WINDOWS=$(hyprctl workspaces -j | jq 'map({key: .id | tostring, value: .windows}) | from_entries')
seq 1 10 | jq --argjson windows "$WORKSPACE_WINDOWS" --slurp -Mc 'map(tostring) | map({id: ., windows: ($windows[.]//0)})'
}
spaces
socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | while read -r line; do
spaces
done

View file

@ -6,6 +6,6 @@
programs.eww = { programs.eww = {
enable = true; enable = true;
package = pkgs.eww-wayland; package = pkgs.eww-wayland;
configDir = ./config/eww; configDir = ./config;
}; };
} }

View file

@ -24,6 +24,7 @@
}; };
in { in {
imports = [ imports = [
../eww
../waybar ../waybar
../rofi ../rofi
../swaylock.nix ../swaylock.nix

View file

@ -1,7 +1,7 @@
{config, ...}: let {config, ...}: let
icon-theme = config.gtk.iconTheme.name; icon-theme = config.gtk.iconTheme.name;
in { in {
imports = [./gtk.nix]; imports = [../gtk.nix];
programs.rofi = { programs.rofi = {
enable = true; enable = true;
location = "center"; location = "center";