From e78cd1abd99ae8060a2b32e9fb1150368099f979 Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Fri, 7 Oct 2022 19:42:19 -0400 Subject: [PATCH] soundboard: make things more organised --- src/.config/fish/config.fish | 1 + src/.config/sxhkd/sxhkdrc | 29 ++++++++++++------- .../bin/deskutils/notification-sound.sh | 4 +++ src/.local/bin/deskutils/soundboard/sb-msg | 7 +++++ src/.profile | 3 ++ 5 files changed, 33 insertions(+), 11 deletions(-) create mode 100755 src/.local/bin/deskutils/soundboard/sb-msg diff --git a/src/.config/fish/config.fish b/src/.config/fish/config.fish index 0e00d8e..dd94e35 100644 --- a/src/.config/fish/config.fish +++ b/src/.config/fish/config.fish @@ -12,6 +12,7 @@ gpgt # Add .local/bin to path set -gx PATH "$PATH:$HOME/.local/bin:" set -gx PATH "$PATH:$HOME/.local/bin/deskutils:" +set -gx PATH "$PATH:$HOME/.local/bin/deskutils/soundboard:" set -gx PATH "$PATH:$HOME/.local/bin/minrss-scripts:" # Disable fish greeting diff --git a/src/.config/sxhkd/sxhkdrc b/src/.config/sxhkd/sxhkdrc index d43ce4e..c58cce1 100644 --- a/src/.config/sxhkd/sxhkdrc +++ b/src/.config/sxhkd/sxhkdrc @@ -1,22 +1,29 @@ # Soundboard setup -# "Boxes" labelled 0-9 in ~/med/sb2/ +# "Boxes" labelled 0-9 in $SB_DIR/ # Each one has files/symlinks 0-9 +# change dir super + {0-9} - unlink ~/med/sb/cur;\ - ln -sr ~/med/sb/{0-9} ~/med/sb/cur;\ - rm /tmp/sb-socket* + unlink $SB_DIR/cur;\ + ln -sr $SB_DIR/{0-9} $SB_DIR/cur +# start sound KP_{Insert,End,Down,Next,Left,Begin,Right,Home,Up,Prior} snd_id="{0-9}";\ id=$(cat /dev/random | base32 | head -c 5);\ - socket="/tmp/sb-socket$snd_id-$id";\ - mpv --input-ipc-server=$socket ~/med/sb/cur/$snd_id*;\ - rm $socket + socket="$SB_DIR/cur/sb-socket$snd_id-$id";\ + mpv --input-ipc-server=$socket $SB_DIR/cur/$snd_id*;\ + rm -f "$socket" +# stop specific sound shift + KP_{Insert,End,Down,Next,Left,Begin,Right,Home,Up,Prior} snd_id="{0-9}";\ - ls /tmp/sb-socket$snd_id-* |\ - while read -r socket; do \ - echo {"stop"} | socat - $socket;\ - done + ls $SB_DIR/cur/sb-socket$snd_id-* | sb-msg "stop" + +# stop all sounds in current dir +KP_Delete + ls $SB_DIR/cur/sb-socket* | stop.sh + +# stop all sounds +shift + KP_Delete + find $SB_DIR/ -name "sb-socket*" | sb-msg "stop" diff --git a/src/.local/bin/deskutils/notification-sound.sh b/src/.local/bin/deskutils/notification-sound.sh index f8a1683..adf2f39 100755 --- a/src/.local/bin/deskutils/notification-sound.sh +++ b/src/.local/bin/deskutils/notification-sound.sh @@ -2,6 +2,10 @@ # Dunst notification sound script. +if [ $DUNST_URGENCY = "LOW" ]; then + exit +fi + if pactl list short sinks | grep -q virtual_mic; then mpv ~/.local/bin/deskutils/notif.wav --audio-device=pulse/c1_out else diff --git a/src/.local/bin/deskutils/soundboard/sb-msg b/src/.local/bin/deskutils/soundboard/sb-msg new file mode 100755 index 0000000..cd6f51e --- /dev/null +++ b/src/.local/bin/deskutils/soundboard/sb-msg @@ -0,0 +1,7 @@ +#!/bin/sh +# Given a list of mpv sockets through stdin, send a message to all of them + +while read -r socket; do + printf "$1\n" | socat - $socket + rm "$socket" +done diff --git a/src/.profile b/src/.profile index 998b3e2..ad56ad7 100644 --- a/src/.profile +++ b/src/.profile @@ -4,6 +4,7 @@ export XDG_CONFIG_HOME="$HOME"/.config export XDG_CACHE_HOME="$HOME"/.cache export XDG_DATA_HOME="$HOME"/.local/share +export XDG_DOWNLOAD_DIR="$HOME"/quar/ # Clean up home directory dotfiles @@ -35,6 +36,8 @@ export BROWSER="qutebrowser" export MANPAGER='nvim +Man!' export MANWIDTH=999 +# Soundboard +export SB_DIR="$HOME"/med/sb export SXHKD_SHELL='/bin/sh' # Variables for passphrase2pgp