hoodie / notify-rust

☝️send desktop notifications from your Rust app.
Apache License 2.0
1.15k stars 74 forks source link

Windows Toast shows PowerShell #219

Open D3XX3R opened 5 months ago

D3XX3R commented 5 months ago

Using notify-rust on Windows shows that the toast comes from Windows PowerShell. I've tried using appname but that doesn't seem to do anything.

Is there a way to use a custom application name for the toasts on Windows?

kareemmahlees commented 3 months ago

I just noticed the same thing.

I took a look at the code and found out that it's passing app_id ( not appname ) to the underlying winrt_notification, if app_id is not set it defaults to powershel's app id, does setting app_id instead solves your problem? ( here is how you find the App User Model ID for your app )

[!Note] Please take a look at the below from winrt_notification docs:

If the program you are using this in was not installed, use Toast::POWERSHELL_APP_ID for now.

rctlmk commented 2 months ago

I was playing around with Tauri's winrt-notification and I was able to set a custom name and icon for the notification. All you need to do is create a new key in HKEY_CLASSES_ROOT\AppUserModelId with your AUMID and use it when creating a notification. The example below uses one of the IDs that I already had on my PC: image Exported reg key:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\AppUserModelId\FirefoxToast-CA9422711AE1A81C]
;COM activator, optional
"CustomActivator"="{B93735BB-724D-4F0B-A9BB-6584C2819E68}"
"DisplayName"="Mozilla Firefox"
"IconBackgroundColor"="0"
"IconUri"="C:\Program Files\Mozilla Firefox\browser\VisualElements\VisualElements_70.png"

Code snippet:

use tauri_winrt_notification::Sound;
use tauri_winrt_notification::Toast;

Toast::new("FirefoxToast-CA9422711AE1A81C")
    .title("Look at this flip!")
    .text1("(╯°□°)╯︵ ┻━┻")
    .add_button("OK", "ok")
    .sound(Some(Sound::Default))
    .show()
    .expect("unable to toast");

https://learn.microsoft.com/en-us/windows/apps/design/shell/tiles-and-notifications/send-local-toast-other-apps