summaryrefslogtreecommitdiffstats
path: root/.scripts/audio
blob: 2e52e08fb547b4fc5051dcbecf8b7314800f913a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash

# This script records audio.
# It runs an appropriate record script for either ALSA and Pulseaudio.
# It also names files smartly to prevent overwrites.

# Picks a file name for the output file based on availability:
while [[ -f $HOME/audio$n.flac ]]
do
	n=$((n+1))
done
filename="$HOME/audio$n.flac"

# For Pulseaudio with ALSA:
record_pulse() { \
ffmpeg \
-f alsa -i default \
-c:a flac \
$filename ;}

# For ALSA:
record_alsa() { \
ffmpeg -y \
-f alsa -ar 44100 -i hw:1 \
$filename ;}

if [[ $(pgrep -x pulseaudio) ]]; then record_pulse; else record_alsa; fi &
# Updating i3blocks recording icon:
echo 🎙️ > ~/.recordingicon && pkill -RTMIN+9 i3blocks