summaryrefslogtreecommitdiffstats
path: root/abs/extra/dolphin-emu/dolphin-emu_scan.sh
blob: 804553e00d63e52363ad60da4a1a8008751bb9fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
#----------------------------------------------------------------------------
. /etc/osd_cat.cfg || {
        color=yellow
        outline=2
        outlinecolour=black
        shadow=0
        shadowcolour=black
        font="-adobe-helvetica-bold-*-*-*-34-*-*-*-*-*-*-*"
}
#----------------------------------------------------------------------------
EXTNS=('[eE][lL][fF]' '[dD][oO][lL]' '[gG][cC][mM]' '[iI][sS][oO]' '[cC][iI][sS][oO]' '[gG][cC][zZ]' '[wW][aA][dD]')
DIR=/myth/games/dolphin-emu/roms
rm -fr /tmp/dolphin*
echo -e "Scanning for games." | osd_cat --pos=middle --align=center --delay=2 --color=$color --outline=$outline --outlinecolour=$outlinecolour --shadow=$shadow --shadowcolour=$shadowcolour --font=$font &
for EXT in ${EXTNS[@]}
do
	if [ -d "$DIR" ]; then
	cd $DIR
	ls *.$EXT >> /tmp/dolphin-emu.games 
	fi
done
sleep 3
if [ -s /tmp/dolphin-emu.games ]; then
	echo -e "Creating menu." | osd_cat --pos=middle --align=center --delay=2 --color=$color --outline=$outline --outlinecolour=$outlinecolour --shadow=$shadow --shadowcolour=$shadowcolour --font=$font &
	sleep 3
else
	echo -e "No games detected. Ensure you have your files in $DIR." | osd_cat --pos=middle --align=center --delay=4 --color=$color --outline=$outline --outlinecolour=$outlinecolour --shadow=$shadow --shadowcolour=$shadowcolour --font=$font &
	sleep 5
	exit 0
fi

echo "<mythmenu name=\"DOLPHIN\">" > /tmp/dolphin-emu_games.xml

while read line
do
	echo "  <button>" >> /tmp/dolphin-emu_games.xml
	echo "    <type>MENU_DOLPHIN</type>" >> /tmp/dolphin-emu_games.xml
	echo "    <text>$(echo "$line"  | sed 's/.\{4\}$//')</text>" >> /tmp/dolphin-emu_games.xml
	echo "    <action>EXEC /usr/bin/dolphin-emu -b -e $DIR/$(echo "$line" | sed "s/'/\\\\'/g" | sed 's/ /\\ /g')</action>" >> /tmp/dolphin-emu_games.xml
	echo "  </button>" >> /tmp/dolphin-emu_games.xml
done < /tmp/dolphin-emu.games
echo "</mythmenu>" >> /tmp/dolphin-emu_games.xml
sudo mv /tmp/dolphin-emu_games.xml /usr/share/mythtv/themes/defaultmenu/
echo -e "Menu created." | osd_cat --pos=middle --align=center --delay=2 --color=$color --outline=$outline --outlinecolour=$outlinecolour --shadow=$shadow --shadowcolour=$shadowcolour --font=$font &
sleep 2