example-tray-icon
This commit is contained in:
parent
a8d2653771
commit
1ed6b9f849
14
example-tray-icon/README.md
Normal file
14
example-tray-icon/README.md
Normal file
@ -0,0 +1,14 @@
|
||||
# Tray Icon Notification
|
||||
Shows a custom notification icon with a menu in the tray area of your desktop.
|
||||
|
||||
## Dependencies
|
||||
- Python
|
||||
- GTK3
|
||||
- AppIndicator3 (libappindicator-gtk3)
|
||||
|
||||
## Resources
|
||||
- Source Tutorial: [Create a Custom System Tray Indicator For Your Tasks on Linux](https://fosspost.org/custom-system-tray-icon-indicator-linux/)
|
||||
- Background on app indicators: [ApplicationIndicators](https://wiki.ubuntu.com/DesktopExperienceTeam/ApplicationIndicators)
|
||||
- [Python GTK3 Tutorial](https://python-gtk-3-tutorial.readthedocs.io/en/latest/)
|
||||
- [PyGObject](https://pygobject.readthedocs.io/en/latest/index.html)
|
||||
|
39
example-tray-icon/tray.py
Executable file
39
example-tray-icon/tray.py
Executable file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/python
|
||||
import os
|
||||
import gi
|
||||
|
||||
gi.require_version('Gtk', '3.0')
|
||||
gi.require_version('AppIndicator3', '0.1')
|
||||
|
||||
from gi.repository import Gtk as gtk
|
||||
from gi.repository import AppIndicator3 as appindicator
|
||||
|
||||
def main():
|
||||
indicator = appindicator.Indicator.new("customtray", "semi-starred-symbolic", 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='My Notes')
|
||||
command_one.connect('activate', note)
|
||||
menu.append(command_one)
|
||||
|
||||
exittray = gtk.MenuItem(label='Exit Tray')
|
||||
exittray.connect('activate', quit)
|
||||
menu.append(exittray)
|
||||
|
||||
menu.show_all()
|
||||
return menu
|
||||
|
||||
def note(_):
|
||||
os.system("gvim $HOME/notes.txt")
|
||||
|
||||
def quit(_):
|
||||
gtk.main_quit()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user