From 0d12ae9ef7c39ecd24bd7a7c711381d637252d8a Mon Sep 17 00:00:00 2001 From: DeveloperDurp Date: Sat, 7 Jun 2025 09:51:35 -0500 Subject: [PATCH] update --- .config/scripts/audioswitch.sh | 47 ++++++++++++++++++++++++++++++++++ .config/sway/config | 4 +++ .config/waybar/config | 2 +- .zshrc | 7 ++--- 4 files changed, 56 insertions(+), 4 deletions(-) create mode 100755 .config/scripts/audioswitch.sh diff --git a/.config/scripts/audioswitch.sh b/.config/scripts/audioswitch.sh new file mode 100755 index 0000000..ab7e8a6 --- /dev/null +++ b/.config/scripts/audioswitch.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# Use pactl to get the name and description pairs +output=$(pactl list sinks | grep -E 'Name:|Description:' | sed 's/^ *//') + +# Initialize an empty array to store the sink info +declare -A sinks + +# Initialize variables +name="" +description="" +i=0 + +# Loop through the lines of the output +while read -r line; do + if [[ "$line" =~ ^Name: ]]; then + name="${line#Name: }" # Extract the name + elif [[ "$line" =~ ^Description: ]]; then + description="${line#Description: }" # Extract the description + # Store the name and description in the associative array + sinks[$description]="$name" # Store name by description key + # Increment the index + ((i++)) + fi +done <<<"$output" + +# Create wofi options string +options=$(printf "%s\n" "${!sinks[@]}") + +# Run wofi and capture the selected description +selected_description=$(echo "$options" | wofi -dmenu -i -p "Select Audio Source" --columns 1) + +# Check if wofi returned a value (user made a selection) +if [ -n "$selected_description" ]; then + + # Get the corresponding name from the sinks array + selected_name="${sinks[$selected_description]}" + + # Check if we found a name for the selected description + if [ -n "$selected_name" ]; then + pactl set-default-sink "$selected_name" + notify-send "Set audio device to: $selected_description" + # ********************************************************************** + else + notify-send "Error: Could not find name for selected description." + fi +fi diff --git a/.config/sway/config b/.config/sway/config index 9ebcf5a..205a777 100644 --- a/.config/sway/config +++ b/.config/sway/config @@ -19,6 +19,7 @@ set $files nautilus set $browser flatpak run io.gitlab.librewolf-community set $bitwarden flatpak run com.bitwarden.desktop set $menu wofi +set $scripts "$HOME/.config/scripts" set $newScript "$HOME/.config/scripts/sessions.sh" set $next_or_new swaymsg -r -t get_workspaces | jq -r --arg OUTPUT $(swaymsg -t get_outputs -r | jq -r '.[] | select(.focused == true) | .name') '(. | (max_by(.num) | .num)) as $max | [.[] | select(.output == $OUTPUT)] | (max_by(.num) | .num) as $maxOutput | (.[] | select(.focused == true) | .num) as $current | if $maxOutput > $current then "next_on_output" else $max + 1 end' @@ -93,6 +94,9 @@ bindsym $mod+control+n exec swaync-client -t -sw # Start your goland bindsym $mod+n exec 'zsh -c ". $newScript new"' bindsym $mod+Shift+n exec 'zsh -c ". $newScript goland-new"' + + # Audio Switch + bindsym $mod+Shift+s exec 'bash -c ". $scripts/audioswitch.sh"' # Drag floating windows by holding down $mod and left mouse button. # Resize them with right mouse button + $mod. diff --git a/.config/waybar/config b/.config/waybar/config index 62d8730..f99d417 100644 --- a/.config/waybar/config +++ b/.config/waybar/config @@ -46,7 +46,7 @@ "default": ["\uf026", "\uf027", "\uf028"] }, "on-click": "pactl set-sink-mute @DEFAULT_SINK@ toggle", - "on-click-right": "pavucontrol", + "on-click-right": "$HOME/.config/scripts/audioswitch.sh", "format-muted": "\uf00d {volume}%" }, "tray": { diff --git a/.zshrc b/.zshrc index cf4ceb1..b6c42e1 100644 --- a/.zshrc +++ b/.zshrc @@ -92,9 +92,10 @@ bindkey -e bindkey '^p' history-search-backward bindkey '^n' history-search-forward bindkey '^[w' kill-region -bindkey "^[[1~" beginning-of-line -bindkey "^[[4~" end-of-line -bindkey '^[[3~' delete-char +bindkey "^[n" beginning-of-line +bindkey "^[." end-of-line +bindkey "^[l" forward-word +bindkey "^[h" backward-word # History HISTSIZE=5000