Commit 193ce7fa authored by Martin Klimes (k11m1)'s avatar Martin Klimes (k11m1)
Browse files

fixed filters + modified structure to use options

parent a5ae47f2
......@@ -11,6 +11,8 @@ use Cwd qw(cwd);
use File::Path;
use File::Copy;
# use File::Chmod qw(chmod);
# NOTE to generate
#my $printers = LoadFile("printers.yml");
#print Dumper $printers;
......@@ -91,10 +93,14 @@ my $printers = {
my $models = {
'TA5007ci' => {
'filters' => [ 'kyofilter_pre_E', 'kyofilter_E' ]
'filters' => [ 'kyofilter_pre_E', 'kyofilter_E' ],
},
'TA4505ci' => {
'filters' => ['kyofilter_B']
'filters' => ['kyofilter_B'],
'options' => [ 'Option19=One', 'Option21=True', 'Option17=DF730' ]
},
'hp-laserjet-600' => {
'options' => ['HPOption_Duplexer=True'],
}
};
......@@ -213,6 +219,11 @@ sub generic_printer {
-o sides-default=two-sided-long-edge \\
-o auth-info-required=username,password);
foreach ( $models->{ $printers->{$printer_name}->{'model'} }->{'options'} )
{
$command = $command . ' -o $_ ';
}
system($command);
return;
......@@ -222,18 +233,22 @@ sub copy_filter {
( my $filter ) = @_;
# my $filter = "kyofilter_B";
my $destination = "/usr/libexec/cups/filter/";
$destination = "first/second/";
#my $destination = "/usr/libexec/cups/filter/";
my $destination = "/usr/lib/cups/filter/";
# $destination = "first/second/";
if ( !-d $destination ) {
my $dirs = eval { mkpath($destination) };
die "Failed to create $destination $@\n" unless $dirs;
}
copy( "filters" . $filter, $destination )
copy( "filters/" . $filter, $destination )
or die "Failed to copy $filter: $!\n";
say "[OK] Copied $filter.";
chmod( 755, $destination . $filter );
return;
}
......@@ -353,19 +368,19 @@ if ( $model eq "TA5007ci" ) {
}
if ( $model eq "TA4505ci" ) {
TA_4505ci("$printer_name");
generic_printer("$printer_name");
}
elsif ( $model eq "hp-laserjet-600" ) {
hp_laserjet_600 $printer_name;
generic_printer $printer_name;
}
else {
generic_printer("$printer_name");
}
# NOTE there was a problem before // THIS DOESNT WORK?
foreach ( $models->{$model}->{'filters'} ) {
foreach (@$_) {
say $_;
say "Selected model is $_";
copy_filter($_);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment