I want to create a time counter that gets added to the top bar in Ubuntu (GNOME Shell 42.9).
I am trying to add an icon first, but it doesn't get added. I also installed all necessary dependencies and restarted the computer.
import signal
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('AppIndicator3', '0.1')
from gi.repository import Gtk, AppIndicator3, GLib
APPINDICATOR_ID = 'custom_indicator'
CUSTOM_ICON_PATH = '/home/afranz/Desktop/ActiveTime/activity_counter_app/icon.svg'
class CustomIndicator:
def __init__(self):
self.indicator = AppIndicator3.Indicator.new(
APPINDICATOR_ID, CUSTOM_ICON_PATH, AppIndicator3.IndicatorCategory.APPLICATION_STATUS
)
self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
def run(self):
Gtk.main()
def main():
gi.require_version('Gtk', '3.0')
gi.require_version('AppIndicator3', '0.1')
app = CustomIndicator()
signal.signal(signal.SIGINT, signal.SIG_DFL) # Allow Ctrl+C to exit the application
app.run()
if __name__ == '__main__':
main()
I am also not getting any error when running this.
The path is correct, I am using Python 3.10.12 and Ubuntu 22.04.3 LTS.
I also enabled this GNOME extension (since legacy tray icons seem to be disabled by default with modern GNOME versions).
Also, I am not constrained to use AppIndicator for any reason, it's just the common solution I saw while researching online about how to "add stuff to the top bar in Ubuntu".