From f0d579a03af9e3ba4a7cf64da96c23f485faac7a Mon Sep 17 00:00:00 2001 From: Don Williams Date: Sat, 21 Feb 2026 00:22:44 -0500 Subject: added script to mute active window from Ivy and s1lang On branch development Your branch is up to date with 'origin/development'. Changes to be committed: modified: CHANGELOG.md modified: config/hypr/configs/Keybinds.conf renamed: config/hypr/scripts/SinkIntToggle.sh -> config/hypr/scripts/Toggle-Active-Window-Audio.sh --- CHANGELOG.md | 10 +++ config/hypr/configs/Keybinds.conf | 2 +- config/hypr/scripts/SinkIntToggle.sh | 97 ----------------------- config/hypr/scripts/Toggle-Active-Window-Audio.sh | 97 +++++++++++++++++++++++ 4 files changed, 108 insertions(+), 98 deletions(-) delete mode 100755 config/hypr/scripts/SinkIntToggle.sh create mode 100755 config/hypr/scripts/Toggle-Active-Window-Audio.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 332c6f67..a5bae84f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ ## v2.3.21 +- Added script from `@ivy` and `@sl1ng` to Toggle audio on active Wundow + - `$HOME/.config/hypr/scripts/Toggle-Active-Window-Audio.sh` + - Keybind is `SUPER + SHIFT + H` (hush) +- Added check for ubunutu v26.04 in startup + - For as of yet unknown reason waybar won't startup without this + ``` + exec-once = /usr/libexec/xdg-desktop-portal-hyprland & + exec-once = /usr/libexec/xdg-desktop-portal & + exec-once = waybar + ``` - Updated `waybar-weather` - Created default files in `.config/waybar-weather` - You can manually override settings or providers diff --git a/config/hypr/configs/Keybinds.conf b/config/hypr/configs/Keybinds.conf index 84a744bd..ba0201f1 100644 --- a/config/hypr/configs/Keybinds.conf +++ b/config/hypr/configs/Keybinds.conf @@ -37,7 +37,7 @@ bindd = $mainMod CTRL, R, rofi theme selector, exec, $scriptsDir/RofiThemeSelect bindd = $mainMod CTRL SHIFT, R, rofi theme selector (modified), exec, pkill rofi || true && $scriptsDir/RofiThemeSelector-modified.sh bindd = $mainMod CTRL, K, Kitty theme selector, exec, $scriptsDir/Kitty_themes.sh bindd = $mainMod SHIFT, B, Set static Rainbow Border, exec, $UserScripts/RainbowBorders-low-cpu.sh --run-once -bindd = $mainMod SHIFT, H, Toggle Mute/Unmute for Active-Window, exec, $scriptsDir/SinkIntToggle.sh +bindd = $mainMod SHIFT, H, Toggle Mute/Unmute for Active-Window, exec, $scriptsDir/Toggle-Active-Window-Audio.sh bindd = ALT SHIFT, S, Hyprshot Screen Capture, exec, $scriptsDir/hyprshot.sh -m region -o %HOME/Pictures/Screenshots bindd = $mainMod SHIFT, F, fullscreen, fullscreen diff --git a/config/hypr/scripts/SinkIntToggle.sh b/config/hypr/scripts/SinkIntToggle.sh deleted file mode 100755 index 12312a47..00000000 --- a/config/hypr/scripts/SinkIntToggle.sh +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" -swayIconDir="${XDG_CONFIG_HOME}/swaync/icons" - -#// Credits to sl1ng for the orginal script. Rewritten by Vyle. -ctlcheck=("pactl" "jq" "notify-send" "awk" "pgrep" "hyprctl" "iconv") -missing=() - -for ctl in "${ctlcheck[@]}"; do - command -v "${ctl}" >/dev/null || missing+=("${ctl}") -done - -if (( ${#missing[@]} )) 2>/dev/null; then - echo "Missing required dependencies: \"${missing[*]}\"" - exit 1 -fi - -#// Parse .pid, .class, .title to __pid, __class, __title. -active_json="$(hyprctl -j activewindow 2>/dev/null || { echo -e "Did hyprctl fail to run? [EXIT-CODE:-1]"; exit 1; } )" -PID="$(jq -r '"\(.pid)\t\(.class)\t\(.title)"' <<< "${active_json}" || { echo -e "Did jq fail to run? [EXIT-CODE:-1]"; exit 1; } )" - -IFS=$'\t' read -r __pid __class __title <<< "${PID}" - -[[ -z "${__pid}" ]] && { echo -e "Could not resolve PID for focused window."; exit 1; } -sink_json="$(pactl -f json list sink-inputs 2>/dev/null | iconv -f utf-8 -t utf-8 -c || { echo -e "Did pactl or iconv fail to run? Required manual intervention."; exit 1; } )" - -#// Check if the __pid matches application.process.id or else verify other statements. -mapfile -t sink_ids < <(jq -r --arg pid "${__pid}" --arg class "${__class}" --arg title "${__title}" ' -.[] | - def lc(x): (x // "" | ascii_downcase); - def normalize(x): x | gsub("[-_~.]+";" ") ; - select( - (.properties["application.process.id"] // "") == $pid - or - (lc(.properties["application.name"]) | contains(lc($class))) - or - (lc(.properties["application.id"]) | contains(lc($class))) - or - (lc(.properties["application.process.binary"]) | contains(lc($class))) - or - ((normalize(lc(.properties["media.name"])) | test(normalize(lc($title))))) - ) | .index' <<< "${sink_json}" -) - -if [[ "${#sink_ids[@]}" -eq 0 ]]; then - fallback_pid="$(pgrep -x "${__class}" | head -n 1 || true)" - if [[ -n "${fallback_pid}" ]]; then - mapfile -t sink_ids < <( jq -r --arg pid "${fallback_pid}" '.[] | - select(.properties["application.process.id"] == $pid) | .index' <<< "${sink_json}" ) - fi -fi - -#// Auto-Detect if the environment is on Hyprland or $HYPRLAND_INSTANCE_SIGNATURE. -if [[ ${#sink_ids[@]} -eq 0 ]]; then - if [[ -n "${HYPRLAND_INSTANCE_SIGNATURE}" ]]; then - # Even if the fallback_pid remains empty, we will dispatch exit code based on $HYPRLAND_INSTANCE_SIGNATURE. - notify-send -a "t1" -r 91190 -t 1200 -i "${swayIconDir}/volume-low.png" "No sink input for the active_window: ${__class}" - echo "No sink input for focused window: ${__class}" - exit 1 - else - echo "No sink input for focused active_window ${__class}" - exit 1 - fi -fi - -idsJson=$(printf '%s\n' "${sink_ids[@]}" | jq -s 'map(tonumber)') - -#// Get the available option from pactl. -want_mute=$(jq -r --argjson ids "$idsJson" ' - [ .[] | select(.index as $i | $ids | index($i)) | .mute ] as $m | - if all($m[]; . == true) then "no" - else "yes" - end' <<< "${sink_json}" -) - -if [[ "${want_mute}" == "no" ]]; then - state_msg="Unmuted" - swayIcon="${swayIconDir}/volume-high.png" -else - state_msg="Muted" - swayIcon="${swayIconDir}/volume-mute.png" -fi - -[[ -f "${swayIcon}" ]] || echo -e "Missing swaync icons." - -for id in "${sink_ids[@]}"; do - pactl set-sink-input-mute "$id" "$want_mute" -done - -#// Append pamixer to get a nice result. Pamixer is complete optional here. -if command -v pamixer >/dev/null; then - notify-send -a "t2" -r 91190 -t 800 -i "${swayIcon}" "${state_msg} ${__class}" "$(pamixer --get-default-sink | awk -F '"' 'END{print $(NF - 1)}')" -else - notify-send -a "t2" -r 91190 -t 800 -i "${swayIcon}" "${state_msg} ${__class}" -fi diff --git a/config/hypr/scripts/Toggle-Active-Window-Audio.sh b/config/hypr/scripts/Toggle-Active-Window-Audio.sh new file mode 100755 index 00000000..44370d10 --- /dev/null +++ b/config/hypr/scripts/Toggle-Active-Window-Audio.sh @@ -0,0 +1,97 @@ +#!/usr/bin/env bash +set -euo pipefail + +XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" +swayIconDir="${XDG_CONFIG_HOME}/swaync/icons" + +#// Credits to sl1ng for the orginal script. Rewritten by Vyle. +ctlcheck=("pactl" "jq" "notify-send" "awk" "pgrep" "hyprctl" "iconv") +missing=() + +for ctl in "${ctlcheck[@]}"; do + command -v "${ctl}" >/dev/null || missing+=("${ctl}") +done + +if (( ${#missing[@]} )) 2>/dev/null; then + echo "Missing required dependencies: \"${missing[*]}\"" + exit 1 +fi + +#// Parse .pid, .class, .title to __pid, __class, __title. +active_json="$(hyprctl -j activewindow 2>/dev/null || { echo -e "Did hyprctl fail to run? [EXIT-CODE:-1]"; exit 1; } )" +PID="$(jq -r '"\(.pid)\t\(.class)\t\(.title)"' <<< "${active_json}" || { echo -e "Did jq fail to run? [EXIT-CODE:-1]"; exit 1; } )" + +IFS=$'\t' read -r __pid __class __title <<< "${PID}" + +[[ -z "${__pid}" ]] && { echo -e "Could not resolve PID for focused window."; exit 1; } +sink_json="$(pactl -f json list sink-inputs 2>/dev/null | iconv -f utf-8 -t utf-8 -c || { echo -e "Did pactl or iconv fail to run? Required manual intervention."; exit 1; } )" + +#// Check if the __pid matches application.process.id or else verify other statements. +mapfile -t sink_ids < <(jq -r --arg pid "${__pid}" --arg class "${__class}" --arg title "${__title}" ' +.[] | + def lc(x): (x // "" | ascii_downcase); + def normalize(x): x | gsub("[-_~.]+";" ") ; + select( + (.properties["application.process.id"] // "") == $pid + or + (lc(.properties["application.name"]) | contains(lc($class))) + or + (lc(.properties["application.id"]) | contains(lc($class))) + or + (lc(.properties["application.process.binary"]) | contains(lc($class))) + or + (normalize(lc(.properties["media.name"])) | contains(normalize(lc($title)))) + ) | .index' <<< "${sink_json}" +) + +if [[ "${#sink_ids[@]}" -eq 0 ]]; then + fallback_pid="$(pgrep -x "${__class}" | head -n 1 || true)" + if [[ -n "${fallback_pid}" ]]; then + mapfile -t sink_ids < <( jq -r --arg pid "${fallback_pid}" '.[] | + select(.properties["application.process.id"] == $pid) | .index' <<< "${sink_json}" ) + fi +fi + +#// Auto-Detect if the environment is on Hyprland or $HYPRLAND_INSTANCE_SIGNATURE. +if [[ ${#sink_ids[@]} -eq 0 ]]; then + if [[ -n "${HYPRLAND_INSTANCE_SIGNATURE}" ]]; then + # Even if the fallback_pid remains empty, we will dispatch exit code based on $HYPRLAND_INSTANCE_SIGNATURE. + notify-send -a "t1" -r 91190 -t 1200 -i "${swayIconDir}/volume-low.png" "No sink input for the active_window: ${__class}" + echo "No sink input for focused window: ${__class}" + exit 1 + else + echo "No sink input for focused active_window ${__class}" + exit 1 + fi +fi + +idsJson=$(printf '%s\n' "${sink_ids[@]}" | jq -s 'map(tonumber)') + +#// Get the available option from pactl. +want_mute=$(jq -r --argjson ids "$idsJson" ' + [ .[] | select(.index as $i | $ids | index($i)) | .mute ] as $m | + if all($m[]; . == true) then "no" + else "yes" + end' <<< "${sink_json}" +) + +if [[ "${want_mute}" == "no" ]]; then + state_msg="Unmuted" + swayIcon="${swayIconDir}/volume-high.png" +else + state_msg="Muted" + swayIcon="${swayIconDir}/volume-mute.png" +fi + +[[ -f "${swayIcon}" ]] || echo -e "Missing swaync icons." + +for id in "${sink_ids[@]}"; do + pactl set-sink-input-mute "$id" "$want_mute" +done + +#// Append pamixer to get a nice result. Pamixer is complete optional here. +if command -v pamixer >/dev/null; then + notify-send -a "t2" -r 91190 -t 800 -i "${swayIcon}" "${state_msg} ${__class}" "$(pamixer --get-default-sink | awk -F '"' 'END{print $(NF - 1)}')" +else + notify-send -a "t2" -r 91190 -t 800 -i "${swayIcon}" "${state_msg} ${__class}" +fi -- cgit v1.2.3