Archive menu

Hi, I hope this is the right location.

A screenshot speaks better than me

You can view, open, open in dir and extract a single file.

What you need:
a function ,
two bash scripts,
some utilities (p7zip, unrar, gzip …) and
ROX-Filer (or maybe you can find other ways)

[color=darkred]function[/color]

[code]DestroyFunc FuncArchive
AddToFunc FuncArchive

  • I PipeRead ‘$[fvwm_scripts]/archive-menu.sh $0’
  • I Popup MenuArchive[/code]
    [color=darkred]archive-menu.sh[/color]

[code]#!/bin/bash

FILE=$1
PRG="$fvwm_scripts/extract.sh"
TYPE=file -b $FILE 2>/dev/null | cut -b -10 | grep -o "Zip\|7z\|RAR\|tar\|bzip2\|gzip"
FDIR=basename $FILE | sed -e's/.[Zz][Ii][Pp]$\|.7z$\|.7z.001$\|.tar.bz2$\|.tar.gz$\|.bz2$\|.gz$\|.[Rr][Aa][Rr]$\|.tar$\|.tbz2$\|.tgz$//'

printf “DestroyMenu recreate MenuArchive\nChangeMenuStyle Archive MenuArchive\n”
if [ -z $TYPE ] ;
then
printf “AddToMenu MenuArchive " basename $FILE is not an archive " Title\n” ;
else
printf “AddToMenu MenuArchive " Archive type is $TYPE " Title\n+ " " Nop\n+ “> extract” Exec exec $PRG x $FILE\n” ;
printf “+ “> extract in $FDIR/” Exec exec $PRG e $FILE\n+ " " Nop\n” ;
for i in $PRG l $FILE | sed -e's/[\ |\&]/**/g' ;
do
echo “+ “$i” Exec exec $PRG s $FILE $i”
done ;
echo “+ " " Nop”
fi

exit 0[/code][list][list]Put this one in your config if you use a [color=orange]MenuStyle[/color]DestroyMenu MenuArchive AddToMenu MenuArchive
or change line 8 [list][color=olive]printf “DestroyMenu recreate MenuArchive\nChangeMenuStyle [/color][color=orange]Archive[/color][color=olive] MenuArchive\n”[/color][/list:u]if you don’t .
[/list:u][/list:u]

[color=darkred]extract.sh[/color]

[code]#!/bin/bash

ARG=$1
FILE=$2
SFILE=$3
TYPE=file -b $FILE 2>/dev/null | cut -b -10 | grep -o "Zip\|7z\|RAR\|tar\|bzip2\|gzip"
FDIR=basename $FILE | sed -e's/.[Zz][Ii][Pp]$\|.7z$\|.7z.001$\|.tar.bz2$\|.tar.gz$\|.bz2$\|.gz$\|.[Rr][Aa][Rr]$\|.tar$\|.tbz2$\|.tgz$//'
STRIP=echo $3 | grep -o / | wc -l

cd dirname $FILE

case $TYPE in
7z|Zip) pName=“7za”
case $ARG in
e) $pName x -o$FDIR $FILE ;;
l) $pName l $FILE | sed -e’1,8d;/-$/d;$d’ | cut -c 54- ;;
s) $pName e $FILE $SFILE ;;
x) $pName x $FILE ;;
esac ;;
RAR) pName=“unrar”
case $ARG in
e) $pName e $FILE $FDIR/ ;;
l) $pName lb $FILE ;;
s) $pName e $FILE $SFILE ;;
x) $pName x $FILE ;;
esac ;;
tar) pName=“tar”
case $ARG in
e) $pName -xf $FILE -C $FDIR/ ;;
l) $pName -tf $FILE ;;
s) $pName --strip-components $STRIP -xf $FILE $SFILE ;;
x) $pName -xf $FILE ;;
esac ;;
bzip2) pName=“tar”
case $ARG in
e) mkdir $FDIR | $pName -xjf $FILE -C $FDIR/ || bzip2 -dck $FILE > $FDIR/basename $FDIR ;;
l) $pName -tjf $FILE 2>/dev/null || 7za l $FILE | sed -e’1,8d;/-$/d;$d’ | cut -c 54- ;;
s) $pName --strip-components $STRIP -xjf $FILE $SFILE || bzip2 -dck $FILE > basename $FDIR ;;
x) $pName -xjf $FILE || bzip2 -dck $FILE > basename $FDIR ;;
esac ;;
gzip) case $ARG in
e) if [ -n $(tar -tzf $FILE) 2>/dev/null ] ;
then
7za x -o$FDIR $FILE ;
else
mkdir $FDIR | tar -xzf $FILE -C $FDIR/ ;
fi ;;
l) if [ -n $(tar -tzf $FILE) 2>/dev/null ] ;
then
7za l $FILE | sed -e’1,8d;/-$/d;$d’ | cut -c 54- ;
else
tar -tzf $FILE ;
fi ;;
s) if [ -n $(tar -tzf $FILE) 2>/dev/null ] ;
then
7za e $FILE $SFILE ;
else
tar --strip-components $STRIP -xzf $FILE $SFILE ;
fi ;;
x) if [ -n $(tar -tzf $FILE) 2>/dev/null ] ;
then
7za x $FILE ;
else
tar -xzf $FILE ;
fi ;;
esac ;;
esac

exit 0[/code]
Finally (ROX): select an archive RightMouseButton > [color=blue]Set Run Action[/color]FvwmCommand "FuncArchive $@"

[color=red][size=125]Warnings:[/size][/color]
[list=1][]Remove spaces (and other special char.) from the archive filename.[/:m][]Don’t worry if the desktop seems to be locked with big archive.Wait.[/:m][/list:o]

As you can see the scripts are dirty hacks (several workaround).
I’m not a programmer: please don’t bite me.

Maybe there’s a better way: C, Python anyone?

Sorry for my funky english, ciao.

[color=red]Edited by theBlackDragon:
–> about 90% is bash, so moving from Complex functions to Other languages :slight_smile:[/color]