1 /* Copyright (C) 2011 Edward Der-Hua Liu, Hsin-Chu, Taiwan
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation version 2.1
6  * of the License.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
16  */
17 
18 #include "hime.h"
19 
main(int argc,char ** argv)20 int main (int argc, char **argv) {
21     int i;
22     char text[128];
23     char icon[128];
24     int duration = 3000;
25 
26     gdk_init (&argc, &argv);
27 
28     if (argc < 3)
29         p_err ("usage: hime-message -icon file_name -text string -duration milli_seconds\n");
30 
31     strcpy (text, "-");
32     strcpy (icon, "-");
33 
34     for (i = 1; i < argc; i += 2) {
35         if (!strcmp (argv[i], "-icon")) {
36             strcpy (icon, argv[i + 1]);
37         } else if (!strcmp (argv[i], "-text")) {
38             strcpy (text, argv[i + 1]);
39         } else if (!strcmp (argv[i], "-duration")) {
40             duration = atoi (argv[i + 1]);
41         } else {
42             dbg ("unknown opt %s", argv[i]);
43         }
44     }
45 
46     char message[512];
47 
48     snprintf (message, sizeof (message), "#hime_message %s %s %d", icon, text, duration);
49 
50     send_hime_message (GDK_DISPLAY (), message);
51 
52     return 0;
53 }
54