Optional parameters for print command

This commit is contained in:
Moritz Lipp 2010-07-05 12:35:38 +02:00
parent 2dde57fcd7
commit 6d321e2ec5
2 changed files with 15 additions and 4 deletions

View File

@ -51,7 +51,7 @@ char* default_text = "[No Name]";
/* printing */
char* list_printer_command = "lpstat -v | sed -n '/^.*device for \\(.*\\): .*$/s//\\1/p'";
char* print_command = "lp -d '%s' -P %s '%s'"; /* printer / pages / file */
char* print_command = "lp -d '%s' -P %s '%s' %s"; /* printer / pages / file */
/* open uri */
char* uri_command = "firefox '%s'"; /* uri */

View File

@ -3162,9 +3162,20 @@ cmd_print(int argc, char** argv)
return FALSE;
}
char* printer = argv[0];
char* sites = (argc == 2) ? g_strdup(argv[1]) : g_strdup_printf("1-%i", Zathura.PDF.number_of_pages);
char* command = g_strdup_printf(print_command, printer, sites, Zathura.PDF.file);
char* printer = argv[0];
char* sites = (argc == 2) ? g_strdup(argv[1]) : g_strdup_printf("1-%i", Zathura.PDF.number_of_pages);
GString *addit = g_string_new("");
int i;
for(i = 2; i < argc; i++)
{
if(i != 0)
addit = g_string_append_c(addit, ' ');
addit = g_string_append(addit, argv[i]);
}
char* command = g_strdup_printf(print_command, printer, sites, addit->str, Zathura.PDF.file);
system(command);
g_free(sites);