source: gutenbach-queue/lib/queue @ e87e682

debianmacno-cupsweb
Last change on this file since e87e682 was e87e682, checked in by Jessica B. Hamrick <jhamrick@…>, 14 years ago

Move debian folder into the root, and move all non-debian code into gutenbach-queue/

  • Property mode set to 100755
File size: 1.7 KB
Line 
1#!/bin/bash
2
3found_current=
4
5if [ -e "/var/run/gutenbach/queue_times" ]; then
6    rm "/var/run/gutenbach/queue_times"
7fi
8
9if [ -e /usr/lib/gutenbach/config/printername ]; then
10    printername=$(cat /usr/lib/gutenbach/config/printername)
11
12    cd /var/spool/lpd/"$printername"/
13    for i in $(ls . | grep ^hf); do
14        done=$(cat "$i" | grep done)
15    if [ ! -n "$done" ]; then
16        timestamp=$(cat "$i" | grep ^job_time= | sed 's/.*=//')
17        echo "$timestamp:$i" >> /var/run/gutenbach/queue_times
18    fi
19    done
20
21    if [ -e /var/run/gutenbach/queue_times ]; then
22        for i in $(sort /var/run/gutenbach/queue_times); do
23            i=$(echo "$i" | sed 's/.*://')
24            prefix="df"${i:2}
25            for j in "$prefix"*; do song="$j"; done
26
27            user=$(cat "$i" | grep ^P=)
28            user=${user:2}
29           
30            if [ -e /var/run/gutenbach/exiftool_data ]; then
31                rm /var/run/gutenbach/exiftool_data
32            fi
33
34            exiftool "$song" >> /var/run/gutenbach/exiftool_data
35            title=$(cat /var/run/gutenbach/exiftool_data | grep "^Title " | sed 's/.*: //')
36            artist=$(cat /var/run/gutenbach/exiftool_data | grep "^Artist " | sed 's/.*: //')
37
38            if [ -z "$found_current" ]; then
39                host=$(cat "$i" | grep ^H=)
40                host=${host:2}
41                filenm="$(cat $i | grep "^filenames" | sed -e 's/filenames=//')"
42                album=$(cat /var/run/gutenbach/exiftool_data | grep "^Album " | sed 's/.*: //')
43                echo "$user@$host is currently playing: "
44                echo "$filenm"
45                echo "'$title'"
46                echo "by '$artist'"
47                echo "on '$album'"
48                echo ""
49                echo "Coming up in the queue:"
50                found_current="true" 
51            else
52                echo "$user: '$title' by '$artist'"
53            fi
54        done
55    fi
56else
57    echo "Error: Printer name configuration file /usr/lib/gutenbach/config/printername does not exist!"
58    exit 1
59fi
Note: See TracBrowser for help on using the repository browser.