[eww] Update

This commit is contained in:
Viyurz 2024-11-05 14:09:13 +01:00
parent cd6043e5c0
commit ce2d898e36
Signed by: Viyurz
SSH key fingerprint: SHA256:IskOHTmhHSJIvAt04N6aaxd5SZCVWW1Guf9tEcxIMj8
9 changed files with 203 additions and 79 deletions

View file

@ -16,53 +16,62 @@
border-radius: 0; border-radius: 0;
} }
.bar > * > *:nth-child(even) { .bar > *:last-child {
color: $accent1; margin-right: 6px;
.disabled {
color: $disabled;
} }
.bar > * > *:nth-child(odd) {
color: $accent1;
scale trough { scale trough {
background-color: $background1; background-color: $disabled;
} }
scale trough highlight { scale trough highlight {
background-color: $accent1; background-color: $accent1;
} }
.disabled {
color: $disabled;
}
} }
.bar > * > *:nth-child(odd) { .bar > * > *:nth-child(even) {
color: $accent2; color: $accent2;
.disabled {
color: $disabled2;
}
scale trough { scale trough {
background-color: $disabled2; background-color: $disabled2;
} }
scale trough highlight { scale trough highlight {
background-color: $accent2; background-color: $accent2;
} }
.disabled {
color: $disabled2;
}
} }
label, .systray { .workspace label {
padding: 6px; padding: 0 7px;
} }
.workspace { .workspace:nth-child(even) {
color: $foreground; color: $accent1;
label {
padding: 0 10px;
} }
.workspace:nth-child(odd) {
color: $accent2;
}
.workspace.empty {
opacity: 0.3;
} }
.workspace:hover { .workspace:hover {
background-color: $hovered; opacity: 0.7;
} }
.workspace.active { .workspace.active {
background-color: $selected; opacity: 1;
} }
scale { scale {
padding: 0 4px; padding-left: 8px;
slider { slider {
all: unset; all: unset;
} }

View file

@ -1,5 +1,5 @@
; Brightness ; Brightness
(defpoll brightness :initial "128" :interval "1m" "cat /sys/class/backlight/amdgpu_bl1/brightness") (defpoll brightness :initial "128" :interval "1h" "cat /sys/class/backlight/amdgpu_bl1/brightness")
(defvar brightness-icons '["", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]') (defvar brightness-icons '["", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]')
(defvar brightness-slide false) (defvar brightness-slide false)
@ -7,20 +7,25 @@
(defvar battery-icons '{"Full": {"10": "󰂄"}, "Charging": ["󰢟", "󰢜", "󰂆", "󰂇", "󰂈", "󰢝", "󰂉", "󰢞", "󰂊", "󰂋", "󰂅"], "Discharging": ["󰂎", "󰁺", "󰁻", "󰁼", "󰁽", "󰁾", "󰁿", "󰂀", "󰂁", "󰂂", "󰁹"]}') (defvar battery-icons '{"Full": {"10": "󰂄"}, "Charging": ["󰢟", "󰢜", "󰂆", "󰂇", "󰂈", "󰢝", "󰂉", "󰢞", "󰂊", "󰂋", "󰂅"], "Discharging": ["󰂎", "󰁺", "󰁻", "󰁼", "󰁽", "󰁾", "󰁿", "󰂀", "󰂁", "󰂂", "󰁹"]}')
; DateTime ; DateTime
(defpoll datetime :interval "1s" "date +'%a %e %b %X'") (defpoll datetime :interval "1s" "date +'%a %-e %b %X'")
(defpoll month :interval "1m" :initial "1" "date +'%m'") (defpoll month :interval "1m" :initial "1" "date +'%m'")
(defpoll day :interval "1m" :initial "1" "date +'%d'") (defpoll day :interval "1m" :initial "1" "date +'%d'")
(defpoll year :interval "1m" :initial "0" "date +'%Y'") (defpoll year :interval "1m" :initial "0" "date +'%Y'")
; Network ; Network
(defpoll network :initial '{"if": "lo"}' :interval "2s" "~/.config/eww/scripts/get-network.sh") (deflisten network :initial '{"if": "null"}' "~/.config/eww/scripts/get-network.sh")
; Notifications status ; Notifications status
(defpoll nf-enabled :initial "true" :interval "1m" "makoctl mode | grep -q dnd && echo false || echo true") (defpoll nf-enabled :initial "true" :interval "1h" "makoctl mode | grep -q dnd && echo false || echo true")
; Packages updates ; Packages updates
(deflisten packages-updates :initial '{"count": "-", "class": " "}' "~/.config/eww/scripts/pkg-updates.sh") (deflisten packages-updates :initial '{"count": "-", "class": " "}' "~/.config/eww/scripts/pkg-updates.sh")
; Volume
(defpoll volume :initial '{"input":{"value":50,"muted":0},"output":{"value":50,"muted":0}}' :interval "1h" "~/.config/eww/scripts/get-volume.sh")
(defvar volume-icons '{"input": {"active": ["󰍬", "󰍬", "󰍬"], "muted": "󰍭"}, "output": {"active": ["󰕿", "󰖀", "󰕾"], "muted": "󰝟"}}')
(defvar volume-slide '{"input": false, "output": false}')
; Window Title ; Window Title
(deflisten window-title "~/.config/eww/scripts/get-window-title.sh") (deflisten window-title "~/.config/eww/scripts/get-window-title.sh")
@ -33,14 +38,13 @@
; Widgets ; Widgets
(defwidget bar-left [] (defwidget bar-left []
(box :halign "start" (box :halign "start"
:spacing 10
:space-evenly false :space-evenly false
(workspaces) (workspaces)
(systray :spacing 8 (tray)
:icon-size 16
:class "systray"
)
(nf-state) (nf-state)
(packages-updates) (packages-updates)
(volume)
(network) (network)
) )
) )
@ -49,15 +53,22 @@
(eventbox :onscroll "~/.config/eww/scripts/change-active-workspace.sh {} ${active-workspace}" (eventbox :onscroll "~/.config/eww/scripts/change-active-workspace.sh {} ${active-workspace}"
(box :spacing 0 (box :spacing 0
(for workspace in workspaces (for workspace in workspaces
(eventbox :onclick "hyprctl dispatch workspace ${workspace}" (eventbox :onclick "hyprctl dispatch workspace ${workspace.id}"
:class "workspace ${workspace == active-workspace ? "active" : ""}" :class "workspace ${workspace.id == active-workspace ? "active" : ""} ${workspace.windows > 0 ? "occupied" : "empty"}"
(label :text "${workspace}") (label :text "${workspace.id == active-workspace ? "" :""}")
) )
) )
) )
) )
) )
(defwidget tray []
(systray :spacing 8
:icon-size 16
:class "systray"
)
)
(defwidget nf-state [] (defwidget nf-state []
(eventbox :onclick "~/.config/eww/scripts/toggle-nf-state.sh" (eventbox :onclick "~/.config/eww/scripts/toggle-nf-state.sh"
(label :text "${nf-enabled ? "󰂚" : "󰂛"} NF" (label :text "${nf-enabled ? "󰂚" : "󰂛"} NF"
@ -67,16 +78,43 @@
) )
(defwidget packages-updates [] (defwidget packages-updates []
(eventbox :onclick "pkill -SIGUSR1 -u 1000 pkg-updates.sh"
(label :text "󰏖 ${packages-updates.count}" (label :text "󰏖 ${packages-updates.count}"
:class "${packages-updates.class}" :class "${packages-updates.class}"
:tooltip "${packages-updates.tooltip}" :tooltip "${packages-updates.tooltip}"
) )
) )
)
(defwidget volume []
(box :spacing 10
:space-evenly false
(for target in '["output", "input"]'
(eventbox :onhover "${EWW_CMD} update volume-slide=$(${EWW_CMD} get volume-slide | jq -c '.${target} = true')"
:onhoverlost "${EWW_CMD} update volume-slide=$(${EWW_CMD} get volume-slide | jq -c '.${target} = false')"
(box :space-evenly false
:class "${volume[target].muted == 1 ? "disabled" : ""}"
(eventbox :onclick "~/.config/eww/scripts/toggle-volume-mute.sh ${target}"
(label :text "${volume[target].muted == 1 ? "${volume-icons[target].muted}" : "${volume-icons[target].active[round(volume[target].value / 42, 0)]}"} ${volume[target].value}%")
)
(revealer :transition "slideleft"
:reveal {volume-slide[target]}
(scale :value {volume[target].value}
:min 0
:max 101
:onchange "~/.config/eww/scripts/set-volume.sh ${target} {}"
)
)
)
)
)
)
)
(defwidget network [] (defwidget network []
(tooltip (tooltip
(label :text "IPv4: ${network.ip4}\\nIPv6: ${network.ip6}${network.type == "wifi" ? "\\nRate: ${network.rate}\\nSignal strength: ${network.signal}" : ""}") (label :text "IPv4: ${network.ip4}\\nIPv6: ${network.ip6}${network.type == "wifi" ? "\\nRate: ${network.rate}\\nSignal strength: ${network.signal}" : ""}")
(label :text "${network.icon} ${network.name} ${network.if == "null" ? "" : "󰜮 ${EWW_NET[network.if].NET_DOWN} 󰜷 ${EWW_NET[network.if].NET_UP}"}") (label :text "${network.icon} ${network.name} ${network.if == "null" ? "" : "󰜮 ${network.down} 󰜷 ${network.up}"}")
) )
) )
@ -91,6 +129,7 @@
(defwidget bar-right [] (defwidget bar-right []
(box :halign "end" (box :halign "end"
:spacing 10
:space-evenly false :space-evenly false
(brightness) (brightness)
(battery :percent {EWW_BATTERY.BAT0.capacity} (battery :percent {EWW_BATTERY.BAT0.capacity}
@ -98,16 +137,8 @@
) )
(ram) (ram)
(cpu-temp) (cpu-temp)
(label :text " ${round(EWW_CPU.avg, 0)}%" (cpu-usage)
:tooltip " ${arraylength(EWW_CPU.cores)} cores available" (clock)
)
(tooltip
(calendar :day {day}
:month {month}
:year {year}
)
(label :text "󰥔 ${datetime}")
)
) )
) )
@ -120,7 +151,7 @@
:reveal {brightness-slide} :reveal {brightness-slide}
(scale :value {brightness} (scale :value {brightness}
:min 0 :min 0
:max 255 :max 256
:onchange "~/.config/eww/scripts/set-brightness.sh {}" :onchange "~/.config/eww/scripts/set-brightness.sh {}"
) )
) )
@ -158,6 +189,23 @@
) )
) )
(defwidget cpu-usage []
(label :text " ${round(EWW_CPU.avg, 0)}%"
:tooltip " ${arraylength(EWW_CPU.cores)} cores available"
)
)
(defwidget clock []
(tooltip
(calendar :day {day}
:month {month}
:year {year}
)
(label :text "󰥔 ${datetime}")
)
)
; Bar ; Bar
(defwidget bar [] (defwidget bar []
@ -172,6 +220,7 @@
:geometry (geometry :x "0%" :geometry (geometry :x "0%"
:y "0%" :y "0%"
:width "100%" :width "100%"
:height "30px"
:anchor "top center" :anchor "top center"
) )
:stacking "fg" :stacking "fg"

View file

@ -1,26 +1,61 @@
#!/bin/bash #!/bin/bash
if=$(ip -j r list default | jq -r '.[0].dev') interval=2
if [[ "$if" != "null" ]]; then while :; do
type="$(nmcli -t -g general.type device show $if)" if_new=$(ip -j r list default | jq -r '.[0].dev')
ip4="$(nmcli -t -g ip4.address device show $if)"
ip6="$(nmcli -t -g ip6.address device show $if | sed 's/\\//g')" unset type ip4 ip6 rate signal up down
if [[ "$if_new" != "null" ]]; then
if [[ "$if_new" != "$if" ]]; then
bytes_down=$(cat "/sys/class/net/$if_new/statistics/rx_bytes")
bytes_up=$(cat "/sys/class/net/$if_new/statistics/tx_bytes")
fi
type="$(nmcli -t -g general.type device show "$if_new")"
ip4="$(nmcli -t -g ip4.address device show "$if_new")"
ip6="$(nmcli -t -g ip6.address device show "$if_new" | sed 's/\\//g')"
name="${type^}"
if [[ "$type" == "wifi" ]]; then if [[ "$type" == "wifi" ]]; then
icon="󰖩" icon="󰖩"
name="$(nmcli -t -g general.connection device show $if)" name="$(nmcli -t -g general.connection device show "$if_new")"
rate="$(nmcli -t -g 'AP' device show wlo1 | awk -F ':' '{if ($2 == "*") { print $12 } }')" rate="$(nmcli -t -g 'AP' device show wlo1 | awk -F ':' '{if ($2 == "*") { print $12 } }')"
signal="$(nmcli -t -g 'AP' device show wlo1 | awk -F ':' '{if ($2 == "*") { print $13 } }')%" signal="$(nmcli -t -g 'AP' device show wlo1 | awk -F ':' '{if ($2 == "*") { print $13 } }')%"
else elif [[ "$type" == "ethernet" ]]; then
icon="󰛳" icon="󰛳"
name="Ethernet" else
icon="󰲛"
fi
bytes_down_new=$(cat "/sys/class/net/$if_new/statistics/rx_bytes")
bitrate_down=$(( (bytes_down_new - bytes_down) / interval ))
bytes_down=$bytes_down_new
if [[ $bitrate_down -lt 1024 ]]; then
down="${bitrate_down}B/s"
else
down="$(numfmt --to=iec $bitrate_down)/s"
fi
bytes_up_new=$(cat "/sys/class/net/$if_new/statistics/tx_bytes")
bitrate_up=$(( (bytes_up_new - bytes_up) / interval ))
bytes_up=$bytes_up_new
if [[ $bitrate_up -lt 1024 ]]; then
up="${bitrate_up}B/s"
else
up="$(numfmt --to=iec $bitrate_up)/s"
fi fi
else else
icon="󰲛" icon="󰲛"
name="Not connected" name="Not connected"
fi fi
if="$if_new"
cat << EOF cat << EOF
{"if": "$if", "icon": "$icon", "type": "$type", "name": "$name", "ip4": "$ip4", "ip6": "$ip6", "rate": "$rate", "signal": "$signal"} {"if": "$if", "icon": "$icon", "type": "$type", "name": "$name", "ip4": "$ip4", "ip6": "$ip6", "rate": "$rate", "signal": "$signal", "down": "$down", "up": "$up"}
EOF EOF
sleep $interval
done

View file

@ -0,0 +1,8 @@
#!/bin/bash
input=$(wpctl get-volume @DEFAULT_AUDIO_SOURCE@ | awk '{print "{\"value\": " $2 * 100 ", \"muted\": " ($3 == "[MUTED]") "}"}')
output=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print "{\"value\": " $2 * 100 ", \"muted\": " ($3 == "[MUTED]") "}"}')
cat << EOF
{"input": $input, "output": $output}
EOF

View file

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

View file

@ -2,10 +2,8 @@
if [[ "$1" =~ ^[0-9]+$ ]]; then if [[ "$1" =~ ^[0-9]+$ ]]; then
echo "$1" > /sys/class/backlight/amdgpu_bl1/brightness echo "$1" > /sys/class/backlight/amdgpu_bl1/brightness
elif [[ "$1" == "raise" ]]; then else
swayosd-client --brightness raise swayosd-client --brightness "$1"
elif [[ "$1" == "lower" ]]; then
swayosd-client --brightness lower
fi fi
eww update brightness=$(cat /sys/class/backlight/amdgpu_bl1/brightness) eww update brightness="$(cat /sys/class/backlight/amdgpu_bl1/brightness)"

View file

@ -0,0 +1,13 @@
#!/bin/bash
if [[ "$2" =~ ^[0-9]+$ ]]; then
if [[ "$1" == "input" ]]; then
wpctl set-volume @DEFAULT_AUDIO_SOURCE@ "$2%"
else
wpctl set-volume @DEFAULT_AUDIO_SINK@ "$2%"
fi
else
swayosd-client "--$1-volume" "$2"
fi
eww update volume="$(~/.config/eww/scripts/get-volume.sh)"

View file

@ -0,0 +1,5 @@
#!/bin/bash
swayosd-client "--$1-volume" mute-toggle
eww update volume="$(~/.config/eww/scripts/get-volume.sh)"

View file

@ -67,10 +67,10 @@ bindm = $mainMod, mouse:273, resizewindow
# Swayosd Audio/Brightness/Caps Lock # Swayosd Audio/Brightness/Caps Lock
bindl = , Caps_Lock, exec, swayosd-client --caps-lock bindl = , Caps_Lock, exec, swayosd-client --caps-lock
binde = , XF86AudioRaiseVolume, exec, swayosd-client --output-volume=raise binde = , XF86AudioRaiseVolume, exec, $HOME/.config/eww/scripts/set-volume.sh output raise
binde = , XF86AudioLowerVolume, exec, swayosd-client --output-volume=lower binde = , XF86AudioLowerVolume, exec, $HOME/.config/eww/scripts/set-volume.sh output lower
binde = , XF86AudioMute, exec, swayosd-client --output-volume=mute-toggle binde = , XF86AudioMute, exec, $HOME/.config/eww/scripts/toggle-volume-mute.sh output
binde = , XF86AudioMicMute, exec, swayosd-client --input-volume=mute-toggle binde = , XF86AudioMicMute, exec, $HOME/.config/eww/scripts/toggle-volume-mute.sh input
bindel = , XF86MonBrightnessUp, exec, $HOME/.config/eww/scripts/set-brightness.sh raise bindel = , XF86MonBrightnessUp, exec, $HOME/.config/eww/scripts/set-brightness.sh raise
bindel = , XF86MonBrightnessDown, exec, $HOME/.config/eww/scripts/set-brightness.sh lower bindel = , XF86MonBrightnessDown, exec, $HOME/.config/eww/scripts/set-brightness.sh lower