diff --git a/.config/eww/eww.scss b/.config/eww/eww.scss index 3d3ced6..8d90926 100644 --- a/.config/eww/eww.scss +++ b/.config/eww/eww.scss @@ -16,53 +16,62 @@ border-radius: 0; } -.bar > * > *:nth-child(even) { +.bar > *:last-child { + margin-right: 6px; +} + +.bar > * > *:nth-child(odd) { color: $accent1; - .disabled { - color: $disabled; - } scale trough { - background-color: $background1; + background-color: $disabled; } scale trough highlight { background-color: $accent1; } + .disabled { + color: $disabled; + } } -.bar > * > *:nth-child(odd) { +.bar > * > *:nth-child(even) { color: $accent2; - .disabled { - color: $disabled2; - } scale trough { background-color: $disabled2; } scale trough highlight { background-color: $accent2; } -} - -label, .systray { - padding: 6px; -} - -.workspace { - color: $foreground; - label { - padding: 0 10px; + .disabled { + color: $disabled2; } } +.workspace label { + padding: 0 7px; +} + +.workspace:nth-child(even) { + color: $accent1; +} + +.workspace:nth-child(odd) { + color: $accent2; +} + +.workspace.empty { + opacity: 0.3; +} + .workspace:hover { - background-color: $hovered; + opacity: 0.7; } .workspace.active { - background-color: $selected; + opacity: 1; } scale { - padding: 0 4px; + padding-left: 8px; slider { all: unset; } diff --git a/.config/eww/eww.yuck b/.config/eww/eww.yuck index 8caf00b..7ab3ddb 100644 --- a/.config/eww/eww.yuck +++ b/.config/eww/eww.yuck @@ -1,5 +1,5 @@ ; 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-slide false) @@ -7,20 +7,25 @@ (defvar battery-icons '{"Full": {"10": "󰂄"}, "Charging": ["󰢟", "󰢜", "󰂆", "󰂇", "󰂈", "󰢝", "󰂉", "󰢞", "󰂊", "󰂋", "󰂅"], "Discharging": ["󰂎", "󰁺", "󰁻", "󰁼", "󰁽", "󰁾", "󰁿", "󰂀", "󰂁", "󰂂", "󰁹"]}') ; 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 day :interval "1m" :initial "1" "date +'%d'") (defpoll year :interval "1m" :initial "0" "date +'%Y'") ; 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 -(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 (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 (deflisten window-title "~/.config/eww/scripts/get-window-title.sh") @@ -33,14 +38,13 @@ ; Widgets (defwidget bar-left [] (box :halign "start" + :spacing 10 :space-evenly false (workspaces) - (systray :spacing 8 - :icon-size 16 - :class "systray" - ) + (tray) (nf-state) (packages-updates) + (volume) (network) ) ) @@ -49,15 +53,22 @@ (eventbox :onscroll "~/.config/eww/scripts/change-active-workspace.sh {} ${active-workspace}" (box :spacing 0 (for workspace in workspaces - (eventbox :onclick "hyprctl dispatch workspace ${workspace}" - :class "workspace ${workspace == active-workspace ? "active" : ""}" - (label :text "${workspace}") + (eventbox :onclick "hyprctl dispatch workspace ${workspace.id}" + :class "workspace ${workspace.id == active-workspace ? "active" : ""} ${workspace.windows > 0 ? "occupied" : "empty"}" + (label :text "${workspace.id == active-workspace ? "" :""}") ) ) ) ) ) +(defwidget tray [] + (systray :spacing 8 + :icon-size 16 + :class "systray" + ) +) + (defwidget nf-state [] (eventbox :onclick "~/.config/eww/scripts/toggle-nf-state.sh" (label :text "${nf-enabled ? "󰂚" : "󰂛"} NF" @@ -67,16 +78,43 @@ ) (defwidget packages-updates [] - (label :text "󰏖 ${packages-updates.count}" - :class "${packages-updates.class}" - :tooltip "${packages-updates.tooltip}" + (eventbox :onclick "pkill -SIGUSR1 -u 1000 pkg-updates.sh" + (label :text "󰏖 ${packages-updates.count}" + :class "${packages-updates.class}" + :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 [] (tooltip (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 [] (box :halign "end" + :spacing 10 :space-evenly false (brightness) (battery :percent {EWW_BATTERY.BAT0.capacity} @@ -98,16 +137,8 @@ ) (ram) (cpu-temp) - (label :text " ${round(EWW_CPU.avg, 0)}%" - :tooltip " ${arraylength(EWW_CPU.cores)} cores available" - ) - (tooltip - (calendar :day {day} - :month {month} - :year {year} - ) - (label :text "󰥔 ${datetime}") - ) + (cpu-usage) + (clock) ) ) @@ -115,12 +146,12 @@ (eventbox :onhover "${EWW_CMD} update brightness-slide=true" :onhoverlost "${EWW_CMD} update brightness-slide=false" (box :space-evenly false - (label :text "${brightness-icons[round(brightness / 18.2, 0)]} ${round(brightness /255 * 100, 0)}%") + (label :text "${brightness-icons[round(brightness / 18.2, 0)]} ${round(brightness / 255 * 100, 0)}%") (revealer :transition "slideleft" :reveal {brightness-slide} (scale :value {brightness} :min 0 - :max 255 + :max 256 :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 (defwidget bar [] @@ -172,6 +220,7 @@ :geometry (geometry :x "0%" :y "0%" :width "100%" + :height "30px" :anchor "top center" ) :stacking "fg" diff --git a/.config/eww/scripts/get-network.sh b/.config/eww/scripts/get-network.sh index fb19b43..f754c74 100755 --- a/.config/eww/scripts/get-network.sh +++ b/.config/eww/scripts/get-network.sh @@ -1,26 +1,61 @@ #!/bin/bash -if=$(ip -j r list default | jq -r '.[0].dev') +interval=2 -if [[ "$if" != "null" ]]; then - type="$(nmcli -t -g general.type device show $if)" - ip4="$(nmcli -t -g ip4.address device show $if)" - ip6="$(nmcli -t -g ip6.address device show $if | sed 's/\\//g')" +while :; do + if_new=$(ip -j r list default | jq -r '.[0].dev') - if [[ "$type" == "wifi" ]]; then - icon="󰖩" - name="$(nmcli -t -g general.connection device show $if)" - 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 } }')%" + 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 + icon="󰖩" + name="$(nmcli -t -g general.connection device show "$if_new")" + 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 } }')%" + elif [[ "$type" == "ethernet" ]]; then + icon="󰛳" + 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 else - icon="󰛳" - name="Ethernet" + icon="󰲛" + name="Not connected" fi -else - icon="󰲛" - name="Not connected" -fi -cat << EOF -{"if": "$if", "icon": "$icon", "type": "$type", "name": "$name", "ip4": "$ip4", "ip6": "$ip6", "rate": "$rate", "signal": "$signal"} + if="$if_new" + + cat << EOF +{"if": "$if", "icon": "$icon", "type": "$type", "name": "$name", "ip4": "$ip4", "ip6": "$ip6", "rate": "$rate", "signal": "$signal", "down": "$down", "up": "$up"} EOF + + sleep $interval +done diff --git a/.config/eww/scripts/get-volume.sh b/.config/eww/scripts/get-volume.sh new file mode 100755 index 0000000..5cbb6cd --- /dev/null +++ b/.config/eww/scripts/get-volume.sh @@ -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 diff --git a/.config/eww/scripts/get-workspaces.sh b/.config/eww/scripts/get-workspaces.sh index 1eac143..d5efbb9 100755 --- a/.config/eww/scripts/get-workspaces.sh +++ b/.config/eww/scripts/get-workspaces.sh @@ -1,6 +1,13 @@ #!/usr/bin/env bash -hyprctl workspaces -j | jq -c '[.[].id] | sort | map(tostring)' -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)' +min_workspaces=4 + +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 diff --git a/.config/eww/scripts/set-brightness.sh b/.config/eww/scripts/set-brightness.sh index 0ce4eb7..d025f72 100755 --- a/.config/eww/scripts/set-brightness.sh +++ b/.config/eww/scripts/set-brightness.sh @@ -2,10 +2,8 @@ if [[ "$1" =~ ^[0-9]+$ ]]; then echo "$1" > /sys/class/backlight/amdgpu_bl1/brightness -elif [[ "$1" == "raise" ]]; then - swayosd-client --brightness raise -elif [[ "$1" == "lower" ]]; then - swayosd-client --brightness lower +else + swayosd-client --brightness "$1" fi -eww update brightness=$(cat /sys/class/backlight/amdgpu_bl1/brightness) +eww update brightness="$(cat /sys/class/backlight/amdgpu_bl1/brightness)" diff --git a/.config/eww/scripts/set-volume.sh b/.config/eww/scripts/set-volume.sh new file mode 100755 index 0000000..b79b6e0 --- /dev/null +++ b/.config/eww/scripts/set-volume.sh @@ -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)" diff --git a/.config/eww/scripts/toggle-volume-mute.sh b/.config/eww/scripts/toggle-volume-mute.sh new file mode 100755 index 0000000..a15bf21 --- /dev/null +++ b/.config/eww/scripts/toggle-volume-mute.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +swayosd-client "--$1-volume" mute-toggle + +eww update volume="$(~/.config/eww/scripts/get-volume.sh)" diff --git a/.config/hypr/hyprland.d/bindings.conf b/.config/hypr/hyprland.d/bindings.conf index 97ca749..145d8df 100644 --- a/.config/hypr/hyprland.d/bindings.conf +++ b/.config/hypr/hyprland.d/bindings.conf @@ -67,10 +67,10 @@ bindm = $mainMod, mouse:273, resizewindow # Swayosd Audio/Brightness/Caps Lock bindl = , Caps_Lock, exec, swayosd-client --caps-lock -binde = , XF86AudioRaiseVolume, exec, swayosd-client --output-volume=raise -binde = , XF86AudioLowerVolume, exec, swayosd-client --output-volume=lower -binde = , XF86AudioMute, exec, swayosd-client --output-volume=mute-toggle -binde = , XF86AudioMicMute, exec, swayosd-client --input-volume=mute-toggle +binde = , XF86AudioRaiseVolume, exec, $HOME/.config/eww/scripts/set-volume.sh output raise +binde = , XF86AudioLowerVolume, exec, $HOME/.config/eww/scripts/set-volume.sh output lower +binde = , XF86AudioMute, exec, $HOME/.config/eww/scripts/toggle-volume-mute.sh output +binde = , XF86AudioMicMute, exec, $HOME/.config/eww/scripts/toggle-volume-mute.sh input bindel = , XF86MonBrightnessUp, exec, $HOME/.config/eww/scripts/set-brightness.sh raise bindel = , XF86MonBrightnessDown, exec, $HOME/.config/eww/scripts/set-brightness.sh lower