MvBonin / wingpanel-community-indicators

Wingpanel - Community Indicators
GNU Lesser General Public License v2.1
82 stars 4 forks source link

Tray not appearing #6

Closed SubSonicSoftware closed 5 months ago

SubSonicSoftware commented 1 year ago

I used to use this script to display icons in the system tray, trying to get it working again:

#!/usr/bin/python
import os
from gi.repository import Gtk as gtk, AppIndicator3 as appindicator

def main():
  indicator = appindicator.Indicator.new("timeshifttray", "timeshift", appindicator.IndicatorCategory.APPLICATION_STATUS)
  indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
  indicator.set_menu(menu())
  gtk.main()

def menu():
  menu = gtk.Menu()

#  command_one = gtk.MenuItem('Open Main Window')
#  command_one.connect('activate', open)
#  menu.append(command_one)

#  exittray = gtk.MenuItem('Exit Tray')
#  exittray.connect('activate', quit)
#  menu.append(exittray)

  menu.show_all()
  return menu

def open(_):
  os.system("sudo timeshift-gtk")

def quit(_):
  gtk.main_quit()

if __name__ == "__main__":
  main()

I've installed the following dependencies: indicator-application ayatana-indicator-application gir1.2-appindicator3-0.1 python-is-python3

The startup command runs without any output: exec /usr/lib/x86_64-linux-gnu/indicator-application/indicator-application-service

And the python script returns errors I would usually ignore:

python /home/me/Documents/Scripts/Syncovery
/home/me/Documents/Scripts/Syncovery:3: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import Gtk as gtk, AppIndicator3 as appindicator
/home/me/Documents/Scripts/Syncovery:3: PyGIWarning: AppIndicator3 was imported without specifying a version first. Use gi.require_version('AppIndicator3', '0.1') before import to ensure that the right version gets loaded.
  from gi.repository import Gtk as gtk, AppIndicator3 as appindicator
nater1983 commented 9 months ago
#!/usr/bin/env python3

 import os
 import gi

gi.require_version('Gtk', '3.0')
gi.require_version('AppIndicator3', '0.1')

from gi.repository import Gtk as gtk, AppIndicator3 as appindicator

def main():
    indicator = appindicator.Indicator.new("timeshifttray", "timeshift", appindicator.IndicatorCategory.APPLICATION_STATUS)
    indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
    indicator.set_menu(menu())
    gtk.main()

def menu():
    menu = gtk.Menu()

command_one = gtk.MenuItem(label='Open Main Window')
command_one.connect('activate', open_window)
menu.append(command_one)

exit_tray = gtk.MenuItem(label='Exit Tray')
exit_tray.connect('activate', quit_app)
menu.append(exit_tray)

menu.show_all()
return menu

def open_window(_):
    os.system("sudo timeshift-gtk")

def quit_app(_):
    gtk.main_quit()

if __name__ == "__main__":
    main()
MvBonin commented 5 months ago

I'm closing this for now since this has not much to do with the development of community-indicators.. @SubSonicSoftware did @nater1983 solve your problem?