dotwryn/bin/play-sound

33 lines
998 B
Plaintext
Raw Normal View History

2022-02-06 07:15:14 +00:00
#!/bin/zsh
source "$HOME/.config/wryn/env.zsh"
2020-10-09 23:07:16 +00:00
which canberra-gtk-play >/dev/null 2>&1 || {
notify-send 'canberra-gtk-play' "unable to play '$1'; is canberra-gtk-play installed?"
exit 1
2020-10-09 23:07:16 +00:00
}
PLAY() { canberra-gtk-play -f "$SFX_PATH/$1"; }
SFX_FILE=''
2020-10-09 23:07:16 +00:00
case $1 in
volume ) SFX_FILE=yaru-message.oga ;;
mute ) SFX_FILE=smooth-dialog-warning.oga ;;
backlight ) SFX_FILE=yaru-audio-volume-change.oga ;;
login ) SFX_FILE=yaru-desktop-login.oga ;;
logout ) SFX_FILE=smooth-desktop-login.oga ;;
notify ) SFX_FILE=yaru-complete.oga ;;
undock ) SFX_FILE=yaru-desktop-login.oga ;;
homedock ) SFX_FILE=homedock.oga ;;
gamedock ) SFX_FILE=gamedock.oga ;;
* ) SFX_FILE="$1"
2022-02-06 07:15:14 +00:00
;;
2020-10-09 23:07:16 +00:00
esac
[ ! -f "$SFX_PATH/$SFX_FILE" ] && {
notify-send 'canberra-gtk-play' "no such sfx file or alias '$1'" \
exit 2
}
canberra-gtk-play -f "$SFX_PATH/$SFX_FILE" \
|| notify-send 'canberra-gtk-play' "unable to play '$1'"