Add restart and exit commands in ibus tools
authorPeng Huang <shawn.p.huang@gmail.com>
Wed, 4 Jan 2012 15:52:28 +0000 (10:52 -0500)
committerPeng Huang <shawn.p.huang@gmail.com>
Tue, 21 Feb 2012 16:51:52 +0000 (11:51 -0500)
tools/ibus.bash
tools/main.vala

index 02303a9..18e9d6c 100644 (file)
@@ -108,7 +108,7 @@ __ibus()
     # echo "cwords='${cwords[@]}'"
 
     # Commands
-    local cmds=( engine list-engine watch )
+    local cmds=( engine list-engine watch restart exit )
 
     local i c cmd subcmd
     for (( i=1; i < ${#words[@]}-1; i++)) ; do
index ba2fe67..575542c 100644 (file)
@@ -118,6 +118,18 @@ int message_watch(string[] argv) {
     return 0;
 }
 
+int restart_daemon(string[] argv) {
+    var bus = get_bus();
+    bus.exit(true);
+    return 0;
+}
+
+int exit_daemon(string[] argv) {
+    var bus = get_bus();
+    bus.exit(false);
+    return 0;
+}
+
 delegate int EntryFunc(string[] argv);
 
 struct CommandEntry {
@@ -129,7 +141,9 @@ public int main(string[] argv) {
     const CommandEntry commands[]  = {
         { "engine", get_set_engine },
         { "list-engine", list_engine },
-        { "watch", message_watch }
+        { "watch", message_watch },
+        { "restart", restart_daemon },
+        { "exit", exit_daemon }
     };
 
     if (argv.length >= 2) {