autostart

This commit is contained in:
j 2016-04-14 12:57:45 +02:00
commit 0551a18cc9
6 changed files with 69 additions and 10 deletions

View file

@ -2,7 +2,7 @@
import os
from os.path import dirname, abspath
import subprocess
import time
import sys
import webbrowser
import gi
@ -26,7 +26,8 @@ class OMLIcon:
icon = None
indicator = None
def __init__(self):
def __init__(self, autostart=False):
self.autostart = autostart
if appindicator:
self.indicator = appindicator.Indicator.new("OML", icon,
appindicator.IndicatorCategory.APPLICATION_STATUS)
@ -40,7 +41,8 @@ class OMLIcon:
self.icon.connect("activate", self._click)
self.icon.connect("popup-menu", self._click)
subprocess.Popen([ctl, 'start'])
GLib.timeout_add_seconds(1, self._open, None)
if not self.autostart:
GLib.timeout_add_seconds(1, self._open, None)
GLib.timeout_add_seconds(60, self._check, None)
def _check(self, *args, **kwargs):
@ -85,5 +87,7 @@ class OMLIcon:
webbrowser.open_new_tab(url)
self.menu = None
OMLIcon()
Gtk.main()
if __name__ == '__main__':
autostart = len(sys.argv) > 1 and sys.argv[1] == '--autostart'
OMLIcon(autostart)
Gtk.main()