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

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