4

I am trying to center a Tauri app on the osx tray icon, but cannot find a way to do it.

The idea is to make the app open and close on tray icon click, and to make it fixed at the top of the screen and centered on the icon (the y position may change depending on the number of items available from other apps). Something like this:

https://eshop.macsales.com/blog/wp-content/uploads/2019/05/Fantastical1280.jpg

(Sorry, i tried to add the image to the question, but always got a "Server error" when uploading)

I have searched the docs, but haven't found anything and also didn't find a solution on google

  • On the tauri.conf.json there is a windows.x and windows.y options, but i don't think i can get this kind of logic there.

  • I noticed that there is a window.set_position() function that i could call when the icon is clicked. But i am not sure how to get the correct position to enter the window on the icon

Boguz
  • 1,600
  • 1
  • 12
  • 25
  • 2
    Try this plugin: https://github.com/JonasKruckenberg/tauri-plugin-positioner it has system tray relative positions as well – t348575 Oct 15 '22 at 06:58
  • Thank you! I had seen that plugin, but i thought there would be a way to do it without plugins. I have tried the plugin. Things like `Position::TopCenter` or `Center` work well, but the tray position, like `Position::TrayCenter` i get `no variant or associated item named `TrayCenter` found for enum `tauri_plugin_positioner::Position` in the current scope` error. I think i will open an issue on the github. – Boguz Oct 15 '22 at 08:12
  • Sounds like you did not enable it through the feature `system-tray`, like so: `tauri-plugin-positioner = { version = "1.0", features = ["system-tray"] }` – t348575 Oct 15 '22 at 10:53
  • @t348575 Yes, you are right, i didn't. I opened a ticket on github, and it seems there are a couple of other problems that still need to be solved. Do you know of any other way to do this? – Boguz Oct 15 '22 at 13:39

0 Answers0