From 4ee1bbf3b1ff83f954e323caf6f3ded444d0761c Mon Sep 17 00:00:00 2001 From: KKV9 Date: Sun, 28 Jan 2024 03:06:42 +0000 Subject: [PATCH] Move sounds to UserScripts Allow user to mute desktop sounds --- config/hypr/UserScripts/Sounds.sh | 19 +++++++++++++++++++ config/hypr/scripts/ScreenShot.sh | 8 ++++---- config/hypr/scripts/Volume.sh | 4 ++-- 3 files changed, 25 insertions(+), 6 deletions(-) create mode 100755 config/hypr/UserScripts/Sounds.sh diff --git a/config/hypr/UserScripts/Sounds.sh b/config/hypr/UserScripts/Sounds.sh new file mode 100755 index 0000000..6bec1ea --- /dev/null +++ b/config/hypr/UserScripts/Sounds.sh @@ -0,0 +1,19 @@ +#!/bin/bash +## /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## +# This script is used to play system sounds. + +# Set the directory for system sounds. +sDIR="/usr/share/sounds/freedesktop/stereo" + +# Set to true to mute the system sounds. +muted=false + +if [[ "$muted" = true ]]; then + exit 0 +fi + +if [[ "$1" == "--shutter" ]]; then + pw-play "$sDIR/camera-shutter.oga" +elif [[ "$1" == "--volume" ]]; then + pw-play "$sDIR/audio-volume-change.oga" +fi diff --git a/config/hypr/scripts/ScreenShot.sh b/config/hypr/scripts/ScreenShot.sh index 1cec086..3fb2580 100755 --- a/config/hypr/scripts/ScreenShot.sh +++ b/config/hypr/scripts/ScreenShot.sh @@ -3,7 +3,7 @@ # Screenshots scripts iDIR="$HOME/.config/swaync/icons" -sDIR="/usr/share/sounds/freedesktop/stereo" +sDIR="$HOME/.config/hypr/UserScripts" notify_cmd_shot="notify-send -h string:x-canonical-private-synchronous:shot-notify -u low -i ${iDIR}/picture.png" time=$(date "+%d-%b_%H-%M-%S") @@ -19,7 +19,7 @@ notify_view() { if [[ "$1" == "active" ]]; then if [[ -e "${active_window_path}" ]]; then ${notify_cmd_shot} "Screenshot of '${active_window_class}' Saved." - pw-play "${sDIR}/camera-shutter.oga" + "${sDIR}/Sounds.sh" --shutter else ${notify_cmd_shot} "Screenshot of '${active_window_class}' not Saved" fi @@ -29,7 +29,7 @@ notify_view() { local check_file="$dir/$file" if [[ -e "$check_file" ]]; then ${notify_cmd_shot} "Screenshot Saved." - pw-play "${sDIR}/camera-shutter.oga" + "${sDIR}/Sounds.sh" --shutter else ${notify_cmd_shot} "Screenshot NOT Saved." fi @@ -92,7 +92,7 @@ shotactive() { shotswappy() { tmpfile=$(mktemp) - grim -g "$(slurp)" - >"$tmpfile" && pw-play "${sDIR}/camera-shutter.oga" && notify_view "swappy" + grim -g "$(slurp)" - >"$tmpfile" && "${sDIR}/Sounds.sh" --shutter && notify_view "swappy" swappy -f - <"$tmpfile" rm "$tmpfile" } diff --git a/config/hypr/scripts/Volume.sh b/config/hypr/scripts/Volume.sh index 8322e29..8c5af5d 100755 --- a/config/hypr/scripts/Volume.sh +++ b/config/hypr/scripts/Volume.sh @@ -3,7 +3,7 @@ # Scripts for volume controls for audio and mic iDIR="$HOME/.config/swaync/icons" -sDIR="/usr/share/sounds/freedesktop/stereo" +sDIR="$HOME/.config/hypr/UserScripts" # Get Volume get_volume() { @@ -35,7 +35,7 @@ notify_user() { notify-send -e -h string:x-canonical-private-synchronous:volume_notif -u low -i "$(get_icon)" "Volume: Muted" else notify-send -e -h int:value:"$(get_volume | sed 's/%//')" -h string:x-canonical-private-synchronous:volume_notif -u low -i "$(get_icon)" "Volume: $(get_volume)" - pw-play "$sDIR/audio-volume-change.oga" + "$sDIR/Sounds.sh" --volume fi }