Oh man, I sat the whole night writing a little bash script for logging manually for me for the time waiting and finally I got it working. Lot of new stuff I had to wrap my head around. Didn’t reckon that you would be so fast
. However it was a nice exercise for me as a newbie. Perhaps someone has a use for it, since it’s pretty versatile to take quick notes and has some nice functionallity, like display of the last three entries in declining order and the ability to delete the last entry from the logfile. It doesn’t scroll down thanks to ‘tput’ prompt-manipulation (I not nearly understand all the features of it yet, but it’s quite fun to fiddle around with it.)
Pro tip: Use with Lolcat! ( scriptname.sh | lolcat )
I look forward to try your new version as soon as possible. Thanks for beeing so approachable for suggestions!
#!/bin/bash
# # # # # # # # # # # # # # # # # # # # # # # # # #
# · · · · · · · · · · · · · · · · · · · · · · · · #
# · · Manual logging-script for PyRadio:· · · · · #
# · ·¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ · · `ovo´· #
# · · · · · · · · · · · · · · · · · · · · /(_)\· #
# · · · · · · · · · · · · · · · · · · · · … … · #
# # Faehnchen Apr. 15, 2022 # # # # # # # # # # # #
# A little script to take notes with a time stamp in the terminal
# ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
# Currently there is no feature in PyRadio to pipe information of a music stream like song/
#+ band/programm into a logfile or even copy text from the application. So I wrote this little
#+ script to help me at least a little bit with that for the while. Just execute alongside PyRa-
#+ dio or any other activity you think you might need notes with a timestamp from.
# Also, change it to your liking and use it to log when you saw a particularly beautiful
#+ bird or you have to remember at which hour your annoying neighbor heard loud music!
# Have fun and special thanks again to Spiros Georgaras, the creator and maintainer of
#+ PyRadio!
# Change these variables to use script universally
FILEPATH="$HOME/.config/pyradio/pyradio_favourites.list"
TEMPFILE="$HOME/.config/pyradio/pyr_fav.tmp"
ls "$FILEPATH"
favlist=$?
clear
sleep 0.5
# Automatc creation when executing for the first time or logfile was renamed
if [ $favlist -ne 0 ]; then
echo -e "\n\033[0m No default list-file detected."
echo -e "\n Resume and create a new PyRadio-favourites-list"
echo -e " in: ~/.config/pyradio/pyradio-favourites.list ? \n"
echo -n " ›r‹ resume | ›ANY KEY‹ quit > "
read resume
if [[ $resume != [r] ]]; then
exit 0
fi
clear
echo -e "\n Done! Start $NAME . . ."
touch "$FILEPATH"
sleep 2
fi
touch "$TEMPFILE"
clear
echo -e "\n Which radio station are you currently listening to? \n "
echo -n " ›ENTER‹ to skip > "
read station
# Prompt for input (don't use 'Tab'-key and a too small window! It scrambles the output pretty much.)
clear
echo -e "\033[0m ›ENTER‹ add to list | ›x‹ delete last entry | ›q‹ quit"
echo -e "\033[1;32m Your - note ↑ ↑ ↑ \033[0m "
echo -e "\033[1;32m ¯¯¯¯¯¯¯¯¯¯¯ \033[0m "
count=1
while [[ $count > 0 ]]; do
echo -n " > "
read note
tput el
tput cuu 1
tput el
case $note in
x) # Delete function
head -n -1 "$FILEPATH" > "$TEMPFILE"
cat "$TEMPFILE" > "$FILEPATH"
sleep 0.3
tput cud 1
tput el
echo " deleted '$note1'."
tput cuu 2
tput sc
;;
q) # Quit from the script
sleep 0.3
echo -e " Your entries added to > \n ~/.config/pyradio/pyradio/pyradio-favourites.list"
printf "%-s (%10s) \n" "=======QUIT=======" "$station" >> "$FILEPATH"
tput cud 4
rm "$TEMPFILE"
wait; exit 0
;;
*)
dtime=`date +"%Y-%m-%d %H:%M"`
printf "[%-16s] %2d) %-s\n" "$dtime" $count "$note" >> "$FILEPATH"
#---Show last three entries in declining order---------------
note3="$note2"
count3=$count2
tput cud 5
tput el
printf "\r\033[36m %3d. %-s \033[0m\n " $count2 "$note2"
tput cuu 6
#---------------------------------------------------------3---
note2="$note1"
count2=$count1
tput cud 4
tput el
printf "\r\033[36m %3d. %-s \033[0m\n " $count1 "$note1"
tput cuu 5
#---------------------------------------------------------2---
note1="$note"
count1=$count
tput cud 3
tput el
printf "\r\033[36m %3d. %-s \033[0m\n " $count "$note"
tput cuu 4
#---------------------------------------------------------1---
;;
esac
count=$(( $count+1 ))
sleep 0.3
done
exit 1

