From 9c9f0c07a2c376f812473400b7d7520cc711e545 Mon Sep 17 00:00:00 2001 From: Till Kamppeter Date: Sun, 12 Aug 2001 00:08:52 +0000 Subject: "Expert Mode" button, better "Remote CUPS server" dialog, bugfixes --- perl-install/printer.pm | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'perl-install/printer.pm') diff --git a/perl-install/printer.pm b/perl-install/printer.pm index 208fd55b6..a592dbcb8 100644 --- a/perl-install/printer.pm +++ b/perl-install/printer.pm @@ -430,6 +430,50 @@ sub read_cups_options ($) { } #------------------------------------------------------------------------------ + +sub read_cups_printer_list { + # This function reads in a list of all printers which the local CUPS + # daemon currently knows, including remote ones. + local *F; + open F, ($::testing ? "$prefix" : "chroot $prefix/ ") . + "lpstat -v |" || return (); + my @printerlist = (); + my $line; + while ($line = ) { + if ($line =~ m/^\s*device\s+for\s+([^:\s]+):\s*(\S+)\s*$/) { + my $queuename = $1; + my $comment = ""; + if ($2 =~ m!^ipp://([^/:]+)[:/]!) { + $comment = _("(on %s)", $1); + } else { + $comment = _("(on this machine)"); + } + push (@printerlist, "$queuename $comment"); + } + } + close F; + return @printerlist; +} + +sub get_cups_default_printer { + local *F; + open F, ($::testing ? "$prefix" : "chroot $prefix/ ") . + "lpstat -d |" || return undef; + my $line; + while ($line = ) { + if ($line =~ /^\s*system\s*default\s*destination:\s*(\S*)$/) { + return $1; + } + } + return undef; +} + +sub set_cups_default_printer { + my $default = $_[0]; + run_program::rooted($prefix, "lpoptions", + "-d", $default) || return; +} + sub read_cupsd_conf { my @cupsd_conf; local *F; -- cgit v1.2.1