From 4ee1bbf3b1ff83f954e323caf6f3ded444d0761c Mon Sep 17 00:00:00 2001 From: KKV9 Date: Sun, 28 Jan 2024 03:06:42 +0000 Subject: Move sounds to UserScripts Allow user to mute desktop sounds --- config/hypr/UserScripts/Sounds.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 config/hypr/UserScripts/Sounds.sh (limited to 'config/hypr/UserScripts') diff --git a/config/hypr/UserScripts/Sounds.sh b/config/hypr/UserScripts/Sounds.sh new file mode 100755 index 00000000..6bec1ea3 --- /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 -- cgit v1.2.3 From 80433d7fc5a69d9c44123d9768f4216d6275ab03 Mon Sep 17 00:00:00 2001 From: KKV9 Date: Sun, 28 Jan 2024 04:44:15 +0000 Subject: Allow Sounds script to find and change sound themes Sounds script allows user to mute or use any compatible freedesktop sound theme for desktop sound effects. This script will search in the home directory and system diretory for freedesktop sound themes to use. --- config/hypr/UserScripts/Sounds.sh | 47 ++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 8 deletions(-) (limited to 'config/hypr/UserScripts') diff --git a/config/hypr/UserScripts/Sounds.sh b/config/hypr/UserScripts/Sounds.sh index 6bec1ea3..1bcb181b 100755 --- a/config/hypr/UserScripts/Sounds.sh +++ b/config/hypr/UserScripts/Sounds.sh @@ -2,18 +2,49 @@ ## /* ---- 💫 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 +theme="freedesktop" # Set the theme for the system sounds. +muted=false # Set to true to mute the system sounds. +# Exit if the system sounds are muted. if [[ "$muted" = true ]]; then - exit 0 + exit 0 +fi + +# Set the directory defaults for system sounds. +userDIR="$HOME/.local/share/sounds" +systemDIR="/usr/share/sounds" +defaultTheme="freedesktop" + +# Prefer the user's theme, but use the system's if it doesn't exist. +sDIR="$systemDIR/$defaultTheme" +if [ -d "$userDIR/$theme" ]; then + sDIR="$userDIR/$theme" +elif [ -d "$systemDIR/$theme" ]; then + sDIR="$systemDIR/$theme" fi +# Get the theme that it inherits. +iTheme=$(cat "$sDIR/index.theme" | grep -i "inherits" | cut -d "=" -f 2) +iDIR="$sDIR/../$iTheme" + +# Choose the sound to play. if [[ "$1" == "--shutter" ]]; then - pw-play "$sDIR/camera-shutter.oga" + soundoption="camera-shutter.*" elif [[ "$1" == "--volume" ]]; then - pw-play "$sDIR/audio-volume-change.oga" + soundoption="audio-volume-change.*" +fi + +# Find the sound file and play it. +sound_file=$(find $sDIR/stereo -name "$soundoption" -print -quit) +if test -f "$sound_file"; then + pw-play "$sound_file" +else + sound_file=$(find $iDIR/stereo -name "$soundoption" -print -quit) + if test -f "$sound_file"; then + pw-play "$sound_file" + elif test -f "$userDIR/$defaultTheme/$soundoption"; then + pw-play "$userDIR/$defaultTheme/$soundoption" + else + pw-play "$systemDIR/$defaultTheme/$soundoption" + fi fi -- cgit v1.2.3 From 3a48d52e34f033ddf54e732749032c84e79825d6 Mon Sep 17 00:00:00 2001 From: KKV9 Date: Sun, 28 Jan 2024 17:25:01 +0000 Subject: Handle file not found error Add exit code 1 when no suitable file is found --- config/hypr/UserScripts/Sounds.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'config/hypr/UserScripts') diff --git a/config/hypr/UserScripts/Sounds.sh b/config/hypr/UserScripts/Sounds.sh index 1bcb181b..d7f08e43 100755 --- a/config/hypr/UserScripts/Sounds.sh +++ b/config/hypr/UserScripts/Sounds.sh @@ -45,6 +45,11 @@ else elif test -f "$userDIR/$defaultTheme/$soundoption"; then pw-play "$userDIR/$defaultTheme/$soundoption" else - pw-play "$systemDIR/$defaultTheme/$soundoption" + if test -f "$systemDIR/$defaultTheme/$soundoption"; then + pw-play "$systemDIR/$defaultTheme/$soundoption" + else + echo "Error: Sound file not found." + exit 1 + fi fi fi -- cgit v1.2.3 From b51fa2711196eb7ed2e42cd899defd1d233afd89 Mon Sep 17 00:00:00 2001 From: KKV9 Date: Sun, 28 Jan 2024 17:56:44 +0000 Subject: List arguments for Sounds.sh List arguments when no valid argument is given --- config/hypr/UserScripts/Sounds.sh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'config/hypr/UserScripts') diff --git a/config/hypr/UserScripts/Sounds.sh b/config/hypr/UserScripts/Sounds.sh index d7f08e43..ef62e3f4 100755 --- a/config/hypr/UserScripts/Sounds.sh +++ b/config/hypr/UserScripts/Sounds.sh @@ -32,6 +32,9 @@ if [[ "$1" == "--shutter" ]]; then soundoption="camera-shutter.*" elif [[ "$1" == "--volume" ]]; then soundoption="audio-volume-change.*" +else + echo -e "Available sounds: --shutter, --volume" + exit 0 fi # Find the sound file and play it. -- cgit v1.2.3 From a12faec054ccdff3faec2f82390c3b39f3816036 Mon Sep 17 00:00:00 2001 From: KKV9 Date: Sun, 28 Jan 2024 18:44:54 +0000 Subject: Check arguments before initialise Sounds.sh --- config/hypr/UserScripts/Sounds.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'config/hypr/UserScripts') diff --git a/config/hypr/UserScripts/Sounds.sh b/config/hypr/UserScripts/Sounds.sh index ef62e3f4..99ec9daa 100755 --- a/config/hypr/UserScripts/Sounds.sh +++ b/config/hypr/UserScripts/Sounds.sh @@ -10,6 +10,16 @@ if [[ "$muted" = true ]]; then exit 0 fi +# Choose the sound to play. +if [[ "$1" == "--shutter" ]]; then + soundoption="camera-shutter.*" +elif [[ "$1" == "--volume" ]]; then + soundoption="audio-volume-change.*" +else + echo -e "Available sounds: --shutter, --volume" + exit 0 +fi + # Set the directory defaults for system sounds. userDIR="$HOME/.local/share/sounds" systemDIR="/usr/share/sounds" @@ -27,16 +37,6 @@ fi iTheme=$(cat "$sDIR/index.theme" | grep -i "inherits" | cut -d "=" -f 2) iDIR="$sDIR/../$iTheme" -# Choose the sound to play. -if [[ "$1" == "--shutter" ]]; then - soundoption="camera-shutter.*" -elif [[ "$1" == "--volume" ]]; then - soundoption="audio-volume-change.*" -else - echo -e "Available sounds: --shutter, --volume" - exit 0 -fi - # Find the sound file and play it. sound_file=$(find $sDIR/stereo -name "$soundoption" -print -quit) if test -f "$sound_file"; then -- cgit v1.2.3 From 47101284b0b654eb0c83a1bd20725c7580eb87a0 Mon Sep 17 00:00:00 2001 From: KKV9 Date: Sun, 28 Jan 2024 20:08:38 +0000 Subject: Allow muting individual sounds Allow user to mute volume ONLY or screenshots ONLY. --- config/hypr/UserScripts/Sounds.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'config/hypr/UserScripts') diff --git a/config/hypr/UserScripts/Sounds.sh b/config/hypr/UserScripts/Sounds.sh index 99ec9daa..a2523a24 100755 --- a/config/hypr/UserScripts/Sounds.sh +++ b/config/hypr/UserScripts/Sounds.sh @@ -5,6 +5,10 @@ theme="freedesktop" # Set the theme for the system sounds. muted=false # Set to true to mute the system sounds. +# Mute individual sounds here. +mutedScreenshots=false +muteVolume=false + # Exit if the system sounds are muted. if [[ "$muted" = true ]]; then exit 0 @@ -12,8 +16,14 @@ fi # Choose the sound to play. if [[ "$1" == "--shutter" ]]; then + if [[ "$mutedScreenshots" = true ]]; then + exit 0 + fi soundoption="camera-shutter.*" elif [[ "$1" == "--volume" ]]; then + if [[ "$muteVolume" = true ]]; then + exit 0 + fi soundoption="audio-volume-change.*" else echo -e "Available sounds: --shutter, --volume" -- cgit v1.2.3 From ed716d91bc6c4f5ebca9bbfb24ceba48137538cc Mon Sep 17 00:00:00 2001 From: KKV9 Date: Sun, 28 Jan 2024 20:30:53 +0000 Subject: Use correct sound file for screen capture Use screen-capture instead of camera-shutter for screenshots --- config/hypr/UserScripts/Sounds.sh | 6 +++--- config/hypr/scripts/ScreenShot.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'config/hypr/UserScripts') diff --git a/config/hypr/UserScripts/Sounds.sh b/config/hypr/UserScripts/Sounds.sh index a2523a24..9aaafcf0 100755 --- a/config/hypr/UserScripts/Sounds.sh +++ b/config/hypr/UserScripts/Sounds.sh @@ -15,18 +15,18 @@ if [[ "$muted" = true ]]; then fi # Choose the sound to play. -if [[ "$1" == "--shutter" ]]; then +if [[ "$1" == "--screenshot" ]]; then if [[ "$mutedScreenshots" = true ]]; then exit 0 fi - soundoption="camera-shutter.*" + soundoption="screen-capture.*" elif [[ "$1" == "--volume" ]]; then if [[ "$muteVolume" = true ]]; then exit 0 fi soundoption="audio-volume-change.*" else - echo -e "Available sounds: --shutter, --volume" + echo -e "Available sounds: --screenshot, --volume" exit 0 fi diff --git a/config/hypr/scripts/ScreenShot.sh b/config/hypr/scripts/ScreenShot.sh index f56c58df..fa1b40ad 100755 --- a/config/hypr/scripts/ScreenShot.sh +++ b/config/hypr/scripts/ScreenShot.sh @@ -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." - "${sDIR}/Sounds.sh" --shutter + "${sDIR}/Sounds.sh" --screenshot 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." - "${sDIR}/Sounds.sh" --shutter + "${sDIR}/Sounds.sh" --screenshot else ${notify_cmd_shot} "Screenshot NOT Saved." fi @@ -91,7 +91,7 @@ shotactive() { shotswappy() { tmpfile=$(mktemp) - grim -g "$(slurp)" - >"$tmpfile" && "${sDIR}/Sounds.sh" --shutter && notify_view "swappy" + grim -g "$(slurp)" - >"$tmpfile" && "${sDIR}/Sounds.sh" --screenshot && notify_view "swappy" swappy -f - <"$tmpfile" rm "$tmpfile" } -- cgit v1.2.3 From 628364022eca36c2d02f13635c49b6c766622fea Mon Sep 17 00:00:00 2001 From: KKV9 Date: Sun, 28 Jan 2024 20:33:42 +0000 Subject: typo --- config/hypr/UserScripts/Sounds.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'config/hypr/UserScripts') diff --git a/config/hypr/UserScripts/Sounds.sh b/config/hypr/UserScripts/Sounds.sh index 9aaafcf0..bc27c92c 100755 --- a/config/hypr/UserScripts/Sounds.sh +++ b/config/hypr/UserScripts/Sounds.sh @@ -3,20 +3,20 @@ # This script is used to play system sounds. theme="freedesktop" # Set the theme for the system sounds. -muted=false # Set to true to mute the system sounds. +mute=false # Set to true to mute the system sounds. # Mute individual sounds here. -mutedScreenshots=false +muteScreenshots=false muteVolume=false # Exit if the system sounds are muted. -if [[ "$muted" = true ]]; then +if [[ "$mute" = true ]]; then exit 0 fi # Choose the sound to play. if [[ "$1" == "--screenshot" ]]; then - if [[ "$mutedScreenshots" = true ]]; then + if [[ "$muteScreenshots" = true ]]; then exit 0 fi soundoption="screen-capture.*" -- cgit v1.2.3 From e2c1144266279c6b522b4ff7e96f578f85b0fcbf Mon Sep 17 00:00:00 2001 From: KKV9 Date: Sun, 28 Jan 2024 21:06:07 +0000 Subject: Fix fallback sounds Fix Sounds.sh not finding files correctly. --- config/hypr/UserScripts/Sounds.sh | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'config/hypr/UserScripts') diff --git a/config/hypr/UserScripts/Sounds.sh b/config/hypr/UserScripts/Sounds.sh index bc27c92c..0d2bfff7 100755 --- a/config/hypr/UserScripts/Sounds.sh +++ b/config/hypr/UserScripts/Sounds.sh @@ -49,20 +49,17 @@ iDIR="$sDIR/../$iTheme" # Find the sound file and play it. sound_file=$(find $sDIR/stereo -name "$soundoption" -print -quit) -if test -f "$sound_file"; then - pw-play "$sound_file" -else +if ! test -f "$sound_file"; then sound_file=$(find $iDIR/stereo -name "$soundoption" -print -quit) - if test -f "$sound_file"; then - pw-play "$sound_file" - elif test -f "$userDIR/$defaultTheme/$soundoption"; then - pw-play "$userDIR/$defaultTheme/$soundoption" - else - if test -f "$systemDIR/$defaultTheme/$soundoption"; then - pw-play "$systemDIR/$defaultTheme/$soundoption" - else - echo "Error: Sound file not found." - exit 1 + if ! test -f "$sound_file"; then + sound_file=$(find $userDIR/$defaultTheme/stereo -name "$soundoption" -print -quit) + if ! test -f "$sound_file"; then + sound_file=$(find $systemDIR/$defaultTheme/stereo -name "$soundoption" -print -quit) + if ! test -f "$sound_file"; then + echo "Error: Sound file not found." + exit 1 + fi fi fi fi +pw-play "$sound_file" -- cgit v1.2.3