#!/bin/sh
progdir=$(cd $(dirname $0); pwd)
a=`cat /mnt/mmc/Roms/APPS/Dark/data.txt`
if grep -q "video_filter =" /mnt/mmc/CFW/retroarch/.retroarch/retroarch.cfg; then
	if [[ "$a" == "" ]]; then
		sed -i -e '/video_filter =/c video_filter = \"\"' /mnt/mmc/CFW/retroarch/.retroarch/retroarch.cfg
	else
		sed -i -e '/video_filter =/{r /mnt/mmc/Roms/APPS/Dark/data.txt' -e 'd}' /mnt/mmc/CFW/retroarch/.retroarch/retroarch.cfg
	fi
else
	echo -e"\nvideo_filter = \"\"" >> /mnt/mmc/CFW/retroarch/.retroarch/retroarch.cfg
	if [[ ! "$a" == "" ]]; then
		sed -i -e '/video_filter =/{r /mnt/mmc/Roms/APPS/Dark/data.txt' -e 'd}' /mnt/mmc/CFW/retroarch/.retroarch/retroarch.cfg
	fi
fi
cp -f $progdir/Dark/夜间模式-已关闭.sh $progdir
rm -f $0
$progdir/Dark/printstr "夜间模式-已关闭"
sleep 2
sync
