diff options
| author | KKV9 <ciaranob.cob@gmail.com> | 2024-01-28 04:44:15 +0000 |
|---|---|---|
| committer | KKV9 <ciaranob.cob@gmail.com> | 2024-01-28 04:44:15 +0000 |
| commit | 80433d7fc5a69d9c44123d9768f4216d6275ab03 (patch) | |
| tree | 3c33fc1145f042652a922dbeab1f26ee31bb5677 /config/hypr/UserScripts | |
| parent | 4ee1bbf3b1ff83f954e323caf6f3ded444d0761c (diff) | |
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.
Diffstat (limited to 'config/hypr/UserScripts')
| -rwxr-xr-x | config/hypr/UserScripts/Sounds.sh | 47 |
1 files changed, 39 insertions, 8 deletions
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 |
