Ravas coding goodies

For discussions about programming and projects not necessarily associated with Porteus.
User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Ravas coding goodies

Post#76 by Ed_P » 30 Jan 2022, 23:40

Rava wrote:
30 Jan 2022, 18:44
I think I will go with alarm-beeping.sh instead.
How about alert.sh? Or beep-alert.sh? :hmmm:
Rava wrote:
30 Jan 2022, 18:44
I have to prepare some stuff for a meeting tomorrow.
What is it that you do?
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Ravas coding goodies

Post#77 by Rava » 31 Jan 2022, 15:15

Since filehorst speaks German, a short HOWTO download and translation:

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)

https://filehorst.de/download.php?file=esJEfEGI

Code: Select all

# lsxzm alarm+beep+notifications.mp3.xzm 
/usr
/usr/local
/usr/local/bin
/usr/local/bin/alarm.sh
/usr/local/bin/beep
/usr/local/bin/beep2
/usr/local/share
/usr/local/share/notification_-12dB.mp3
/usr/local/share/notification_-15dB.mp3
md5sum
3ffcd76cd8ada71127d41cf7e92e0f9d alarm+beep+notifications.mp3.xzm

Size: 8192 bytes
(it contains two mp3 files, and these are hard to compress any further…)

Added in 5 hours 9 minutes 45 seconds:
What I forgot to add. I changed the script (previously named daueralarm.sh) alarm.sh from using mpv to now also using mpg123:
The line that executes the player with the sound file in all scripts is this:

Code: Select all

root@porteus:/Porteus_modules/dir2xzm/usr/local/bin# grep mpg *
alarm.sh:	mpg123 "$soundfile" >/dev/null 2>&1
beep:    mpg123 "$soundfile" >/dev/null 2>&1
beep2:    mpg123 "$soundfile" >/dev/null 2>&1
As you also can see, it eliminates all other output, be it normal or error output.

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Ravas coding goodies

Post#78 by Ed_P » 31 Jan 2022, 23:41

Got it. (Glad I waited :D ) Will try the next time I boot Porteus.

Added in 8 hours 4 minutes 27 seconds:
Ok, what am I doing wrong?? :%)

Code: Select all

guest@porteus:~$ alarm.sh
daueralarm.sh V1.3 - sound file is /usr/local/share/notification_-15dB.mp3
pause length: 2 seconds - Aboard with Strg+C








^C
guest@porteus:~$ alarm.sh 1
daueralarm.sh V1.3 - sound file is /usr/local/share/notification_-15dB.mp3
pause length: 2 seconds - Aboard with Strg+C
^C
guest@porteus:~$ alarm.sh 5
daueralarm.sh V1.3 - sound file is /usr/local/share/notification_-15dB.mp3
pause length: 5 seconds - Aboard with Strg+C
^C
guest@porteus:~$ 
I hear no sound and my volume is set to 46%.

I Aborted the script with Ctrl+c.
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Ravas coding goodies

Post#79 by Rava » 01 Feb 2022, 07:57

Ed_P wrote:
01 Feb 2022, 07:46
Ok, what am I doing wrong?? :%)

Code: Select all

[…]
guest@porteus:~$ ls /mnt/live/memory/images
000-kernel.xzm/
001-core.xzm/
002-xorg.xzm/
002-xtra.xzm/
003-cinnamon-20220118.xzm/
004-brave-browser-1.34.81-linux-amd64.xzm/
07-printing-x86_64-2021-11-07.xzm/
firefox-94.0.2-x86_64-en-US.xzm/
keepassx-2.0.3-x86_64-bundle.xzm/
kernel-firmware-20211229_57d6b95-noarch-1.xzm/
mychanges.xzm/
guest@porteus:~$
Looks like you just forgot to activate alarm+beep+notifications.mp3.xzm

As I recall, you usually not have the extracted modules on your hard drive (aka in somewhere/porteus/base/ ) but you use custom-made ISOs?

I presume you either added the module to the wrong ISO, or not added the module to the ISO and forgot to manually activate it after bootup.

The base folder of my module is owned by root but readable and executable by everyone:

Code: Select all

root@porteus:/Porteus_modules/dir2xzm# ls -lad . usr/
drwxr-xr-x 3 root root 4096 Jan 31 14:41 .
drwxr-xr-x 3 root root 4096 Jan 31 14:41 usr/
root@porteus:/Porteus_modules/dir2xzm# stat usr/
  File: usr/
  Size: 4096      	Blocks: 8          IO Block: 4096   directory
