From 5b40716ab9c1c3ca0d91185e00856245fc1f9ed4 Mon Sep 17 00:00:00 2001 From: JaKooLit Date: Mon, 29 Apr 2024 08:24:48 +0900 Subject: moving of Sounds.sh from UserScripts to scripts. --- config/hypr/UserScripts/Sounds.sh | 69 -------------------------------------- config/hypr/scripts/ScreenShot.sh | 2 +- config/hypr/scripts/Sounds.sh | 70 +++++++++++++++++++++++++++++++++++++++ config/hypr/scripts/Volume.sh | 2 +- 4 files changed, 72 insertions(+), 71 deletions(-) delete mode 100755 config/hypr/UserScripts/Sounds.sh create mode 100755 config/hypr/scripts/Sounds.sh diff --git a/config/hypr/UserScripts/Sounds.sh b/config/hypr/UserScripts/Sounds.sh deleted file mode 100755 index fb8a1f57..00000000 --- a/config/hypr/UserScripts/Sounds.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/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. -if [ -d "/run/current-system/sw/share/sounds" ]; then - systemDIR="/run/current-system/sw/share/sounds" # NixOS -else - systemDIR="/usr/share/sounds" -fi -userDIR="$HOME/.local/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" \ No newline at end of file diff --git a/config/hypr/scripts/ScreenShot.sh b/config/hypr/scripts/ScreenShot.sh index 309114dc..d2ee51a2 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="$HOME/.config/hypr/UserScripts" +sDIR="$HOME/.config/hypr/scripts" 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") diff --git a/config/hypr/scripts/Sounds.sh b/config/hypr/scripts/Sounds.sh new file mode 100755 index 00000000..a749114c --- /dev/null +++ b/config/hypr/scripts/Sounds.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## +# This script is used to play system sounds. +# Script is used by Volume.Sh and ScreenShots.sh + +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. +if [ -d "/run/current-system/sw/share/sounds" ]; then + systemDIR="/run/current-system/sw/share/sounds" # NixOS +else + systemDIR="/usr/share/sounds" +fi +userDIR="$HOME/.local/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" \ No newline at end of file diff --git a/config/hypr/scripts/Volume.sh b/config/hypr/scripts/Volume.sh index d2fef87e..19868caf 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="$HOME/.config/hypr/UserScripts" +sDIR="$HOME/.config/hypr/scripts" # Get Volume get_volume() { -- cgit v1.2.3