debianmacno-cupsweb
Last change
on this file since 6157f97 was
6157f97,
checked in by Jessica B. Hamrick <jhamrick@…>, 14 years ago
|
Modify queue to be a perl script using Net::CUPS
|
-
Property mode set to
100755
|
File size:
1.3 KB
|
Rev | Line | |
---|
[6157f97] | 1 | #!/usr/bin/perl |
---|
| 2 | |
---|
| 3 | use Net::CUPS; |
---|
| 4 | use Net::CUPS::Destination; |
---|
| 5 | use Image::ExifTool qw(ImageInfo); |
---|
| 6 | |
---|
| 7 | use strict; |
---|
| 8 | use warnings; |
---|
| 9 | |
---|
| 10 | use vars qw/$queue/; |
---|
| 11 | require "/usr/lib/gutenbach/config/gutenbach-filter-config.pl" or die "Unable to load configuration"; |
---|
| 12 | |
---|
| 13 | my $cups = Net::CUPS->new(); |
---|
| 14 | my $printer = $cups->getDestination("$queue"); |
---|
| 15 | my @jobs = $printer->getJobs( 0, 0 ); |
---|
| 16 | my $job_ref; |
---|
| 17 | my $jobid; |
---|
| 18 | my $attr; |
---|
| 19 | |
---|
| 20 | my $jobnum = 0; |
---|
| 21 | foreach $jobid(@jobs) |
---|
| 22 | { |
---|
| 23 | $job_ref = $printer->getJob($jobid); |
---|
| 24 | my $filepath = "/var/spool/cups/d0$job_ref->{'id'}-001"; |
---|
| 25 | my $fileinfo = ImageInfo($filepath); |
---|
| 26 | my $magic = $fileinfo->{FileType}; |
---|
| 27 | |
---|
| 28 | if ($jobnum == 0) |
---|
| 29 | { |
---|
| 30 | print $job_ref->{'user'}." is currently playing:\n"; |
---|
| 31 | print "\t".$magic." file ".$job_ref->{'title'}."\n"; |
---|
| 32 | |
---|
| 33 | if ($magic) |
---|
| 34 | { |
---|
| 35 | foreach my $key (qw/Title Artist Album AlbumArtist/) |
---|
| 36 | { |
---|
| 37 | if (exists $fileinfo->{$key}) |
---|
| 38 | { |
---|
| 39 | print "\t$fileinfo->{$key}\n"; |
---|
| 40 | } |
---|
| 41 | } |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | print "\nComing up the queue:\n\n"; |
---|
| 45 | } |
---|
| 46 | else |
---|
| 47 | { |
---|
| 48 | if ($magic) |
---|
| 49 | { |
---|
| 50 | my $user = $job_ref->{'user'}; |
---|
| 51 | my $title = $fileinfo->{'Title'}; |
---|
| 52 | my $artist = $fileinfo->{'Artist'}; |
---|
| 53 | my $album = $fileinfo->{'Album'}; |
---|
| 54 | print "$user: \"$title\" by \"$artist\" on \"$album\"\n"; |
---|
| 55 | } |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | $jobnum += 1; |
---|
| 59 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.