1

I made a simple app that sends notifications in Go. In Linux, using notify-send everything works well, while in macOS osascript sends notifications without the icon (it uses the default AppleScript icon), and I need my icon to be displayed. I also don't want to use terminal-notifier, since not everyone has it.

How can I send notifications with Go in macOS displaying the icon (with osascript or even with some other external library)?

0xFR
  • 108
  • 9
  • 1
    Did you take a look at https://github.com/gen2brain/beeep or https://github.com/keybase/go-notifier ? (Never used them, I’ve just google for "golang MacOS notification") – mgagnon Jun 04 '20 at 14:46
  • the first one uses osascript. The second one I don't know how to use it. It could be the correct one but I don't know how to use it. Could you explain? I'm still learning Go. I only need to use Title, subtitle and icon, nothing else – 0xFR Jun 04 '20 at 15:01

1 Answers1

0

You cannot add an icon to a notification through osascript, as you can see from the documentation: display notification

Posts a notification using the Notification Center, containing a title, subtitle, and explanation, and optionally playing a sound.

You can find some clarification also in this answer: https://stackoverflow.com/a/49079025/5199939

MircoT
  • 185
  • 1
  • 9
  • And is there another tool to send notifications that support the icon? – 0xFR Jun 04 '20 at 13:53
  • A possible alternative could be to use something like growl: [http://growl.info/downloads](http://growl.info/downloads). – MircoT Jun 05 '20 at 14:30
  • Yes but something that doesn’t need to be downloaded – 0xFR Jun 05 '20 at 14:47
  • The only remaining options are: using a dialog: [display dialog](https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW12); or saving the script as an app and change the `.icns` icon file – MircoT Jun 05 '20 at 15:15
  • How can I use it in go? – 0xFR Jun 05 '20 at 15:18