Ticket #225: emulator_screenshots21.sh

File emulator_screenshots21.sh, 2.3 KB (added by jochen, 16 years ago)

2.1 small bug fixed

Line 
1#!/bin/sh
2
3DBUSER=root;
4DBPWD=
5DBNAME=mythconverg
6
7
8TMPFILE=/tmp/tmp.png
9
10case "$1" in
11
12 start)
13
14  WERTE=`echo "SELECT playername FROM gameplayers" | mysql -B --database=$DBNAME --password=$DBPWD --user=$DBUSER -N`;
15
16  for player in $WERTE
17   do
18 
19    ROMPATH=`echo "SELECT rompath FROM gameplayers WHERE playername = '$player'" | mysql -B --database=$DBNAME --password=$DBPWD --user=$DBUSER -N`
20    COMMANDLINE=`echo "SELECT commandline FROM gameplayers WHERE playername = '$player'" | mysql -B --database=$DBNAME --password=$DBPWD --user=$DBUSER -N`
21    EXTENSIONS=`echo "SELECT extensions FROM gameplayers WHERE playername = '$player'" | mysql -B --database=$DBNAME --password=$DBPWD --user=$DBUSER -N`
22    SCREENSHOTS=`echo "SELECT screenshots FROM gameplayers WHERE playername = '$player'" | mysql -B --database=$DBNAME --password=$DBPWD --user=$DBUSER -N`
23   
24    cmdpfad=$(dirname "$(echo $COMMANDLINE | cut -d "-" -f 1)")
25    cmdprgname=$(basename "$(echo $COMMANDLINE | cut -d "-" -f 1)")
26    cmdparameter=${COMMANDLINE:$((`echo "$cmdpfad" | wc -m`+`echo "$cmdprgname" | wc -m`-1)):`echo "$COMMANDLINE" | wc -m`}
27    cmdrun=`echo "$cmdpfad/$cmdprgname"`
28   
29    if [ "$ROMPATH" ]; then
30      #if [ "$player" = "GBA" ]; then
31        for i in $ROMPATH/*.*
32         do
33         COMMAND="start-stop-daemon --exec $cmdrun --start --background -- $cmdparameter"
34         $COMMAND "$i"     
35         path="`expr "$i" : '\(.*\)/'`"                  # get file path (if any)
36         name="`expr "//$i" : '.*/\([^/]*\)'`"           # remove path to file
37         suffix="`expr "$name" : '.*\.\([^./]*\)$'`"     # extract last suffix
38         name="`expr "$name" : '\(.*\)\.[^.]*$'`"        # remove last suffix
39         picname=$name.png
40
41        sleep 10
42     
43        scrot --quality 1 $TMPFILE
44        mv $TMPFILE "$SCREENSHOTS/$picname"
45        killall -9 $cmdrun
46        sleep 1
47        done
48      #fi
49    fi
50  done
51  ;;
52 
53  *)
54  echo ""
55  echo "This is a Script to generate Screenshots for your Emulators, wich"
56  echo "you have set up in MythTV automaticaly. It uses the program scrot"
57  echo "to generate the screenshot."
58  echo ""
59  echo "To run you had to enter: emulator_screenshots start"
60  echo "Bevor running, check the username and passwort in the script"
61  echo "Also the timeout until the screenshot is taken can be adjusted"
62  ;;
63esac