#!/bin/bash #iManga-reader #You must have gnome (zenity 1.6 or above), gqview, unrar and unzip #programs installed on your system. #Wan Nor Arifin 2006 #gq1=gqview #gq2=`ps h -C gqview | awk '{print $5}'` tmp_folder=~/.iManga-reader-tmp ppid=$$ #check if another gqview is running #if [ "$gq1" = "$gq2" ]; then # number=`ps h -C $gq1 | awk '{print $1}'` # kill -9 $number # else # echo "gqview not running" #fi #Make temporary folder mkdir $tmp_folder if [ $? == 0 ]; then echo "Success" else echo "Directory exists!" #remove the temporary folder rm -rf $tmp_folder #It is important to remove and recreate the directory #since there are possibly some files inside the directory #from script crash. mkdir $tmp_folder fi #check for file types for file in "$@"; do case $file in #zip file *[.][zZ][iI][pP] ) echo "I find zip file!" ( unzip -j -o "$1" -d $tmp_folder if [ $? == 0 ]; then echo "Success" echo "100"; sleep 0.5 else echo "I'm broken" echo "100"; sleep 0.5 zenity --error --text="Sorry. I can't open this file." --title="Error" --width=200 --height=100 #remove the temporary folder rm -rf $tmp_folder kill $ppid fi ) | zenity --progress --pulsate --auto-close --text="Extracting..." --title="Please wait for a while." ;; #rar part *[.][rR][aAI][rR] ) echo "I find rar file!" ( unrar e -o+ "$1" -d $tmp_folder if [ $? == 0 ]; then echo "Success" echo "100"; sleep 0.5 else echo "I'm broken" echo "100"; sleep 0.5 zenity --error --text="Sorry. I can't open this file." --title="Error" --width=200 --height=100 #remove the temporary folder rm -rf $tmp_folder kill $ppid fi ) | zenity --progress --pulsate --auto-close --text="Extracting..." --title="Please wait for a while." ;; #unrecognised * ) echo "I'm broken badly!!!" zenity --error --text="Sorry. I can't recognize this file. You have to rename the file to something that I can recognize. :)" --title="Error" --width=200 --height=100 #remove the temporary folder rm -rf $tmp_folder exit 1 ;; esac done #open files with gqview gqview $tmp_folder #remove the temporary folder rm -rf $tmp_folder exit 0