Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No (native) tray icon #22

Closed
fenrig opened this issue Aug 27, 2016 · 13 comments
Closed

No (native) tray icon #22

fenrig opened this issue Aug 27, 2016 · 13 comments

Comments

@fenrig
Copy link

fenrig commented Aug 27, 2016

Would it be possible to add a tray icon to the app ? Something we can (optionally) close to... ?

@fenrig fenrig changed the title No (native) notifications No (native) tray icon Aug 27, 2016
@ConorIA
Copy link
Contributor

ConorIA commented Aug 27, 2016

The tray icon was limited to Windows only in commit 7e11fc4. You could try reverting it. I'll test on my install.

@ConorIA
Copy link
Contributor

ConorIA commented Aug 27, 2016

Alright, I manged to come up with something in #23. I think you mentioned that you run Arch, right? I will update my PKGBUILD so that the AUR build gets the tray icon, but I'd really like to move the source back to the official repo, so I hope this gets merged and the devs can push another point release so I can go back to basing on the official code.

@lipis
Copy link
Contributor

lipis commented Aug 27, 2016

@fenrig if it works OK on Linux we could enable it there as well but we need your help to test it out :)

@ConorIA
Copy link
Contributor

ConorIA commented Aug 27, 2016

@lipis I'm happy to test too. The only two tray menu items on Linux are "Open WireInternal" and "Quit". No way to minimize to tray yet. But at least there is an icon that will show a badge when there is a message waiting.

EDIT: Might have spoken too soon. While I added a tray.badge.png, it doesn't actually seem to change when a new message is waiting. So at most the tray icon currently serves as a shortcut to the open program! I imagine that you folks will need to add more code for the Linux icon context menu?

@fenrig
Copy link
Author

fenrig commented Aug 28, 2016

yeah I'm ready to test it, indeed I run arch

@ConorIA
Copy link
Contributor

ConorIA commented Aug 28, 2016

@fenrig, while we wait for Arch to fix the nodejs version issue, see if this package will install with pacman -U http://cubert.conr.ca:8001/f/c95b3b631b/?dl=1

@fenrig
Copy link
Author

fenrig commented Aug 28, 2016

Okay on gnome it works fine, still awaiting the close to tray option. But its really shaping up to be a great desktop app :D

@fenrig
Copy link
Author

fenrig commented Aug 28, 2016

Oh and afterward it would be great if we could pass a flag to start the app in the tray :)

@ConorIA
Copy link
Contributor

ConorIA commented Sep 6, 2016

There is some code over on StackExchange (source) that might help. But I'm not sure where to add things like this, so I'll leave it to the professionals for now. 😉

EDIT: @fenrig, here is a diff that you can stick in for now. This will both close to tray and minimize to tray. I think it might be better to have the tray on Linux PR close before suggesting any additional functionality.

/electron/main.js
@@ -208,13 +208,17 @@
     util.updateBadge(main);
   });

+  main.on('minimize',function(event) {
+    event.preventDefault();
+    main.hide();
+  });
+
   main.on('close', function(event) {
     init.save('fullscreen', main.isFullScreen());
     if (!main.isFullScreen()) {
       init.save('bounds', main.getBounds());
     }
-
-    if ((process.platform === 'darwin' || process.platform === 'win32') && !quitting) {
+    if (!quitting) {
       event.preventDefault();
       main.hide();
     }

Actually, looking at the code it looks like the app already closes to tray on darwin and win32. @lipis, should I include the close to tray code in the open PR? Or leave it for a different one?

EDIT 2: Man, I'm on a roll it seems.

This diff makes the tray icon a toggle. If the window is visible, it is closed to the tray. If it is hidden, it is made visible.

/electron/js/menu/tray.js
@@ -51,7 +51,8 @@
     appIcon.setToolTip(config.NAME);
     appIcon.setContextMenu(contextMenu);
     appIcon.on('click', function () {
-      BrowserWindow.getAllWindows()[0].show();
+      if (BrowserWindow.getAllWindows()[0].isFocused()) BrowserWindow.getAllWindows()[0].hide();
+      else BrowserWindow.getAllWindows()[0].show();
     });
   },

EDIT 3: Arch/Manjaro package to test the above changes http://cubert.conr.ca:8001/f/adf78d6079/?dl=1

@lipis
Copy link
Contributor

lipis commented Sep 7, 2016

Fixed in #23 :)

@lipis lipis closed this as completed Sep 7, 2016
@lipis
Copy link
Contributor

lipis commented Oct 4, 2016

@ConorIA Do I have to do anything special on Ubuntu to see the Tray Icon? I just installed a new VM and it doesn't appear.. maybe some sort of settings or something?

@lipis
Copy link
Contributor

lipis commented Oct 4, 2016

Found it :) electron/electron#1347 (comment)

sudo apt-get install libappindicator1

@ConorIA
Copy link
Contributor

ConorIA commented Oct 4, 2016

Linux is funny with electron tray icons. I find the icon doesn't appear the first time I start Wire, but if I quit and open it again, it does work. Same thing with Rambox and other apps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants