Skip to content

Instantly share code, notes, and snippets.

@candidtim
Last active July 15, 2021 21:40
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save candidtim/7290a1ad6e465d680b68 to your computer and use it in GitHub Desktop.
Save candidtim/7290a1ad6e465d680b68 to your computer and use it in GitHub Desktop.
Minimal Ubuntu AppIndicator in Python, with custom icon and a "Quit" menu item
import os
import signal
from gi.repository import Gtk as gtk
from gi.repository import AppIndicator3 as appindicator
APPINDICATOR_ID = 'myappindicator'
def main():
indicator = appindicator.Indicator.new(APPINDICATOR_ID, os.path.abspath('sample_icon.svg'), appindicator.IndicatorCategory.SYSTEM_SERVICES)
indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
indicator.set_menu(build_menu())
gtk.main()
def build_menu():
menu = gtk.Menu()
item_quit = gtk.MenuItem('Quit')
item_quit.connect('activate', quit)
menu.append(item_quit)
menu.show_all()
return menu
def quit(source):
gtk.main_quit()
if __name__ == "__main__":
signal.signal(signal.SIGINT, signal.SIG_DFL)
main()
Display the source blob
Display the rendered blob
Raw
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64px"
height="64px"
id="svg2985"
version="1.1"
inkscape:version="0.48.4 r9939"
sodipodi:docname="New document 2">
<defs
id="defs2987">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="-27.490789 : 28.819006 : 1"
inkscape:vp_y="0 : 928.80024 : 0"
inkscape:vp_z="80.947862 : 32.534206 : 1"
inkscape:persp3d-origin="14.448897 : 22.627004 : 1"
id="perspective2997" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="5.5"
inkscape:cx="32"
inkscape:cy="32"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:window-width="1855"
inkscape:window-height="1056"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="1" />
<metadata
id="metadata2990">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<g
sodipodi:type="inkscape:box3d"
style="opacity:0.6;fill:#5aa02c"
id="g2999"
inkscape:perspectiveID="#perspective2997"
inkscape:corner0="0.34158251 : 0.027037199 : 0 : 1"
inkscape:corner7="-0.409304 : -0.0091649277 : 0.45725455 : 1">
<path
sodipodi:type="inkscape:box3dside"
id="path3009"
style="fill:#afafde;fill-rule:evenodd;stroke:none"
inkscape:box3dsidetype="13"
d="M 3.7705652,46.141475 43.509668,60.074322 59.845157,47.5915 23.388612,42.410997 z" />
<path
sodipodi:type="inkscape:box3dside"
id="path3001"
style="fill:#353564;fill-rule:evenodd;stroke:none"
inkscape:box3dsidetype="6"
d="m 3.7705652,21.078131 0,25.063344 19.6180468,-3.730478 0,-18.692379 z" />
<path
sodipodi:type="inkscape:box3dside"
id="path3011"
style="fill:#e9e9ff;fill-rule:evenodd;stroke:none"
inkscape:box3dsidetype="11"
d="m 23.388612,23.718618 36.456545,-8.21312 0,32.086002 -36.456545,-5.180503 z" />
<path
sodipodi:type="inkscape:box3dside"
id="path3003"
style="fill:#4d4d9f;fill-rule:evenodd;stroke:none"
inkscape:box3dsidetype="5"
d="M 3.7705652,21.078131 43.509668,3.1507197 59.845157,15.505498 23.388612,23.718618 z" />
<path
sodipodi:type="inkscape:box3dside"
id="path3007"
style="fill:#d7d7ff;fill-rule:evenodd;stroke:none"
inkscape:box3dsidetype="14"
d="m 43.509668,3.1507197 0,56.9236023 16.335489,-12.482822 0,-32.086002 z" />
<path
sodipodi:type="inkscape:box3dside"
id="path3005"
style="fill:#8686bf;fill-rule:evenodd;stroke:none"
inkscape:box3dsidetype="3"
d="M 3.7705652,21.078131 43.509668,3.1507197 l 0,56.9236023 L 3.7705652,46.141475 z" />
</g>
</g>
</svg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment