feat(waybar): use builtins
This commit is contained in:
parent
d5a6763585
commit
cedc2cc728
4 changed files with 42 additions and 152 deletions
|
|
@ -110,7 +110,6 @@ in
|
||||||
link "$cfg/hypr/themes/$theme.conf" "$cfg/hypr/themes/theme.conf"
|
link "$cfg/hypr/themes/$theme.conf" "$cfg/hypr/themes/theme.conf"
|
||||||
link "$cfg/waybar/themes/$theme.css" "$cfg/waybar/themes/theme.css"
|
link "$cfg/waybar/themes/$theme.css" "$cfg/waybar/themes/theme.css"
|
||||||
link "$cfg/fuzzel/themes/$theme.ini" "$cfg/fuzzel/themes/theme.ini"
|
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"
|
$DRY_RUN_CMD mkdir -p "$cfg/dunst/dunstrc.d"
|
||||||
link "$cfg/dunst/themes/$theme.conf" "$cfg/dunst/dunstrc.d/theme.conf"
|
link "$cfg/dunst/themes/$theme.conf" "$cfg/dunst/dunstrc.d/theme.conf"
|
||||||
''}
|
''}
|
||||||
|
|
|
||||||
|
|
@ -16,15 +16,6 @@ let
|
||||||
tooltip { background: ${palette.bgAlt}; color: ${palette.fg}; border: 1px solid ${palette.border}; }
|
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";
|
hexToFuzzel = hex: "${builtins.substring 1 6 hex}ff";
|
||||||
|
|
||||||
mkFuzzelTheme = palette: ''
|
mkFuzzelTheme = palette: ''
|
||||||
|
|
@ -87,7 +78,6 @@ in
|
||||||
papirus-icon-theme
|
papirus-icon-theme
|
||||||
psmisc
|
psmisc
|
||||||
fuzzel
|
fuzzel
|
||||||
eww
|
|
||||||
wl-clipboard
|
wl-clipboard
|
||||||
grim
|
grim
|
||||||
slurp
|
slurp
|
||||||
|
|
@ -167,7 +157,7 @@ in
|
||||||
max-volume = 100;
|
max-volume = 100;
|
||||||
scroll-step = 5;
|
scroll-step = 5;
|
||||||
on-click = "ctl audio sink";
|
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";
|
on-click-middle = "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle";
|
||||||
tooltip = true;
|
tooltip = true;
|
||||||
tooltip-format = "{volume}%";
|
tooltip-format = "{volume}%";
|
||||||
|
|
@ -181,7 +171,7 @@ in
|
||||||
max-volume = 100;
|
max-volume = 100;
|
||||||
scroll-step = 5;
|
scroll-step = 5;
|
||||||
on-click = "ctl audio source";
|
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";
|
on-click-middle = "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle";
|
||||||
tooltip = true;
|
tooltip = true;
|
||||||
tooltip-format = "{volume}%";
|
tooltip-format = "{volume}%";
|
||||||
|
|
@ -329,110 +319,6 @@ in
|
||||||
xdg.configFile."waybar/themes/midnight.css".text = mkWaybarTheme config.palettes.midnight;
|
xdg.configFile."waybar/themes/midnight.css".text = mkWaybarTheme config.palettes.midnight;
|
||||||
xdg.configFile."waybar/themes/daylight.css".text = mkWaybarTheme config.palettes.daylight;
|
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 = ''
|
xdg.configFile."fuzzel/fuzzel.ini".text = ''
|
||||||
include=${config.xdg.configHome}/fuzzel/themes/theme.ini
|
include=${config.xdg.configHome}/fuzzel/themes/theme.ini
|
||||||
|
|
||||||
|
|
@ -467,6 +353,8 @@ in
|
||||||
|
|
||||||
[key-bindings]
|
[key-bindings]
|
||||||
custom-1=Control+r
|
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/midnight.ini".text = mkFuzzelTheme config.palettes.midnight;
|
||||||
xdg.configFile."fuzzel/themes/daylight.ini".text = mkFuzzelTheme config.palettes.daylight;
|
xdg.configFile."fuzzel/themes/daylight.ini".text = mkFuzzelTheme config.palettes.daylight;
|
||||||
|
|
|
||||||
67
scripts/ctl
67
scripts/ctl
|
|
@ -81,42 +81,51 @@ audio)
|
||||||
class="Audio/Sink"
|
class="Audio/Sink"
|
||||||
prompt="sink: "
|
prompt="sink: "
|
||||||
default_meta="default.audio.sink"
|
default_meta="default.audio.sink"
|
||||||
|
node="@DEFAULT_AUDIO_SINK@"
|
||||||
pad=7
|
pad=7
|
||||||
else
|
else
|
||||||
class="Audio/Source"
|
class="Audio/Source"
|
||||||
prompt="source: "
|
prompt="source: "
|
||||||
default_meta="default.audio.source"
|
default_meta="default.audio.source"
|
||||||
|
node="@DEFAULT_AUDIO_SOURCE@"
|
||||||
pad=8
|
pad=8
|
||||||
fi
|
fi
|
||||||
dump=$(pw-dump)
|
while :; do
|
||||||
devices=$(printf '%s' "$dump" | jq -r --arg class "$class" \
|
dump=$(pw-dump)
|
||||||
'.[] | select(.info.props."media.class" == $class) | "\(.id)\t\(.info.props."node.description" // .info.props."node.name" // "unknown")\t\(.info.props."node.name" // "")"')
|
devices=$(printf '%s' "$dump" | jq -r --arg class "$class" \
|
||||||
[ -z "$devices" ] && exit 0
|
'.[] | select(.info.props."media.class" == $class) | "\(.id)\t\(.info.props."node.description" // .info.props."node.name" // "unknown")\t\(.info.props."node.name" // "")"')
|
||||||
default_name=$(printf '%s' "$dump" | jq -r --arg key "$default_meta" \
|
[ -z "$devices" ] && exit 0
|
||||||
'.[] | select(.type == "PipeWire:Interface:Metadata" and .info.props."metadata.name" == "default") | .info.metadata[] | select(.key == $key) | .value | fromjson | .name')
|
default_name=$(printf '%s' "$dump" | jq -r --arg key "$default_meta" \
|
||||||
rows=$(printf '%s\n' "$devices" | while IFS="$(printf '\t')" read -r id name node_name; do
|
'.[] | select(.type == "PipeWire:Interface:Metadata" and .info.props."metadata.name" == "default") | .info.metadata[] | select(.key == $key) | .value | fromjson | .name')
|
||||||
active=$([ "$node_name" = "$default_name" ] && echo ">" || echo "")
|
vol=$(wpctl get-volume "$node" | awk '{printf "%d", $2 * 100}')
|
||||||
printf '%s\t%s\t%s\n' "$id" "$name" "$active"
|
rows=$(printf '%s\n' "$devices" | while IFS="$(printf '\t')" read -r id name node_name; do
|
||||||
done)
|
active=$([ "$node_name" = "$default_name" ] && echo ">" || echo "")
|
||||||
[ -z "$rows" ] && exit 0
|
printf '%s\t%s\t%s\n' "$id" "$name" "$active"
|
||||||
w1=$(printf '%s\n' "$rows" | awk -F'\t' 'BEGIN{m=11}{l=length($2);if(l>m)m=l}END{print m}')
|
done)
|
||||||
fw=$((w1 + pad + 10))
|
[ -z "$rows" ] && exit 0
|
||||||
sep=$(awk -v n="$w1" 'BEGIN{for(i=0;i<n;i++)printf "─";print ""}')
|
w1=$(printf '%s\n' "$rows" | awk -F'\t' 'BEGIN{m=11}{l=length($2);if(l>m)m=l}END{print m}')
|
||||||
indent=$(printf "%${pad}s" "")
|
fw=$((w1 + pad + 10))
|
||||||
active_prefix=$(printf " >%$((pad - 3))s" "")
|
sep=$(awk -v n="$w1" 'BEGIN{for(i=0;i<n;i++)printf "─";print ""}')
|
||||||
header=$(printf "%s%s\n%s%s" "$indent" "Device name" "$indent" "$sep")
|
indent=$(printf "%${pad}s" "")
|
||||||
count=$(printf '%s\n' "$rows" | wc -l)
|
active_prefix=$(printf " >%$((pad - 3))s" "")
|
||||||
choice=$(printf '%s\n' "$rows" |
|
header=$(printf "%s%s vol: %d%%\n%s%s" "$indent" "Device name" "$vol" "$indent" "$sep")
|
||||||
awk -F'\t' -v w1="$w1" -v indent="$indent" -v active_prefix="$active_prefix" '{
|
count=$(printf '%s\n' "$rows" | wc -l)
|
||||||
prefix = ($3 == ">") ? active_prefix : indent
|
choice=$(printf '%s\n' "$rows" |
|
||||||
printf "%s%-*s\t%s\n", prefix, w1, $2, $1
|
awk -F'\t' -v w1="$w1" -v indent="$indent" -v active_prefix="$active_prefix" '{
|
||||||
}' |
|
prefix = ($3 == ">") ? active_prefix : indent
|
||||||
fuzzel --dmenu --prompt="$prompt" --no-icons --lines="$count" \
|
printf "%s%-*s\t%s\n", prefix, w1, $2, $1
|
||||||
--with-nth=1 --accept-nth=2 \
|
}' |
|
||||||
--mesg="$header" --mesg-mode=expand \
|
fuzzel --dmenu --prompt="$prompt" --no-icons --lines="$count" \
|
||||||
--font="monospace:size=12" --width="$fw")
|
--with-nth=1 --accept-nth=2 \
|
||||||
[ -z "$choice" ] && exit 0
|
--mesg="$header" --mesg-mode=expand \
|
||||||
wpctl set-default "$choice"
|
--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
|
echo "Usage: ctl audio {sink|source}" >&2
|
||||||
|
|
|
||||||
|
|
@ -101,12 +101,6 @@ Linux)
|
||||||
ln -sf "$fuzzel_themes/$theme.ini" "$fuzzel_themes/theme.ini"
|
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"
|
dunst_themes="$cfg/dunst/themes"
|
||||||
[ -f "$dunst_themes/$theme.conf" ] && {
|
[ -f "$dunst_themes/$theme.conf" ] && {
|
||||||
mkdir -p "$cfg/dunst/dunstrc.d"
|
mkdir -p "$cfg/dunst/dunstrc.d"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue