PoshNotify icon indicating copy to clipboard operation
PoshNotify copied to clipboard

Default "Sound" behavior

Open TylerLeonhardt opened this issue 7 years ago • 6 comments

Some options:

  1. whatever the default sound is for that platform (if the platform supports sound)
  2. no sound at all

Number 1 means we'd support a -Silent switch parameter Number 2 means we'd support a -Sound $someStr parameter

I think we should do number 1 first and then add number 2 so that users can specify their own sound files

TylerLeonhardt avatar Dec 03 '18 04:12 TylerLeonhardt

I'm keen on #1 and then #2 as a bonus.

Do all platforms support sounds (both preset and custom i.e. path to an MP3/wav?)

On Mon, 3 Dec 2018, 5:01 PM Tyler James Leonhardt, [email protected] wrote:

Some options:

  1. whatever the default sound is for that platform (if the platform supports sound)
  2. no sound at all

Number 1 means we'd support a -Silent switch parameter Number 2 means we'd support a -Sound $someStr parameter

I think we should do number 1 first and then add number 2 so that users can specify their own sound files

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Windos/PoshNotify/issues/9, or mute the thread https://github.com/notifications/unsubscribe-auth/AGojCn6YNn1Tl8WTNeudzdhLlFQciHdqks5u1KIogaJpZM4Y91vf .

Windos avatar Dec 03 '18 04:12 Windos

It looks like linux supports it as a hint

http://www.galago-project.org/specs/notification/0.9/x344.html

 "sound-file"     | string     |   The path to a sound file to play when the notification pops up.    

looks like there's no default sound though. Maybe for linux, no sound is a good default... and then we can allow users to specify the sound file which should work cross-plat.

There's some work I'll have to do in PSNotifySend to support this.

TylerLeonhardt avatar Dec 03 '18 04:12 TylerLeonhardt

MacNotify works by looking in all the default directories for sounds and then populating the parameter set dynamically with the names of the files. This is what makes the module PowerShell Core specific as I think the functionality to do so via a class is core specific.

While figuring out how to do it I noticed there was an open issue to add the technique to the documentation, which I then did, so the way I'm using it in MacNotify is also the documented example: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions_advanced_parameters?view=powershell-6#dynamic-validateset-values

markwragg avatar Dec 05 '18 14:12 markwragg

So I've done a fair bit of playing with this today. It looks like all the major distros (CentOS,Ubuntu,Debian,Fedora) have a paplay binary which can play any filetype.

Testing againt what's it /usr/share/sounds/gnome/default/alerts on each system yielded 100% success rate in hearing the audio.

Armed with that data, I intend to stream tonight on a new branch which adds the -Sound parameter to Send-OSNotification.

steviecoaster avatar Feb 08 '19 22:02 steviecoaster

I did the work in PSNotifySend to expose a -SoundFile so that should be ready :)

TylerLeonhardt avatar Feb 09 '19 02:02 TylerLeonhardt

Also, I noticed that notify-send has a --category (which is exposed in PSNotifySend) that gives you a bunch of sounds for different notification types:

"device","device.added","device.error","device.removed",
        "email","email.arrived","email.bounced",
        "im","im.error","im.received",
        "network","network.connected","network.disconnected","network.error",
        "presence","presence.offline","presence.online",
        "transfer","transfer.complete","transfer.error"

and I'm wondering if that's useful here... not quite sure.

TylerLeonhardt avatar Feb 17 '19 19:02 TylerLeonhardt