aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/UserScripts/Sounds.sh
blob: d7f08e438fd28e0689bbc1553d94d7a58e8e0f2b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
## /* ---- 💫 https://github.com/JaKooLit 💫 ---- */  ##
# 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.

# Exit if the system sounds are muted.
if [[ "$muted" = true ]]; then
    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
    soundoption="camera-shutter.*"
elif [[ "$1" == "--volume" ]]; then
    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
        if test -f "$systemDIR/$defaultTheme/$soundoption"; then
            pw-play "$systemDIR/$defaultTheme/$soundoption"
        else
            echo "Error: Sound file not found."
            exit 1
        fi
    fi
fi
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage