diff --git a/home/modules/theme.nix b/home/modules/theme.nix index 179ced9..cd124b7 100644 --- a/home/modules/theme.nix +++ b/home/modules/theme.nix @@ -110,7 +110,6 @@ in link "$cfg/hypr/themes/$theme.conf" "$cfg/hypr/themes/theme.conf" link "$cfg/waybar/themes/$theme.css" "$cfg/waybar/themes/theme.css" link "$cfg/fuzzel/themes/$theme.ini" "$cfg/fuzzel/themes/theme.ini" - link "$cfg/eww/themes/$theme.scss" "$cfg/eww/themes/theme.scss" $DRY_RUN_CMD mkdir -p "$cfg/dunst/dunstrc.d" link "$cfg/dunst/themes/$theme.conf" "$cfg/dunst/dunstrc.d/theme.conf" ''} diff --git a/home/modules/ui.nix b/home/modules/ui.nix index f940b19..afbd11a 100644 --- a/home/modules/ui.nix +++ b/home/modules/ui.nix @@ -16,15 +16,6 @@ let tooltip { background: ${palette.bgAlt}; color: ${palette.fg}; border: 1px solid ${palette.border}; } ''; - mkEwwTheme = palette: '' - $bg: ${palette.bg}; - $fg: ${palette.fg}; - $bgAlt: ${palette.bgAlt}; - $fgAlt: ${palette.fgAlt}; - $border: ${palette.border}; - $accent: ${palette.accent}; - ''; - hexToFuzzel = hex: "${builtins.substring 1 6 hex}ff"; mkFuzzelTheme = palette: '' @@ -87,7 +78,6 @@ in papirus-icon-theme psmisc fuzzel - eww wl-clipboard grim slurp @@ -167,7 +157,7 @@ in max-volume = 100; scroll-step = 5; on-click = "ctl audio sink"; - on-click-right = "eww open --toggle volume"; + on-click-right = "ctl audio sink"; on-click-middle = "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; tooltip = true; tooltip-format = "{volume}%"; @@ -181,7 +171,7 @@ in max-volume = 100; scroll-step = 5; on-click = "ctl audio source"; - on-click-right = "eww open --toggle volume"; + on-click-right = "ctl audio source"; on-click-middle = "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"; tooltip = true; tooltip-format = "{volume}%"; @@ -329,110 +319,6 @@ in xdg.configFile."waybar/themes/midnight.css".text = mkWaybarTheme config.palettes.midnight; xdg.configFile."waybar/themes/daylight.css".text = mkWaybarTheme config.palettes.daylight; - xdg.configFile."eww/scripts/audio" = { - executable = true; - text = '' - #!/bin/sh - emit() { - sink=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ 2>/dev/null) - source=$(wpctl get-volume @DEFAULT_AUDIO_SOURCE@ 2>/dev/null) - sv=$(echo "$sink" | awk '{printf "%d", $2 * 100}') - sm=$(echo "$sink" | grep -q MUTED && echo true || echo false) - iv=$(echo "$source" | awk '{printf "%d", $2 * 100}') - im=$(echo "$source" | grep -q MUTED && echo true || echo false) - printf '{"sv":%d,"sm":%s,"iv":%d,"im":%s}\n' "$sv" "$sm" "$iv" "$im" - } - emit - pactl subscribe 2>/dev/null | while read -r line; do - case "$line" in - *"change"*"sink"*|*"change"*"source"*|*"change"*"server"*) emit ;; - esac - done - ''; - }; - - xdg.configFile."eww/eww.yuck".text = '' - (deflisten audio :initial '{"sv":0,"sm":false,"iv":0,"im":false}' "${config.xdg.configHome}/eww/scripts/audio") - - (defwidget volume-popup [] - (box :class "volume-popup" :orientation "v" :space-evenly false :spacing 12 - (box :class "slider-row" :orientation "h" :space-evenly false :spacing 8 - (button :class "mute-btn" :onclick "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle" - (label :text {audio.sm ? "󰖁" : audio.sv <= 33 ? "󰕿" : audio.sv <= 66 ? "󰖀" : "󰕾"})) - (scale :class "vol-slider" :value {audio.sv} :min 0 :max 100 :orientation "h" - :onchange "wpctl set-volume @DEFAULT_AUDIO_SINK@ {}%")) - (box :class "slider-row" :orientation "h" :space-evenly false :spacing 8 - (button :class "mute-btn" :onclick "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle" - (label :text {audio.im ? "󰍭" : "󰍬"})) - (scale :class "vol-slider" :value {audio.iv} :min 0 :max 100 :orientation "h" - :onchange "wpctl set-volume @DEFAULT_AUDIO_SOURCE@ {}%")))) - - (defwindow volume - :monitor 0 - :geometry (geometry :x "-16px" :y "42px" :width "280px" :anchor "top right") - :stacking "overlay" - :exclusive false - :focusable false - (volume-popup)) - ''; - - xdg.configFile."eww/eww.scss".text = '' - @import "themes/theme"; - - window { - border-radius: 0; - } - - .volume-popup { - background: $bg; - border: 2px solid $border; - border-radius: 0; - padding: 16px; - } - - .slider-row { - padding: 4px 0; - } - - .mute-btn { - background: transparent; - color: $fg; - font-size: 18px; - min-width: 28px; - min-height: 28px; - padding: 0; - border: none; - &:hover { color: $accent; } - } - - .vol-slider { - min-width: 200px; - min-height: 8px; - - trough { - background: $bgAlt; - min-height: 4px; - border-radius: 2px; - } - - highlight { - background: $accent; - border-radius: 2px; - } - - slider { - background: $fg; - min-width: 12px; - min-height: 12px; - border-radius: 6px; - margin: -4px 0; - } - } - ''; - - xdg.configFile."eww/themes/midnight.scss".text = mkEwwTheme config.palettes.midnight; - xdg.configFile."eww/themes/daylight.scss".text = mkEwwTheme config.palettes.daylight; - xdg.configFile."fuzzel/fuzzel.ini".text = '' include=${config.xdg.configHome}/fuzzel/themes/theme.ini @@ -467,6 +353,8 @@ in [key-bindings] custom-1=Control+r + custom-2=Control+k + custom-3=Control+j ''; xdg.configFile."fuzzel/themes/midnight.ini".text = mkFuzzelTheme config.palettes.midnight; xdg.configFile."fuzzel/themes/daylight.ini".text = mkFuzzelTheme config.palettes.daylight; diff --git a/scripts/ctl b/scripts/ctl index 36938c6..e14888e 100755 --- a/scripts/ctl +++ b/scripts/ctl @@ -81,42 +81,51 @@ audio) class="Audio/Sink" prompt="sink: " default_meta="default.audio.sink" + node="@DEFAULT_AUDIO_SINK@" pad=7 else class="Audio/Source" prompt="source: " default_meta="default.audio.source" + node="@DEFAULT_AUDIO_SOURCE@" pad=8 fi - dump=$(pw-dump) - devices=$(printf '%s' "$dump" | jq -r --arg class "$class" \ - '.[] | select(.info.props."media.class" == $class) | "\(.id)\t\(.info.props."node.description" // .info.props."node.name" // "unknown")\t\(.info.props."node.name" // "")"') - [ -z "$devices" ] && exit 0 - default_name=$(printf '%s' "$dump" | jq -r --arg key "$default_meta" \ - '.[] | select(.type == "PipeWire:Interface:Metadata" and .info.props."metadata.name" == "default") | .info.metadata[] | select(.key == $key) | .value | fromjson | .name') - rows=$(printf '%s\n' "$devices" | while IFS="$(printf '\t')" read -r id name node_name; do - active=$([ "$node_name" = "$default_name" ] && echo ">" || echo "") - printf '%s\t%s\t%s\n' "$id" "$name" "$active" - done) - [ -z "$rows" ] && exit 0 - w1=$(printf '%s\n' "$rows" | awk -F'\t' 'BEGIN{m=11}{l=length($2);if(l>m)m=l}END{print m}') - fw=$((w1 + pad + 10)) - sep=$(awk -v n="$w1" 'BEGIN{for(i=0;i%$((pad - 3))s" "") - header=$(printf "%s%s\n%s%s" "$indent" "Device name" "$indent" "$sep") - count=$(printf '%s\n' "$rows" | wc -l) - choice=$(printf '%s\n' "$rows" | - awk -F'\t' -v w1="$w1" -v indent="$indent" -v active_prefix="$active_prefix" '{ - prefix = ($3 == ">") ? active_prefix : indent - printf "%s%-*s\t%s\n", prefix, w1, $2, $1 - }' | - fuzzel --dmenu --prompt="$prompt" --no-icons --lines="$count" \ - --with-nth=1 --accept-nth=2 \ - --mesg="$header" --mesg-mode=expand \ - --font="monospace:size=12" --width="$fw") - [ -z "$choice" ] && exit 0 - wpctl set-default "$choice" + while :; do + dump=$(pw-dump) + devices=$(printf '%s' "$dump" | jq -r --arg class "$class" \ + '.[] | select(.info.props."media.class" == $class) | "\(.id)\t\(.info.props."node.description" // .info.props."node.name" // "unknown")\t\(.info.props."node.name" // "")"') + [ -z "$devices" ] && exit 0 + default_name=$(printf '%s' "$dump" | jq -r --arg key "$default_meta" \ + '.[] | select(.type == "PipeWire:Interface:Metadata" and .info.props."metadata.name" == "default") | .info.metadata[] | select(.key == $key) | .value | fromjson | .name') + vol=$(wpctl get-volume "$node" | awk '{printf "%d", $2 * 100}') + rows=$(printf '%s\n' "$devices" | while IFS="$(printf '\t')" read -r id name node_name; do + active=$([ "$node_name" = "$default_name" ] && echo ">" || echo "") + printf '%s\t%s\t%s\n' "$id" "$name" "$active" + done) + [ -z "$rows" ] && exit 0 + w1=$(printf '%s\n' "$rows" | awk -F'\t' 'BEGIN{m=11}{l=length($2);if(l>m)m=l}END{print m}') + fw=$((w1 + pad + 10)) + sep=$(awk -v n="$w1" 'BEGIN{for(i=0;i%$((pad - 3))s" "") + header=$(printf "%s%s vol: %d%%\n%s%s" "$indent" "Device name" "$vol" "$indent" "$sep") + count=$(printf '%s\n' "$rows" | wc -l) + choice=$(printf '%s\n' "$rows" | + awk -F'\t' -v w1="$w1" -v indent="$indent" -v active_prefix="$active_prefix" '{ + prefix = ($3 == ">") ? active_prefix : indent + printf "%s%-*s\t%s\n", prefix, w1, $2, $1 + }' | + fuzzel --dmenu --prompt="$prompt" --no-icons --lines="$count" \ + --with-nth=1 --accept-nth=2 \ + --mesg="$header" --mesg-mode=expand \ + --font="monospace:size=12" --width="$fw") + rc=$? + [ "$rc" = 11 ] && { wpctl set-volume "$node" 5%+ --limit 1.0; continue; } + [ "$rc" = 12 ] && { wpctl set-volume "$node" 5%-; continue; } + [ -z "$choice" ] && exit 0 + wpctl set-default "$choice" + break + done ;; *) echo "Usage: ctl audio {sink|source}" >&2 diff --git a/scripts/theme b/scripts/theme index a78fb90..fa01435 100755 --- a/scripts/theme +++ b/scripts/theme @@ -101,12 +101,6 @@ Linux) ln -sf "$fuzzel_themes/$theme.ini" "$fuzzel_themes/theme.ini" } - eww_themes="$cfg/eww/themes" - [ -f "$eww_themes/$theme.scss" ] && { - ln -sf "$eww_themes/$theme.scss" "$eww_themes/theme.scss" - eww reload 2>/dev/null || true - } - dunst_themes="$cfg/dunst/themes" [ -f "$dunst_themes/$theme.conf" ] && { mkdir -p "$cfg/dunst/dunstrc.d"