Sound effects question...

Please post suggestions for improvement of Cinnamon here
https://github.com/linuxmint/Cinnamon
Post Reply
User avatar
invex
Level 2
Level 2
Posts: 78
Joined: Sun Aug 14, 2016 12:38 pm

Sound effects question...

Post by invex » Sat Sep 15, 2018 11:00 pm

I like to have sound effects enabled.
Is it to possible to add more sound effects?
Namely a sound effect when notifications are cleared.
TIA
Attachments
Selection_122.jpg

User avatar
catweazel
Level 17
Level 17
Posts: 7774
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: Sound effects question...

Post by catweazel » Sat Sep 15, 2018 11:02 pm

invex wrote:
Sat Sep 15, 2018 11:00 pm
Is it to possible to add more sound effects?
Please post the output of this terminal command:

Code: Select all

inxi -S
Enclose the results between [ⅽode] and [/ⅽode] code markers by selecting </> from the mini toolbar above the textbox where you type your reply.
¡uʍop ǝpısdn sı buıɥʇʎɹǝʌǝ os ɐıןɐɹʇsnɐ ɯoɹɟ ɯ,ı

User avatar
invex
Level 2
Level 2
Posts: 78
Joined: Sun Aug 14, 2016 12:38 pm

Re: Sound effects question...

Post by invex » Sat Sep 15, 2018 11:58 pm

Code: Select all

System:    Host: Invex-Mint Kernel: 4.15.0-041500-generic x86_64 bits: 64
           Desktop: Cinnamon 3.8.9  Distro: Linux Mint 19 Tara

User avatar
smurphos
Level 8
Level 8
Posts: 2255
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: Sound effects question...

Post by smurphos » Sun Sep 16, 2018 12:02 am

invex wrote:
Sat Sep 15, 2018 11:00 pm
Is it to possible to add more sound effects?
Namely a sound effect when notifications are cleared.
Open the Sound settings module, navigate to the Sounds tab and switch the toggle for Notification sounds on.

Image

User avatar
invex
Level 2
Level 2
Posts: 78
Joined: Sun Aug 14, 2016 12:38 pm

Re: Sound effects question...

Post by invex » Sun Sep 16, 2018 4:04 am

Thx.
I have Notification sound on.
I'd like to add a sound effect when I click on Clear notifications.

User avatar
smurphos
Level 8
Level 8
Posts: 2255
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: Sound effects question...

Post by smurphos » Sun Sep 16, 2018 4:40 am

That's not quite so simple.... :)

You'll need to modify the default notification tray applet to do that.

Step 1:

Copy the default applet folder /usr/share/cinnamon/applets/notifications@cinnamon.org to ~/.local/share/cinnamon/applets/notifications@cinnamon.org

Step 2:

Open ~/.local/share/cinnamon/applets/notifications@cinnamon.org/applet.js in your favorite text editor - ideally one that supports line numbers (The default editor xed does if you turn them on in it's preferences)

Navigate to line 195 - you will see a function that looks like this

Code: Select all

_clear_all() {
        let count = this.notifications.length;
        if (count > 0) {
            for (let i = count-1; i >=0; i--) {
                this._notificationbin.remove_actor(this.notifications[i].actor);
                this.notifications[i].destroy(NotificationDestroyedReason.DISMISSED);
            }
        }
        this.notifications = [];
        this.update_list();
    }
Add the line Main.soundManager.play('notification'); so it looks like this. Save the file. Hit Ctrl-Alt-Escape to restart Cinnamon. if it hangs for a bit just hit Ctrl-Alt-Escape again. You'll get the same notification sound on clearing notifications as you do when a new one comes in. If you want to pick a different sound the valid values are - "switch", "close", "map", "minimize", "maximize", "unmaximize", "tile", "login", "plug", "unplug", "notification"

Code: Select all

_clear_all() {
        let count = this.notifications.length;
        if (count > 0) {
            for (let i = count-1; i >=0; i--) {
                this._notificationbin.remove_actor(this.notifications[i].actor);
                this.notifications[i].destroy(NotificationDestroyedReason.DISMISSED);
            }
        }
        this.notifications = [];
        this.update_list();
        Main.soundManager.play('notification');
    }
I'm sure you can also set a totally custom sound, just not quite sure how at time of writing. If I work it out I'll post back.... :)

User avatar
smurphos
Level 8
Level 8
Posts: 2255
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: Sound effects question...

Post by smurphos » Sun Sep 16, 2018 5:03 am

To add a completely custom sound for clear notifications the line to add is

Main.soundManager.playSoundFile(0, '/path/to/soundfile');

e.g...

Main.soundManager.playSoundFile(0, '/usr/share/sounds/freedesktop/stereo/trash-empty.oga');

User avatar
invex
Level 2
Level 2
Posts: 78
Joined: Sun Aug 14, 2016 12:38 pm

Re: Sound effects question...

Post by invex » Mon Sep 17, 2018 12:16 am

Thanks a lot.

I'm sure I didn't make a mistake when I added:
Main.soundManager.playSoundFile(0, '/usr/share/mint-artwork/sounds/clearnotification.oga');

But it didn't work. No sound effect when I click 'Clear notifications'.

User avatar
MrEen
Level 8
Level 8
Posts: 2012
Joined: Mon Jun 12, 2017 8:39 pm

Re: Sound effects question...

Post by MrEen » Mon Sep 17, 2018 12:43 am

invex wrote:
Mon Sep 17, 2018 12:16 am
But it didn't work. No sound effect when I click 'Clear notifications'.
Did you restart Cinnamon?

User avatar
smurphos
Level 8
Level 8
Posts: 2255
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: Sound effects question...

Post by smurphos » Mon Sep 17, 2018 12:50 am

There isn't a clearnotifications.oga in that location. You need to provide the path to an existing sound file. That might be one that is preinstalled or might be one you have downloaded, or might be one you've created from scratch.

The default sound files available on a Mint 19 systems are in 3 locations.

Code: Select all

$ ls -1 /usr/share/mint-artwork/sounds
close.oga
login.oga
logout.ogg
map.oga
maximize.oga
minimize.oga
notification.oga
plug.oga
switch.oga
tile.oga
trash.oga
unmaximize.oga
unplug.oga
volume.oga
&

Code: Select all

$ ls -1 /usr/share/sounds/LinuxMint/stereo
button-pressed.ogg
button-toggle-off.ogg
button-toggle-on.ogg
desktop-login.ogg
desktop-logout.ogg
dialog-error.ogg
dialog-information.ogg
dialog-question.ogg
dialog-question.wav
dialog-warning.ogg
phone-incoming-call.ogg
system-ready.ogg
window-slide.ogg
&

Code: Select all

$ ls -1 /usr/share/sounds/freedesktop/stereo
alarm-clock-elapsed.oga
audio-channel-front-center.oga
audio-channel-front-left.oga
audio-channel-front-right.oga
audio-channel-mono.oga
audio-channel-rear-center.oga
audio-channel-rear-left.oga
audio-channel-rear-right.oga
audio-channel-side-left.oga
audio-channel-side-right.oga
audio-test-signal.oga
audio-volume-change.oga
bell.oga
camera-shutter.oga
complete.oga
device-added.oga
device-removed.oga
dialog-error.oga
dialog-information.oga
dialog-warning.oga
message-new-instant.oga
message.oga
network-connectivity-established.oga
network-connectivity-lost.oga
onboard-key-feedback.oga
phone-incoming-call.oga
phone-outgoing-busy.oga
phone-outgoing-calling.oga
power-plug.oga
power-unplug.oga
screen-capture.oga
service-login.oga
service-logout.oga
suspend-error.oga
trash-empty.oga
window-attention.oga
window-question.oga
You can find additional sound-themes in the repos to get more choices e.g. apt install oxygen-sounds ubuntu-sounds

You can also look here for more user-created sound-themes - https://www.opendesktop.org/browse/cat/316/order/latest

User avatar
invex
Level 2
Level 2
Posts: 78
Joined: Sun Aug 14, 2016 12:38 pm

Re: Sound effects question...

Post by invex » Mon Sep 17, 2018 1:32 am

Thank you again.
I feel so stupid.
No, I didn't restart Cinnamon.
When I did, everything worked fine.
Thank you VERY much!
You have no idea how happy this small tweak makes me :)

User avatar
smurphos
Level 8
Level 8
Posts: 2255
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: Sound effects question...

Post by smurphos » Mon Sep 17, 2018 1:58 am

You are welcome - I learnt a few new things myself checking this out... :), and I like having a few more sound-effects too.

User avatar
invex
Level 2
Level 2
Posts: 78
Joined: Sun Aug 14, 2016 12:38 pm

Re: Sound effects question...

Post by invex » Mon Sep 17, 2018 3:25 pm

I'd like to create a script which would display notifications (the same like clicking the notification icon in the panel), display them for 1 second, delete them and exit.
I didn't get very far :)

User avatar
MrEen
Level 8
Level 8
Posts: 2012
Joined: Mon Jun 12, 2017 8:39 pm

Re: Sound effects question...

Post by MrEen » Mon Sep 17, 2018 3:46 pm

Not sure of the purpose, but you can use notify-send in a script or the terminal like this: notify-send --expire-time=1000 My 1 second notification is better than Hello World!

This works on Xfce, but the Ubuntu man page shows this for --expire-time: The duration, in milliseconds, for the notification to appear on screen. (Ubuntu's Notify OSD and GNOME Shell both ignore this parameter.) I'm not sure if this affects Cinnamon or not.

User avatar
invex
Level 2
Level 2
Posts: 78
Joined: Sun Aug 14, 2016 12:38 pm

Re: Sound effects question...

Post by invex » Mon Sep 17, 2018 6:11 pm

Thank you but it's not the same as clicking on the panel notification icon.
And the purpose?
I have to clear notifications many, many times a day. I'd like to bring the mouse cursor to the bottom left corner (hot corner) to execute a script which would show me notifications for 1 second and then automatically delete them (the same as clicking Clear notifications) .
Attachments
Selection_131.jpg
Selection_131.jpg (1.87 KiB) Viewed 279 times

User avatar
invex
Level 2
Level 2
Posts: 78
Joined: Sun Aug 14, 2016 12:38 pm

Re: Sound effects question...

Post by invex » Mon Sep 17, 2018 7:23 pm

Thank you very much.
I had no idea that the sounds are in 3 different locations.
However, how would I enable for example trash-empty.oga?
Sound/Sounds has only 13 sound effects available. No Trash Empty.
smurphos wrote:
Mon Sep 17, 2018 12:50 am
There isn't a clearnotifications.oga in that location. You need to provide the path to an existing sound file. That might be one that is preinstalled or might be one you have downloaded, or might be one you've created from scratch.

The default sound files available on a Mint 19 systems are in 3 locations.

Code: Select all

$ ls -1 /usr/share/mint-artwork/sounds
close.oga
login.oga
logout.ogg
map.oga
maximize.oga
minimize.oga
notification.oga
plug.oga
switch.oga
tile.oga
trash.oga
unmaximize.oga
unplug.oga
volume.oga
&

Code: Select all

$ ls -1 /usr/share/sounds/LinuxMint/stereo
button-pressed.ogg
button-toggle-off.ogg
button-toggle-on.ogg
desktop-login.ogg
desktop-logout.ogg
dialog-error.ogg
dialog-information.ogg
dialog-question.ogg
dialog-question.wav
dialog-warning.ogg
phone-incoming-call.ogg
system-ready.ogg
window-slide.ogg
&

Code: Select all

$ ls -1 /usr/share/sounds/freedesktop/stereo
alarm-clock-elapsed.oga
audio-channel-front-center.oga
audio-channel-front-left.oga
audio-channel-front-right.oga
audio-channel-mono.oga
audio-channel-rear-center.oga
audio-channel-rear-left.oga
audio-channel-rear-right.oga
audio-channel-side-left.oga
audio-channel-side-right.oga
audio-test-signal.oga
audio-volume-change.oga
bell.oga
camera-shutter.oga
complete.oga
device-added.oga
device-removed.oga
dialog-error.oga
dialog-information.oga
dialog-warning.oga
message-new-instant.oga
message.oga
network-connectivity-established.oga
network-connectivity-lost.oga
onboard-key-feedback.oga
phone-incoming-call.oga
phone-outgoing-busy.oga
phone-outgoing-calling.oga
power-plug.oga
power-unplug.oga
screen-capture.oga
service-login.oga
service-logout.oga
suspend-error.oga
trash-empty.oga
window-attention.oga
window-question.oga
You can find additional sound-themes in the repos to get more choices e.g. apt install oxygen-sounds ubuntu-sounds

You can also look here for more user-created sound-themes - https://www.opendesktop.org/browse/cat/316/order/latest

User avatar
smurphos
Level 8
Level 8
Posts: 2255
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: Sound effects question...

Post by smurphos » Tue Sep 18, 2018 1:49 am

invex wrote:
Mon Sep 17, 2018 7:23 pm
Thank you very much.
I had no idea that the sounds are in 3 different locations.
However, how would I enable for example trash-empty.oga?
Sound/Sounds has only 13 sound effects available. No Trash Empty.
Yeah it looks like Cinnamon only implements a subset of the available sounds. Enabling trash noises I think would probably require modification to Nemo's source code which is a step above hacking some extra noise into Cinnamon applets.

Post Reply

Return to “Cinnamon”