Skip to content

Commit

Permalink
create system tray
Browse files Browse the repository at this point in the history
  • Loading branch information
shadeyg56 committed Feb 5, 2023
1 parent 7b0d46d commit 84124df
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions auto_cpufreq/gui/tray.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import gi

gi.require_version("Gtk", "3.0")

from gi.repository import Gtk, AppIndicator3 as appindicator

from subprocess import run

def main():
indicator = appindicator.Indicator.new("auto-cpufreq-tray", "network-idle-symbolic", appindicator.IndicatorCategory.APPLICATION_STATUS)
indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
indicator.set_menu(build_menu())
Gtk.main()

def build_menu():
menu = Gtk.Menu()

program = Gtk.MenuItem("auto-cpufreq")
program.connect("activate", open_app)
menu.append(program)

_quit = Gtk.MenuItem("Quit")
_quit.connect("activate", Gtk.main_quit)
menu.append(_quit)
menu.show_all()
return menu

def open_app(MenuItem):
run("sudo -E python app.py", shell=True)

if __name__ == "__main__":
main()

0 comments on commit 84124df

Please sign in to comment.