#!/usr/bin/sh # @author nate zhou # @since 2024,2025,2026 # use a dynamic menu to select the audio source for voice recording RECORD_HOME="${HOME}/tmp/recordings" [ -d "$RECORD_HOME" ] || mkdir -p $RECORD_HOME menu="" if [ "$XDG_SESSION_TYPE" = "wayland" ]; then menu="${HOME}/.local/bin/wmenu-color -l5 -p" elif [ -n "$XAUTHORITY" ]; then menu="dmenu -l 5 -p" else menu="fzf --prompt" fi filename="${RECORD_HOME}/$(date +%Y-%m-%d_%H_%M_%S).mp3" notifyStart() { notify-send -u low -r 1258 "$(basename "$0")" "on $source" } notifyStop() { notify-send -u low -r 1258 "$(basename "$0")" "stopped $source" } setSource() { pactl list short sources | awk '{print $2}' | sort \ | $menu '[choose source]' } source="$(setSource)" [ -z "$source" ] && exit 0 notifyStart trap notifyStop EXIT INT TERM pw-record --target "$source" "$filename"