From 6d321e2ec5d0248b5f5b85502fd89d0fc06841d7 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Mon, 5 Jul 2010 12:35:38 +0200 Subject: [PATCH] Optional parameters for print command --- config.def.h | 2 +- zathura.c | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/config.def.h b/config.def.h index c41a376..d4d8838 100644 --- a/config.def.h +++ b/config.def.h @@ -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 */ diff --git a/zathura.c b/zathura.c index 0e60fc1..cff4370 100644 --- a/zathura.c +++ b/zathura.c @@ -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);