Since one of the things that I do on a regular basis is playing a 1 hrs white noise sound file on loop I decided to not use my /usr/local/bin/ffplay-hide_banner-loop script with the file name again and again (and needing to either navigate via Thunar into the WhiteNoise/ folder or go via guest xfce4-terinal to the same WhiteNoise/ folder), thus I decided to create a script for doing just that.
The 1st version was in the folder the white noise sound files itself sits, but then I decided to move the script "Vintage 70s Hoover 1 hr.sh" itself into
/usr/local/bin/ as well, thus the only change needed was to add the full path of the sound file, and now it can be executed from any guest terminal, regardless of the current directory the terminal itself is in.
It adds the minimum of error checking (only checks if the target file exists, if the file exists but is no multimedia file then ffplay will most likely report an error and abort.)
Since this script uses the
true escape sequences that lets you use colours in the echo output even without using echo's -e parameter,
I cannot post the [ code ] itself here, since the escape character cannot be handled, thus you get it
as a mini module.
You will have to adjust the script, for the module I renamed "Vintage 70s Hoover 1 hr.sh" into Demo-ffplay-loop-sound.sh - but you have to
manually adjust the path and the sound file name since I cannot guess what you want that to be.
You need to adjust
Code: Select all
myfile="/mnt/sda2/sound/MyLoopSound.webm"
to a valid path and file name that suits your need.
else you only get this:
Code: Select all
guest@porteus:~$ Demo-ffplay-loop-sound.sh
/usr/local/bin/Demo-ffplay-loop-sound.sh -- fatal error: target file
/mnt/sda2/sound/MyLoopSound.webm
not found… aborting.
guest@porteus:~$
While by default the file /usr/local/bin/Demo-ffplay-loop-sound.sh is owned by root group root
it is not meant to be executed by root, so I added an extra check to prevent root from being the one running the script.
Trying to run the Demo script as user root you get this error only:
root@porteus:~# Demo-ffplay-loop-sound.sh
/usr/local/bin/Demo-ffplay-loop-sound.sh -- fatal error: Do not execute me as user root, or how ALSA puts it
ALSA: Couldn't open audio device: Connection refused
This could e.g. happen if you try to connect to a non-root PulseAudio as a root user, over the native protocol. Don't do that.
Here is the module:
https://filehorst.de/d/eFiAGHwd
The md5sum is like filehorst says it is: 212ec429aa7df9779800d4ca79dd1ff4
Since filehorst speaks German, a short HOWTO translation for downloading files:
To get it, first wait 15 seconds "
Dein Download wird jetzt vorbereitet." (Your download is being prepared)
Then click "
Jetzt zur Download-Seite" (Now to the download page)
Then click "
Dein Download steht nun bereit. Klicke hier, um ihn zu starten." (Your download is ready. Click here to start downloading it)
Downloads: 1 (4 kB) Zuletzt am: 16.11.2022 21:29 Uhr
Added in 1 day 10 hours 15 minutes 1 second:
Here an extract from my /usr/local/bin/echo.colors - more details about colours and other stuff (bold, flashing, right-aligned) since my above mini module only uses
bold+red and
bold+yellow.
I not use the true escape sequenzes here since you still cannot use these in a [
code
] segment, therefore the string variant is used.
Use these in a script e.g. like so:
(after first initializing the strings, of course)
Code: Select all
# initializing - demo - only bld red off
bld="\033[1m" # bold
red="\033[31m" # red
off="\033[m" # off
echo -e $bld${red}This is a warning or error message in bold+red.$off
echo this is again normal text.
or like this if you prefer:
Code: Select all
echo -e "$bld${red}This is a warning or error message in bold+red.$off
this is again normal text."
See for yourself:
Here now the more complete list of the codes as string variant
Code: Select all
# details also see man ls; man console_codes
bld="\033[1m" # bold
und="\033[4m" # underline
fla="\033[5m" # flashing (Cave! flashing works on some terminals but not on all!)
red="\033[31m" # red
gre="\033[32m" # green
yel="\033[33m" # yellow
blu="\033[34m" # blue
mag="\033[35m" # magenta
cya="\033[36m" # cyan
#spc="\033[60G" # aligned to the right (column 60)
off="\033[m" # off
# MORE THAN ONE IN ONE GO, e.g. red and bold like so:
# \033[01;31m
HTH.