Thanks @nas!
However, I still have the annoying startup icon hovering for about 10 seconds whenever I start and stop the script. Is there any way to be rid if that?
Also, parec does not record in mp3 format, but rather in raw format. One needs to pipe it through lame to get mp3 output. Here is another version of the script. The echo lines are useful if you start/stop the script from the terminal.
#!/bin/sh if [ -n "$(ps -e | grep parec)" ]; then killall parec; pacmd set-source-volume source.droid 65536; echo -e "\033[32;1;4mrecording stopped.\033[0m" exit 0; fi mkdir -p /home/nemo/lydfiler pacmd set-source-volume source.droid 229376 parec | lame -r - /home/nemo/lydfiler/$(date +%d-%m-%H:%M).mp3 & echo -e "\033[31;1;4mrecording started ...\033[0m"