Device: 8,5	Inode: 1193874     Links: 3
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-01-31 14:41:51.261390437 +0100
Modify: 2022-01-31 14:41:51.266390375 +0100
Change: 2022-01-31 14:41:51.266390375 +0100
 Birth: 2022-01-31 14:41:51.261390437 +0100
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Ravas coding goodies

Post#80 by Ed_P » 01 Feb 2022, 08:06

We crossed posted. See my updated one above.
Rava wrote:
01 Feb 2022, 07:57
Looks like you just forgot to activate alarm+beep+notifications.mp3.xzm

As I recall, you usually not have the extracted modules on your hard drive (aka in somewhere/porteus/base/ ) but you use custom-made ISOs?
Yes, I screwed up and activated the wrong module.

Yes, I boot ISOs but my Modules and Optional folders, and changes folder, are on my harddrive.
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Ravas coding goodies

Post#81 by Rava » 01 Feb 2022, 08:22

Ed_P wrote:
01 Feb 2022, 08:06
We crossed posted. See my updated one above.
Hmmm… do you have mpg123 in your system?

Maybe edit one of the scripts and remove the error handling, best not the loop one in alarm.sh since text output makes it quite messy (due to the loop), but use beep or beep2 as testing victim.

Aka from

Code: Select all

mpg123 "$soundfile" >/dev/null 2>&1
to

Code: Select all

mpg123 "$soundfile" # >/dev/null 2>&1
and report what beep or beep2 says.

Or just execute this as guest:

Code: Select all

mpg123 /usr/local/share/notification_-12dB.mp3
Doing so, I get this (aside from the sound played):

Code: Select all

guest@porteus:~$ mpg123 /usr/local/share/notification_-12dB.mp3 
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
	version 1.29.2; written and copyright by Michael Hipp and others
	free software (LGPL) without any warranty but with best wishes

Directory: /usr/local/share/

Terminal control enabled, press 'h' for listing of keys and functions.

Playing MPEG stream 1 of 1: notification_-12dB.mp3 ...

MPEG 1.0 L III cbr128 44100 mono

[0:00] Decoding of notification_-12dB.mp3 finished.
guest@porteus:~$ 
I can also look if I still have the original notification.wav somewhere, and I can make an volume-unchanged notification.mp3 out of it and share it.

I did reduce the volume of both since usually my sound is set a bit higher cause when you use ffplay for playing almost all sound containing files (as : aac, mp3 and all video files) you can decrease the sound, but unlike mpv, you cannot increase the sound past the 100% when using ffplay.
And since some video files have the sound volume lowered, I use as default 75% volume via APPEND cheatcode in my porteus.cfg

Code: Select all

volume=75%
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Ravas coding goodies

Post#82 by Ed_P » 01 Feb 2022, 08:34

I tried it twice.

Code: Select all

guest@porteus:~$ mpg123 /usr/local/share/notification_-12dB.mp3
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
	version 1.29.3; written and copyright by Michael Hipp and others
	free software (LGPL) without any warranty but with best wishes

Directory: /usr/local/share/

Terminal control enabled, press 'h' for listing of keys and functions.

Playing MPEG stream 1 of 1: notification_-12dB.mp3 ...

MPEG 1.0 L III cbr128 44100 mono

[0:00] Decoding of notification_-12dB.mp3 finished.
guest@porteus:~$ mpg123 /usr/local/share/notification_-12dB.mp3
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
	version 1.29.3; written and copyright by Michael Hipp and others
	free software (LGPL) without any warranty but with best wishes

Directory: /usr/local/share/

Terminal control enabled, press 'h' for listing of keys and functions.

Playing MPEG stream 1 of 1: notification_-12dB.mp3 ...

MPEG 1.0 L III cbr128 44100 mono

[0:00] Decoding of notification_-12dB.mp3 finished.
guest@porteus:~$ 
After the 1st try I increased my volume to 100% and I did hear the pop. Not very load at 100% but hearable.
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Ravas coding goodies

Post#83 by Rava » 01 Feb 2022, 08:43

Ed_P wrote:
01 Feb 2022, 08:34
After the 1st try I increased my volume to 100% and I did hear the pop. Not very load at 100% but hearable.
So, seems your speakers are less sensitive to lower volumes than mine are, then.

Should I look for the original notification.wav?

Also, since it was part of uget package (I presume, since the path where I found it in said so), it should be found on the internet as well.
Cheers!
Yours Rava

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Ravas coding goodies

Post#84 by Rava » 01 Feb 2022, 12:16

