aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/UserScripts
diff options
context:
space:
mode:
authorJa.KooLit <jimmielovejay@gmail.com>2024-02-14 05:22:34 +0900
committerGitHub <noreply@github.com>2024-02-14 05:22:34 +0900
commita160ceeab550d8fdefc0b19f6b3a0dd6c2784db8 (patch)
treebf2ebecab995012b984c931e2ec22d947897b4b3 /config/hypr/UserScripts
parent610a46e8fe3c5c0d0b292977b6015d9f858e5e98 (diff)
parente34165295e0856f9f14fffb4e323fb1f2e2220c9 (diff)
Merge pull request #158 from JaKooLit/development
Development to Main
Diffstat (limited to 'config/hypr/UserScripts')
-rwxr-xr-xconfig/hypr/UserScripts/Sounds.sh65
1 files changed, 65 insertions, 0 deletions
diff --git a/config/hypr/UserScripts/Sounds.sh b/config/hypr/UserScripts/Sounds.sh
new file mode 100755
index 00000000..0d2bfff7
--- /dev/null
+++ b/config/hypr/UserScripts/Sounds.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+## /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ##
+# This script is used to play system sounds.
+
+theme="freedesktop" # Set the theme for the system sounds.
+mute=false # Set to true to mute the system sounds.
+
+# Mute individual sounds here.
+muteScreenshots=false
+muteVolume=false
+
+# Exit if the system sounds are muted.
+if [[ "$mute" = true ]]; then
+ exit 0
+fi
+
+# Choose the sound to play.
+if [[ "$1" == "--screenshot" ]]; then
+ if [[ "$muteScreenshots" = true ]]; then
+ exit 0
+ fi
+ soundoption="screen-capture.*"
+elif [[ "$1" == "--volume" ]]; then
+ if [[ "$muteVolume" = true ]]; then
+ exit 0
+ fi
+ soundoption="audio-volume-change.*"
+else
+ echo -e "Available sounds: --screenshot, --volume"
+ 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"
+
+# Find the sound file and play it.
+sound_file=$(find $sDIR/stereo -name "$soundoption" -print -quit)
+if ! test -f "$sound_file"; then
+ sound_file=$(find $iDIR/stereo -name "$soundoption" -print -quit)
+ 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"
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage