added input module

This commit is contained in:
2025-09-09 09:33:04 +02:00
parent 8e5a15395a
commit 6af5a295b1
3 changed files with 73 additions and 21 deletions

View File

@@ -8,13 +8,11 @@
"modules-center": [], "modules-center": [],
"modules-right": [ "modules-right": [
"custom/pixelbuds_pro", "custom/pixelbuds_pro",
"wireplumber", "wireplumber#sink",
"custom/audio-output", "wireplumber#source",
"custom/network", "custom/network",
"custom/mem", "custom/mem",
"custom/cpu", "custom/cpu",
"custom/disk-root",
"custom/disk-gdrive",
"custom/tlp", "custom/tlp",
"tray", "tray",
"clock" "clock"
@@ -49,8 +47,8 @@
"format-disconnected": "Disconnected", "format-disconnected": "Disconnected",
"tooltip-format": "{ifname} via {gwaddr}" "tooltip-format": "{ifname} via {gwaddr}"
}, },
"wireplumber": { "wireplumber#sink": {
"format": "{volume}% {icon}", "format": "{node_name} {volume}% {icon}",
"format-muted": "", "format-muted": "",
"format-icons": { "format-icons": {
"headphone": "", "headphone": "",
@@ -60,9 +58,17 @@
"on-click": "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle", "on-click": "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle",
"on-click-right": "~/.config/waybar/scripts/audio.sh cycle", "on-click-right": "~/.config/waybar/scripts/audio.sh cycle",
"on-click-middle": "pavucontrol", "on-click-middle": "pavucontrol",
"scroll-step": 1 "scroll-step": 5
},
"wireplumber#source": {
"node-type": "Audio/Source",
"format": "{node_name} {volume}% ",
"format-muted": "",
"on-click": "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle",
"on-click-right": "~/.config/waybar/scripts/cycle_input.sh cycle",
"on-click-middle": "pavucontrol",
"scroll-step": 5
}, },
"custom/bluetooth-audio": { "custom/bluetooth-audio": {
"format": "{}", "format": "{}",
"return-type": "json", "return-type": "json",
@@ -208,13 +214,11 @@
"modules-center": [], "modules-center": [],
"modules-right": [ "modules-right": [
// "custom/pixelbuds_pro", // "custom/pixelbuds_pro",
"wireplumber", "wireplumber#sink",
"custom/audio-output", "wireplumber#source",
"custom/network", "custom/network",
"custom/mem", "custom/mem",
"custom/cpu", "custom/cpu",
"custom/disk-root",
"custom/disk-gdrive",
"custom/tlp", "custom/tlp",
"tray", "tray",
"clock" "clock"
@@ -249,8 +253,8 @@
"format-disconnected": "Disconnected", "format-disconnected": "Disconnected",
"tooltip-format": "{ifname} via {gwaddr}" "tooltip-format": "{ifname} via {gwaddr}"
}, },
"wireplumber": { "wireplumber#sink": {
"format": "{volume}% {icon}", "format": "{node_name} {volume}% {icon}",
"format-muted": "", "format-muted": "",
"format-icons": { "format-icons": {
"headphone": "", "headphone": "",
@@ -260,7 +264,16 @@
"on-click": "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle", "on-click": "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle",
"on-click-right": "~/.config/waybar/scripts/audio.sh cycle", "on-click-right": "~/.config/waybar/scripts/audio.sh cycle",
"on-click-middle": "pavucontrol", "on-click-middle": "pavucontrol",
"scroll-step": 1 "scroll-step": 5
},
"wireplumber#source": {
"node-type": "Audio/Source",
"format": "{node_name} {volume}% ",
"format-muted": "",
"on-click": "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle",
"on-click-right": "~/.config/waybar/scripts/cycle_input.sh cycle",
"on-click-middle": "pavucontrol",
"scroll-step": 5
}, },
"custom/bluetooth-audio": { "custom/bluetooth-audio": {

40
waybar/scripts/cycle_input.sh Executable file
View File

@@ -0,0 +1,40 @@
#!/bin/bash
DEFAULT_SOURCE=$(pactl info | grep 'Default Source' | cut -d ' ' -f3)
DESCRIPTION=$(pactl list sources | grep -A2 "Name: $DEFAULT_SOURCE" | grep "Description:" | cut -d ' ' -f2-)
case $1 in
cycle)
SOURCES=($(pactl list short sources | awk '{print $2}'))
NUM_SOURCES=${#SOURCES[@]}
CURRENT_SOURCE=$(pactl info | grep 'Default Source' | cut -d ' ' -f3)
for i in "${!SOURCES[@]}"; do
if [[ "${SOURCES[$i]}" == "$CURRENT_SOURCE" ]]; then
NEXT_INDEX=$(( (i + 1) % NUM_SOURCES ))
pactl set-default-source "${SOURCES[$NEXT_INDEX]}"
exit 0
fi
done
;;
show)
TEXT=$(echo "$DESCRIPTION" | cut -c -20)
if [ -z "$DESCRIPTION" ]; then
DESCRIPTION=$DEFAULT_SOURCE
fi
CLASS=""
case $(pactl get-source-mute @DEFAULT_SOURCE@ | awk '{print $2}') in
yes)
CLASS="muted"
;;
no)
CLASS="unmuted"
;;
esac
printf '{"text": "%s", "tooltip": "%s", "class": "%s"}' "$TEXT" "$DESCRIPTION" "$CLASS"
;;
*)
echo "usage audio.sh {cycle|show}"
;;
esac

View File

@@ -76,8 +76,8 @@ window#waybar.hidden {
#custom-btrfs, #custom-btrfs,
#custom-gpu-screen-recorder { #custom-gpu-screen-recorder {
border-radius: 10px; border-radius: 10px;
margin: 0px 3px; margin: 0px 2px;
padding: 0px 6px; padding: 0px 10px;
background-color: @base; background-color: @base;
color: @text; color: @text;
} }
@@ -142,7 +142,7 @@ window#waybar.hidden {
} }
#custom-tlp { #custom-tlp {
padding: 0 4px; padding: 0 10px;
min-width: 10px; min-width: 10px;
} }
@@ -225,8 +225,8 @@ window#waybar.hidden {
color: @mauve; color: @mauve;
} }
#wireplumber { #wireplumber.muted {
padding-right: 10px; padding-right: 15p;
} }
#custom-audio-output.unmuted, #wireplumber { #custom-audio-output.unmuted, #wireplumber {
@@ -239,7 +239,6 @@ window#waybar.hidden {
} }
#network { #network {
padding-right: 9px;
} }
tooltip { tooltip {