summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuang Peng <shawn.p.huang@gmail.com>2008-06-20 13:31:29 +0800
committerHuang Peng <shawn.p.huang@gmail.com>2008-06-20 13:31:29 +0800
commitdc88529bb57ac78a3d22e8a7d85478d32cbafd69 (patch)
treea8d44d536a3944cee21c6941fb775406c82d7c08
parent0dad9dcb3357223527537a952d4b0e59644cb852 (diff)
downloadibus-dc88529bb57ac78a3d22e8a7d85478d32cbafd69.tar.gz
ibus-dc88529bb57ac78a3d22e8a7d85478d32cbafd69.tar.xz
ibus-dc88529bb57ac78a3d22e8a7d85478d32cbafd69.zip
Add arguments for panel.
-rw-r--r--panel/ibus-panel.in2
-rw-r--r--panel/main.py37
2 files changed, 36 insertions, 3 deletions
diff --git a/panel/ibus-panel.in b/panel/ibus-panel.in
index 07a61d7..8206d40 100644
--- a/panel/ibus-panel.in
+++ b/panel/ibus-panel.in
@@ -1,2 +1,2 @@
#!/bin/sh
-python @prefix@/share/ibus/panel/main.py
+python @prefix@/share/ibus/panel/main.py $@
diff --git a/panel/main.py b/panel/main.py
index 26ebc20..6ff4857 100644
--- a/panel/main.py
+++ b/panel/main.py
@@ -19,6 +19,9 @@
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
+import os
+import sys
+import getopt
import ibus
import gtk
import dbus
@@ -45,11 +48,41 @@ class PanelApplication:
gtk.main_quit ()
-def main ():
+
+def launch_panel ():
+ dbus.mainloop.glib.DBusGMainLoop (set_as_default=True)
# gtk.settings_get_default ().props.gtk_theme_name = "/home/phuang/.themes/aud-Default/gtk-2.0/gtkrc"
# gtk.rc_parse ("./themes/default/gtkrc")
PanelApplication ().run ()
+def print_help (out, v = 0):
+ print >> out, "-h, --help show this message."
+ print >> out, "-d, --daemonize daemonize ibus"
+ sys.exit (v)
+
+def main ():
+ daemonize = False
+ shortopt = "hd"
+ longopt = ["help", "daemonize"]
+ try:
+ opts, args = getopt.getopt (sys.argv[1:], shortopt, longopt)
+ except getopt.GetoptError, err:
+ print_help (sys.stderr, 1)
+
+ for o, a in opts:
+ if o in ("-h", "--help"):
+ print_help (sys.stdout)
+ elif o in ("-d", "--daemonize"):
+ daemonize = True
+ else:
+ print >> sys.stderr, "Unknown argument: %s" % o
+ print_help (sys.stderr, 1)
+
+ if daemonize:
+ if os.fork ():
+ sys.exit ()
+
+ launch_panel ()
+
if __name__ == "__main__":
- dbus.mainloop.glib.DBusGMainLoop (set_as_default=True)
main ()