Found notification.wav several times on my internal harddisk in much older versions of Porteus rootcopy backup folders. Its path always was

Code: Select all

usr/share/sounds/uget/notification.wav
Used LAME 3.100 64bits with the bitrate of 128 to shrink the original to a mp3:

Code: Select all

guest@porteus:/tmp$ ls -l notification.*
-rw-r--r-- 1 guest users  2924 Feb  1 12:30 notification.mp3
-rw-r--r-- 1 guest users 11008 Dec  3  2013 notification.wav
guest@porteus:/tmp$ md5sum notification.*
810cc1a60751247bde54bbe914f861d9  notification.mp3
02689c2c14d4a0dc1bff40c3c54b327c  notification.wav
I made a module, but brave and palemoon both crash every time I try to upload it unlike me having no issue uploading the original module.

Therefore you all you have to do are five easy steps to do the alteration from alarm+beep+notifications.mp3.xzm into alarm+beep+notifications.mp3_no-dB-reduction.xzm yourself.

Is is only five easy steps: (the extra 3 dots below only show the results of your work and are no alteration or mp3-creation or module-creation in itself)

Extract the original alarm*xzm module into a folder on a POSIX file system (ext[234], reiserfs etcetera) - no VFAT, NTFS or such. When running Porteus your RAMDISK would also work, e.g. use a folder in /tmp . Use a POSIX filesystem for extracting your module or else all file permissions will be messed up.

● Find a notification.wav (see file size and md5sum above) and use lame to convert it into notification.mp3 (bitrate of 128 should be sufficient) - look for a slackware package of uget, the sound file as described above should be included. Use txz2dir to extract the whole package and then use lame on your extracted /uget-extracted/usr/share/sounds/uget/notification.wav (Your file path will most probably differ from my example one)

● Replace occurrence of
notification_-12dB.mp3 with notification.mp3
in alarm.sh and beep

● and replace occurrence of notification_-15dB.mp3 with notification_-12dB.mp3
in beep2.

● The result should be

Code: Select all

root@porteus:/Porteus_modules/dir2xzm/usr/local/bin# grep soundfile= *
alarm.sh:soundfile="/usr/local/share/notification.mp3"
beep:soundfile=/usr/local/share/notification.mp3
beep2:soundfile=/usr/local/share/notification_-12dB.mp3
● Then delete notification_-15dB.mp3 and copy your notification.mp3 where your exploded ("xzm2dir") alarm+beep+notifications.mp3.xzm/usr/local/share/ folder is.

● Then dir2xzm the folder into the new module. In my case that would be:

Code: Select all

root@porteus:/Porteus_modules# dir2xzm dir2xzm/ alarm+beep+notifications.mp3_no-dB-reduction.xzm
● In the end it should be like this

Code: Select all

root@porteus:/Porteus_modules# lsxzm alarm+beep+notifications.mp3_no-dB-reduction.xzm 
/usr
/usr/local
/usr/local/bin
/usr/local/bin/alarm.sh
/usr/local/bin/beep
/usr/local/bin/beep2
/usr/local/share
/usr/local/share/notification.mp3
/usr/local/share/notification_-12dB.mp3
● Of course, the scripts beep beep2 and alarm.sh are now the altered versions as described above.

And indeed as I presumed it would be, the resulting notification sound is much too loud for my very own system. :(
Cheers!
Yours Rava

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Ravas coding goodies

Post#85 by Rava » 01 Feb 2022, 14:49

Since I figured out the reason why I could not upload anything was any browser crashing when I opened an file dialogue (be it palemoon or brave). I had to restart to fix the issue, the reason why that happened is still unclear.

Here the non dB reduced module:
https://filehorst.de/d/eazznhAd

name alarm+beep+notifications.mp3_no-dB-reduction.xzm
md5sum is like filehorst says: e7e62c84b9e17899827b2a2be882f443
size: 8 kB

Contents as described in the post above.

The same jazz applied when it come to the German English translation of the German speaking site filehorst.de as above.
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Ravas coding goodies

Post#86 by Ed_P » 01 Feb 2022, 16:22

Rava wrote:
01 Feb 2022, 14:47
Found notification.wav several times on my internal harddisk in much older versions of Porteus

Code: Select all

guest@porteus:~$ ls /usr/share/sounds/uget
/bin/ls: cannot access '/usr/share/sounds/uget': No such file or directory
guest@porteus:~$ ls -l notification.*
/bin/ls: cannot access 'notification.*': No such file or directory
guest@porteus:~$ cd /tmp
guest@porteus:/tmp$ ls -l notification.*
/bin/ls: cannot access 'notification.*': No such file or directory
guest@porteus:/tmp$ 
Rava wrote:
01 Feb 2022, 14:47
Extract the original alarm*xzm module into a folder on a POSIX file system (ext[234], reiserfs etcetera) - no VFAT, NTFS or such.
I assume all my Porteus live folders are POSIX file systems: /tmp, /home/guest/Downloads, /root/Downloads, ...
Rava wrote:
01 Feb 2022, 14:47
Find a notification.wav (see file size and md5sum above) and use lame to convert it into notification.mp3 (bitrate of 128 should be sufficient)
"lame"? :%)
Rava wrote:
01 Feb 2022, 14:49
Here the non dB reduced module:
https://filehorst.de/d/eazznhAd
I like this option better. :) Thank you. :beer:
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Ravas coding goodies

Post#87 by Rava » 01 Feb 2022, 16:26

Ed_P wrote:
01 Feb 2022, 16:22
Rava wrote:
01 Feb 2022, 14:47
Find a notification.wav (see file size and md5sum above) and use lame to convert it into notification.mp3 (bitrate of 128 should be sufficient)
"lame"? :%)
You not know of lame as in "lame ain't no mp3 encoder", said to be the best mp3 encoder out there?

Just type lame in your terminal and you see:

Code: Select all

root@porteus:~# lame
LAME 64bits version 3.100 (http://lame.sf.net)

usage: lame [options] <infile> [outfile]

    <infile> and/or <outfile> can be "-", which means stdin/stdout.

Try:
     "lame --help"           for general usage information
 or:
     "lame --preset help"    for information on suggested predefined settings
 or:
     "lame --longhelp"
  or "lame -?"              for a complete options list
And as wc can tell you, the complete options list is quite a thing:

Code: Select all

root@porteus:~# lame -?|wc
    164    1005    7804
:D

Anyhow, the name lame ain't no mp3 encoder comes from the fact that lame is just some patches on the official reference C source code as published by Frauenhofer Institut.
https://www.iis.fraunhofer.de/en/ff/amm/mp3history.html
Ed_P wrote:
01 Feb 2022, 16:22
Rava wrote:
01 Feb 2022, 14:49
Here the non dB reduced module:
https://filehorst.de/d/eazznhAd
I like this option better. :) Thank you. :beer:
Hope you approve of the notification.mp3 volume.

And seems you oversaw what I wrote about uget no longer being part of Porteus and you needing to find a uget package to get the notification.wav …
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Ravas coding goodies

Post#88 by Ed_P » 01 Feb 2022, 23:24

At volume 71% sound is indeed heard, and repeatedly. At 13% not so much.

And Ctrl+C aborts/stops it.

Code: Select all

guest@porteus:~$ lame
LAME 64bits version 3.100 (http://lame.sf.net)

usage: lame [options] <infile> [outfile]

    <infile> and/or <outfile> can be "-", which means stdin/stdout.

Try:
     "lame --help"           for general usage information
 or:
     "lame --preset help"    for information on suggested predefined settings
 or:
     "lame --longhelp"
  or "lame -?"              for a complete options list

guest@porteus:~$ alarm.sh
daueralarm.sh V1.4 - sound file is /usr/local/share/notification.mp3
pause length: 2 seconds - Aboard with Strg+C
^C
guest@porteus:~$ alarm.sh
daueralarm.sh V1.4 - sound file is /usr/local/share/notification.mp3
pause length: 2 seconds - Aboard with Strg+C
^C
guest@porteus:~$ 

Ed

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

Ravas coding goodies

Post#89 by Rava » 02 Feb 2022, 08:52

Ed_P wrote:
01 Feb 2022, 23:24
At volume 71% sound is indeed heard, and repeatedly. At 13% not so much.
And with 13% all other sounds, like your average mp3 collection or some youtube video are heard okay? Especially considering some video files are encoded to have reduced dB…

The notification.mp3 is the original loudness of the wav file, not really much improvement there. One could use audacity to increase the volume more than 100% but that would also worsen the sound quality.

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Ravas coding goodies

Post#90 by Ed_P » 03 Feb 2022, 01:31

Rava wrote:
02 Feb 2022, 08:52
And with 13% all other sounds,
No, and sometimes I have my sound off all together, so as to not disturb others. But the alarm.sh has value for some things that I do. It would also be good if it did the repeat sound after a period of time the user could input so I may be playing with it in the future.
Ed

Post Reply