#!/bin/bash #Company: PowerCraft Technology #Author: Copyright Jelle de Jong #Note: Please send me an email if you enhanced this script #Version: 0.0.2 #Date: 01-08-2006 / 01-10-07 #System: Ubuntu/Debian GNU/Linux #Information: man unrar, man par2, man file #Category Thunar scripts (thunar->edit->custom actions) #Name: Unrar or Par2 #Description: Unrar or par2 selected file(s) #Command: xfce4-terminal --disable-server --hide-toolbars --execute /usr/share/pct-thunar-scripts/scripts/unrar-par2 %F #Patterns: *.rar; *.par2 #Directories: False #Audio Files: False #Image Files: False #Text Files: False #Video Files: False #Other Files: True # Did the script work for you? # Yes # Yes, but with some errors # Yes, but I had to change some things # Not at all # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. TEXTDOMAINDIR=/usr/share/locale TEXTDOMAIN=${0##*/} NAME=$"Unrar or Par2" DESCRIPTION=$"Unrar or par2 selected file(s)" cecho() { case "$1" in "black") echo -ne "\E[30m" ;; "red") echo -ne "\E[31m" ;; "green") echo -ne "\E[32m" ;; "yellow") echo -ne "\E[33m" ;; "blue") echo -ne "\E[34m" ;; "magenta") echo -ne "\E[35m" ;; "cyan") echo -ne "\E[36m" ;; *) echo -ne "\E[30m" exit ;; esac echo "$2" "$3" tput sgr0 } cecho "green" $"program:" echo "$0" cecho "green" $"description:" echo "$DESCRIPTION" disk_busy_scan() { seconds=0 file="$HOME/.scripts/thunar/.diskbusy.txt" while [ -e "$file" ] do /bin/echo -e $"disk is busy, scanning $seconds please standby..." seconds=$(($seconds+10)) /bin/sleep 10 done } disk_busy_set() { file=$(mktemp -p $HOME/.scripts/thunar .diskbusy.txt) trap "rm -f $file" 0 1 2 3 15 echo $"diskbusy: $file indication set" } disk_busy_unset() { file="$HOME/.scripts/thunar/.diskbusy.txt" rm -f "$file" echo $"diskbusy: $file indication unset" } cecho "green" $"processing:" for I in "$@" do cecho "blue" "$I" done echo $"enter current working directory: " cecho "blue" "$PWD" cd "$PWD" for I in "$@" do echo $"starting with: " echo "$I" disk_busy_scan disk_busy_set filetype=$(file -b "$I" | cut -f 1 -d ",") echo $"file type is: " echo "$filetype" completed=0 if [ "$filetype" = "Par archive data" ] || [ "$filetype" = "Parity Archive Volume Set" ] then cecho "blue" $"repair par2 file" par2 r "$I" completed=1 fi if [ "$filetype" = "RAR archive data" ] then cecho "blue" $"extract rar file" unrar x "$I" completed=1 fi if [ ! $completed -eq 1 ] then cecho "red" $"error: nothing done: $file\n" error+=$"error: nothing done: $file\n" sleep=30 fi if [ $? -eq 1 ] then cecho "red" $"error: processing: $file\n" error+=$"error: processing: $file\n" fi disk_busy_unset cecho "green" $"completed with: " echo "$I" cecho "blue" "---------------" done cecho "red" "$error" cecho "green" -n $"done, do you want to exit [Y]? " read input if [ ! "$input" = "n" ] then cecho "green" $"done, exiting script" exit fi cecho "green" $"done, closing anyway" exit