17 printf("e-notify-send "VERSION"\n");
24 " e-notify-send [OPTION...] <SUMMARY> [BODY] - create a notification\n"
27 " -?, --help Show help options\n"
29 "Application Options:\n"
30 " -n, --name=NAME Specifies the application name to use (default is e-notify-send).\n"
31 " -u, --urgency=LEVEL Specifies the urgency level (low, normal, critical).\n"
32 " -t, --expire-time=TIME Specifies the timeout in milliseconds at which to expire the notification.\n"
33 " -r, --replace=ID Specifies the ID of notification to replace.\n"
34 " -p, --print-id Prints the ID of notification to STDOUT.\n"
35 " -i, --icon=ICON Specifies an icon filename or stock icon to display.\n"
36 " -c, --category=TYPE Specifies the notification category.\n"
37 " -v, --version Version of the package.\n"
42 read_int_arg(long long *result, const char *name, intmax_t min, intmax_t max)
47 *result = strtoll(optarg, &endptr, 10);
48 if ((errno != 0 && *result == 0) || endptr == optarg)
50 fprintf(stderr, "Cannot parse integer value '%s' for %s\n", optarg, name);
53 else if (*result > max || *result < min)
55 fprintf(stderr, "Integer value '%s' for %s out of range\n", optarg, name);
63 send_cb(void *user_data __UNUSED__, void *method_return, DBusError *error __UNUSED__)
65 E_Notification_Return_Notify *r = method_return;
70 printf("%u\n", r->notification_id );
72 ecore_main_loop_quit();
76 main(int argc, char **argv)
83 e_notification_init();
84 n = e_notification_new();
85 e_notification_app_name_set(n, "e-notify-send");
86 e_notification_timeout_set(n, -1);
88 /* options descriptor */
89 static struct option longopts[] = {
90 { "help", no_argument, NULL, '?' },
91 { "name", required_argument, NULL, 'n' },
92 { "urgency", required_argument, NULL, 'u' },
93 { "expire-time", required_argument, NULL, 't' },
94 { "replace", required_argument, NULL, 'r' },
95 { "print-id", no_argument, NULL, 'p' },
96 { "icon", required_argument, NULL, 'i' },
97 { "category", required_argument, NULL, 'c' },
98 { "version", no_argument, NULL, 'v' },
102 while ((ch = getopt_long(argc, argv, "p?vn:u:t:r:i:c:", longopts, NULL)) != -1)
113 e_notification_app_name_set(n, optarg);
116 if (!strcasecmp(optarg, "low"))
117 e_notification_hint_urgency_set(n, E_NOTIFICATION_URGENCY_LOW);
118 else if (!strcasecmp(optarg, "normal"))
119 e_notification_hint_urgency_set(n, E_NOTIFICATION_URGENCY_NORMAL);
120 else if (!strcasecmp(optarg, "critical"))
121 e_notification_hint_urgency_set(n, E_NOTIFICATION_URGENCY_CRITICAL);
123 printf("Urgency level must be: low, normal or critical\n");
126 if (!read_int_arg(&value, "-t", INT_MIN, INT_MAX))
129 e_notification_timeout_set(n, (int)value);
132 if (!read_int_arg(&value, "-r", 0, UINT_MAX))
135 e_notification_replaces_id_set(n, (unsigned int)value);
138 e_notification_app_icon_set(n, optarg);
141 e_notification_hint_category_set(n, optarg);
159 e_notification_summary_set(n, argv[0]);
160 if (argc > 1) e_notification_body_set(n, argv[1]);
165 e_notification_send(n, send_cb, NULL);
166 ecore_main_loop_begin();
169 e_notification_send(n, NULL, NULL);
171 e_notification_unref(n);
172 e_notification_shutdown();