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

use AyatanaAppIndicator3 if available, fallback to AppIndicator3 #130

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions pulsemeeter/interface/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

# from pulsectl import Pulse
gi_require_version('Gtk', '3.0')
gi_require_version('AppIndicator3', '0.1')
from gi.repository import Gtk, GLib, AppIndicator3
from gi.repository import Gtk, GLib


class MainWindow(Gtk.Window):
Expand Down Expand Up @@ -699,6 +698,18 @@ def tray_menu(self):
return menu

def create_indicator(self):
# Try AyatanaAppIndicator3 first, fall back to AppIndicator3
try:
gi_require_version('AyatanaAppIndicator3', '0.1')
from gi.repository import AyatanaAppIndicator3 as AppIndicator3
except (ImportError, ValueError):
try:
gi_require_version('AppIndicator3', '0.1')
from gi.repository import AppIndicator3 as AppIndicator3
except (ImportError, ValueError):
print("Neither AyatanaAppIndicator3 nor AppIndicator3 found. System tray functionality will be disabled.")
return None

indicator = AppIndicator3.Indicator.new(id='pulsemeetertray',
icon_name='Pulsemeeter',
category=AppIndicator3.IndicatorCategory.APPLICATION_STATUS)
Expand Down