@@ -22,26 +22,39 @@ static gboolean serverinfo = false;
2222static  gboolean  printid  =  false;
2323static  guint32  replace_id  =  0 ;
2424static  guint32  close_id  =  0 ;
25- static  gboolean  block  =  false;
25+ static  gboolean  wait  =  false;
2626static  gchar  * * rest  =  NULL ;
27+ static  gboolean  transient  =  false;
28+ static  gboolean  say_version  =  false;
2729
2830static  GOptionEntry  entries [] = 
2931{
30-     { "appname" ,          'a' , 0 , G_OPTION_ARG_STRING ,         & appname ,        "Name of your application" , "NAME"  },
3132    { "urgency" ,          'u' , 0 , G_OPTION_ARG_STRING ,         & urgency_str ,    "The urgency of this notification" , "URG"  },
32-     { "hints" ,            'h' , 0 , G_OPTION_ARG_STRING_ARRAY ,   & hint_strs ,      "User specified hints" , "HINT"  },
33-     { "action" ,           'A' , 0 , G_OPTION_ARG_STRING_ARRAY ,   & action_strs ,    "Actions the user can invoke" , "ACTION"  },
34-     { "timeout" ,          't' , 0 , G_OPTION_ARG_INT ,            & timeout ,        "The time in milliseconds until the notification expires" , "TIMEOUT"  },
33+     { "expire-time" ,      't' , 0 , G_OPTION_ARG_INT ,            & timeout ,        "The time in milliseconds until the notification expires" , "TIMEOUT"  },
34+     { "app-name" ,         'a' , 0 , G_OPTION_ARG_STRING ,         & appname ,        "Name of your application" , "NAME"  },
3535    { "icon" ,             'i' , 0 , G_OPTION_ARG_STRING ,         & icon ,           "An icon that should be displayed with the notification" , "ICON"  },
36-     { "raw_icon " ,         'I' , 0 , G_OPTION_ARG_STRING ,         & raw_icon_path ,  "Path to the icon to be sent as raw image data" , "RAW_ICON" },
36+     { "raw-icon " ,         'I' , 0 , G_OPTION_ARG_STRING ,         & raw_icon_path ,  "Path to the icon to be sent as raw image data" , "RAW_ICON" },
3737    { "category" ,         'c' , 0 , G_OPTION_ARG_STRING ,         & category ,       "The category of this notification" , "TYPE"  },
38-     { "capabilities" ,     0 ,   0 , G_OPTION_ARG_NONE ,           & capabilities ,   "Print the server capabilities and exit" , NULL  },
39-     { "serverinfo" ,       's' , 0 , G_OPTION_ARG_NONE ,           & serverinfo ,     "Print server information and exit" , NULL  },
40-     { "printid" ,          'p' , 0 , G_OPTION_ARG_NONE ,           & printid ,        "Print id, which can be used to update/replace this notification" , NULL  },
41-     { "replace" ,          'r' , 0 , G_OPTION_ARG_INT ,            & replace_id ,     "Set id of this notification." , "ID"  },
38+     { "transient" ,        'e' , 0 , G_OPTION_ARG_INT ,            & transient ,      "Mark the notification as transient" , NULL  },
39+     { "hint" ,             'h' , 0 , G_OPTION_ARG_STRING_ARRAY ,   & hint_strs ,      "User specified hints" , "TYPE:NAME:VALUE"  },
40+     { "print-id" ,         'p' , 0 , G_OPTION_ARG_NONE ,           & printid ,        "Print id, which can be used to update/replace this notification" , NULL  },
41+     { "replace-id" ,       'r' , 0 , G_OPTION_ARG_INT ,            & replace_id ,     "Set id of this notification" , "ID"  },
42+     { "wait" ,             'w' , 0 , G_OPTION_ARG_NONE ,           & wait ,           "Block until notification is closed and print close reason" , NULL  },
43+     { "action" ,           'A' , 0 , G_OPTION_ARG_STRING_ARRAY ,   & action_strs ,    "Actions the user can invoke" , "ACTION"  },
4244    { "close" ,            'C' , 0 , G_OPTION_ARG_INT ,            & close_id ,       "Close the notification with the specified ID" , "ID"  },
43-     { "block" ,            'b' , 0 , G_OPTION_ARG_NONE ,           & block ,          "Block until notification is closed and print close reason" , NULL  },
44-     { G_OPTION_REMAINING , 0 ,   0 , G_OPTION_ARG_FILENAME_ARRAY , & rest ,            NULL , NULL  },
45+ 
46+     // Legacy names 
47+     { "hints" ,            0 , 0 , G_OPTION_ARG_STRING_ARRAY ,     & hint_strs ,      "Legacy alias of '--hint'" , "HINT"  },
48+     { "timeout" ,          0 , 0 , G_OPTION_ARG_INT ,              & timeout ,        "Legacy alias of '--expire-time'" , "TIMEOUT"  },
49+     { "printid" ,          0 , 0 , G_OPTION_ARG_NONE ,             & printid ,        "Legacy alias of '--print-id'" , NULL  },
50+     { "replace" ,          0 , 0 , G_OPTION_ARG_INT ,              & replace_id ,     "Legacy alias of '--replace-id'" , "ID"  },
51+     { "block" ,            'b' , 0 , G_OPTION_ARG_NONE ,           & wait ,           "Legacy alias of '--wait'" , NULL  },
52+     { "raw_icon" ,         0 , 0 , G_OPTION_ARG_STRING ,           & raw_icon_path ,  "Legacy alias of '--raw-icon'" , NULL  },
53+ 
54+     { "capabilities" ,     0 , 0 , G_OPTION_ARG_NONE ,             & capabilities ,   "Print the server capabilities and exit" , NULL  },
55+     { "serverinfo" ,       0 , 0 , G_OPTION_ARG_NONE ,             & serverinfo ,     "Print server information and exit" , NULL  },
56+     { "version" ,          'v' , 0 , G_OPTION_ARG_NONE ,           & say_version ,    "Print version information and exit" , NULL  },
57+     { G_OPTION_REMAINING , 0 , 0 , G_OPTION_ARG_FILENAME_ARRAY ,   & rest ,           NULL , NULL  },
4558    { NULL  }
4659};
4760
@@ -80,6 +93,11 @@ void print_serverinfo(void)
8093                                                                 spec_version );
8194}
8295
96+ void  print_version (void )
97+ {
98+     printf ("dunstify (shipped with Dunst %s)\n" , VERSION );
99+ }
100+ 
83101/* 
84102 * Glib leaves the option terminator "--" in the argv after parsing in some 
85103 * cases. This function gets the specified argv element ignoring the first 
@@ -131,6 +149,11 @@ void parse_commandline(int argc, char *argv[])
131149        die (0 );
132150    }
133151
152+     if  (say_version ) {
153+         print_version ();
154+         die (0 );
155+     }
156+ 
134157    if  (* appname  ==  '\0' ) {
135158        g_printerr ("Provided appname was empty\n" );
136159        die (1 );
@@ -280,6 +303,9 @@ int main(int argc, char *argv[])
280303    if  (category  !=  NULL )
281304        notify_notification_set_category (n , category );
282305
306+     if  (transient )
307+         notify_notification_set_hint (n , "transient" , g_variant_new_boolean (TRUE));
308+ 
283309    GError  * err  =  NULL ;
284310
285311    if  (raw_icon_path ) {
@@ -309,7 +335,7 @@ int main(int argc, char *argv[])
309335
310336    GMainLoop  * l  =  NULL ;
311337
312-     if  (block  ||  action_strs ) {
338+     if  (wait  ||  action_strs ) {
313339        l  =  g_main_loop_new (NULL , false);
314340        g_signal_connect (n , "closed" , G_CALLBACK (closed ), NULL );
315341    }
@@ -336,12 +362,12 @@ int main(int argc, char *argv[])
336362        fflush (stdout );
337363    }
338364
339-     if  (block  ||  action_strs )
365+     if  (wait  ||  action_strs )
340366        g_main_loop_run (l );
341367
342368    g_object_unref (G_OBJECT  (n ));
343369
344370    die (0 );
345371}
346372
347- /* vim: set ft=c tabstop=8  shiftwidth=8  expandtab textwidth=0: */ 
373+ /* vim: set ft=c tabstop=4  shiftwidth=4  expandtab textwidth=0: */ 
0 commit comments