Browse Source

Merge pull request #143 from KKV9/development

Feat: Add freedesktop sound themes
pull/146/head
Ja.KooLit 2 years ago committed by GitHub
parent
commit
24d2811134
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 65
      config/hypr/UserScripts/Sounds.sh
  2. 2
      config/hypr/configs/Keybinds.conf
  3. 16
      config/hypr/scripts/ScreenShot.sh
  4. 2
      config/hypr/scripts/Volume.sh

65
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"

2
config/hypr/configs/Keybinds.conf

@ -78,7 +78,7 @@ bind = $mainMod ALT, Print, exec, $scriptsDir/ScreenShot.sh --in10 #screenshot i
bind = ALT, Print, exec, $scriptsDir/ScreenShot.sh --active #screenshot in 10 secs
# screenshot with swappy (another screenshot tool)
bind = $mainMod SHIFT, S, exec, grim -g "$(slurp)" - | swappy -f -
bind = $mainMod SHIFT, S, exec, $scriptsDir/ScreenShot.sh --swappy
# Resize windows
binde = $mainMod SHIFT, left, resizeactive,-50 0

16
config/hypr/scripts/ScreenShot.sh

@ -3,6 +3,7 @@
# Screenshots scripts
iDIR="$HOME/.config/swaync/icons"
sDIR="$HOME/.config/hypr/UserScripts"
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")
@ -18,13 +19,17 @@ notify_view() {
if [[ "$1" == "active" ]]; then
if [[ -e "${active_window_path}" ]]; then
${notify_cmd_shot} "Screenshot of '${active_window_class}' Saved."
"${sDIR}/Sounds.sh" --screenshot
else
${notify_cmd_shot} "Screenshot of '${active_window_class}' not Saved"
fi
elif [[ "$1" == "swappy" ]]; then
${notify_cmd_shot} "Screenshot Captured."
else
local check_file="$dir/$file"
if [[ -e "$check_file" ]]; then
${notify_cmd_shot} "Screenshot Saved."
"${sDIR}/Sounds.sh" --screenshot
else
${notify_cmd_shot} "Screenshot NOT Saved."
fi
@ -84,6 +89,13 @@ shotactive() {
notify_view "active"
}
shotswappy() {
tmpfile=$(mktemp)
grim -g "$(slurp)" - >"$tmpfile" && "${sDIR}/Sounds.sh" --screenshot && notify_view "swappy"
swappy -f - <"$tmpfile"
rm "$tmpfile"
}
if [[ ! -d "$dir" ]]; then
mkdir -p "$dir"
@ -101,8 +113,10 @@ elif [[ "$1" == "--area" ]]; then
shotarea
elif [[ "$1" == "--active" ]]; then
shotactive
elif [[ "$1" == "--swappy" ]]; then
shotswappy
else
echo -e "Available Options : --now --in5 --in10 --win --area --active"
echo -e "Available Options : --now --in5 --in10 --win --area --active --swappy"
fi
exit 0

2
config/hypr/scripts/Volume.sh

@ -3,6 +3,7 @@
# Scripts for volume controls for audio and mic
iDIR="$HOME/.config/swaync/icons"
sDIR="$HOME/.config/hypr/UserScripts"
# Get Volume
get_volume() {
@ -34,6 +35,7 @@ notify_user() {
notify-send -e -h string:x-canonical-private-synchronous:volume_notif -u low -i "$(get_icon)" "Volume: Muted"
else
notify-send -e -h int:value:"$(get_volume | sed 's/%//')" -h string:x-canonical-private-synchronous:volume_notif -u low -i "$(get_icon)" "Volume: $(get_volume)"
"$sDIR/Sounds.sh" --volume
fi
}

Loading…
Cancel
Save