slitaz-dev-tools view baba-scripts/yaff @ rev 118

tazwikiss: avoid duplicate files with wkp_Upload.sh
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Jun 17 13:05:26 2011 +0200 (2011-06-17)
parents cc32aec9351e
children 01fb349cd0ac
line source
1 #!/bin/sh
2 BIN=`which firefox`
3 PROFILE_DIR=$HOME/.mozilla/firefox
4 CONFDIR=$HOME/.yaff
5 VERCONF=$CONFDIR/versions.conf
6 PROFCONF=$CONFDIR/profiles.conf
7 INSTANCES=`ps | grep firefox-bin | grep -v 'grep firefox-bin' | grep -v /bin/sh | wc -l`
8 [ $INSTANCES -gt 0 ] && NOREMOTE='-no-remote' || NOREMOTE=''
9 FIREFOX='3.5.7#/usr/bin/firefox 3.6#/home/gg/apps/firefox-3.6/firefox 4#/home/gg/apps/firefox-4/firefox#Firefox-4b'
10 PROFILES=""
12 add_new_versions() {
13 local tmp=`mktemp -t -p $CONFDIR`
14 ADD_VERSIONS='
15 <window title="Yaff - Add new versions">
16 <vbox>
17 <hbox>
18 <text width-request="100"><label>Version number</label></text>
19 <entry width-request="20"><variable>VERNUMBER</variable></entry>
20 </hbox>
21 <button ok></button>
22 </vbox>
23 </window>'
24 export ADD_VERSIONS
25 gtkdialog --program=ADD_VERSIONS &> $tmp
26 cat $tmp
27 [ -f "$tmp" ] && rm -f $tmp
28 }
30 [ ! -d "$CONFDIR" ] && mkdir -p $CONFDIR
31 #~ [ ! -f "$VERCONF" -o `stat -c %s $VERCONF` -eq 0 ] && add_new_versions
32 [ ! -f "$VERCONF" -o `stat -c %s $VERCONF` -eq 0 ]
34 [ ! -f "$PROFCONF" ] && touch $PROFCONF; echo -n "" > $PROFCONF
35 for firefox in $FIREFOX
36 do
37 version=`echo $firefox | cut -d '#' -f 1`
38 exec=`echo $firefox | cut -d '#' -f 2`
39 profile=`echo $firefox | cut -d '#' -f 3`
40 echo "$profile|$version" >> $PROFCONF
41 [ -n "$profile" -a "$profile" != "" ] && echo "$version|$profile" >> $PROFCONF
42 done
45 MAIN_DIALOG='
46 <window title="Yet Another Firefox" window_position="1">
47 <vbox>
48 <notebook labels="Choose a profile|Information">
49 <vbox>
50 <list selection-mode="2">
51 <variable>PROFIL</variable>'
52 [ ! -d $PROFILE_DIR ] && echo "Directory $PROFILE_DIR not found" >&2 && exit 1
53 cd $PROFILE_DIR
54 for dir in $(ls -F $PROFILE_DIR | grep -iv "Crash" | grep -iv "reports" | grep \/$ | grep -v "~/$")
55 #~ for dir in $(echo "$PROFILES")
56 do
57 [ ! -d $dir -o ! -r $dir ] && continue
58 dir=${dir#*.}
59 MAIN_DIALOG=${MAIN_DIALOG}'<item>'${dir%%/}'</item>'
60 done
61 MAIN_DIALOG=$MAIN_DIALOG'
62 </list>
63 <text>
64 <label>'$INSTANCES' running instance(s) of Firefox detected.</label>
65 </text>
66 <hbox homogeneous="true">'
67 for firefox in $FIREFOX
68 do
69 version=`echo $firefox | cut -d '#' -f 1`
70 exec=`echo $firefox | cut -d '#' -f 2`
71 profile=`echo $firefox | cut -d '#' -f 3`
72 radio='<radiobutton><label>'$version'</label><variable>F'${version//./_}'</variable></radiobutton>'
73 #echo $radio
74 MAIN_DIALOG=$MAIN_DIALOG$radio
75 done
76 MAIN_DIALOG=$MAIN_DIALOG'
77 </hbox>
78 <hbox>
79 <button>
80 <input file>/usr/share/pixmaps/mozicon16.png</input>
81 <label>Launch Firefox</label>
82 <action>Exit:OK</action>
83 </button>
84 <button>
85 <input file icon="gtk-quit"></input>
86 <label>Quit</label>
87 <action type="CloseWindow">MAIN_DIALOG</action>
88 </button>
89 </hbox>
90 </vbox>
92 </vbox>
94 <vbox>
95 <frame>
96 <text use-markup="true" width-chars="30" height-request="50">
97 <label>"<i>Copyleft [^c] 2010 Babaorum</i>"</label>
98 </text>
99 <text use-markup="true" width-chars="30">
100 <label>"<b>YAFF (Yet Another Firefox)</b>"</label>
101 </text>
102 <text>
103 <label>lets you launch many instances of Firefox in different versions with different profiles.</label>
104 </text>
105 </frame>
106 <hbox>
107 <button>
108 <input file icon="gtk-quit"></input>
109 <label>Quit</label>
110 <action type="CloseWindow">MAIN_DIALOG</action>
111 </button>
112 </hbox>
113 </vbox>
114 </notebook>
115 </vbox>
116 </window>'
117 export MAIN_DIALOG
118 VARIABLES=$(gtkdialog --program=MAIN_DIALOG)
119 eval $VARIABLES
120 for firefox in $FIREFOX
121 do
122 version=`echo $firefox | cut -d '#' -f 1`
123 bin=`echo $firefox | cut -d '#' -f 2`
124 profile=`echo $firefox | cut -d '#' -f 3`
125 name_var="F${version}"
126 name_var=${name_var//./_}
127 eval "version_var=\$$name_var"
128 if [ "$version_var" = "true" ]
129 then
130 BIN=$bin
131 if [ -n $profile -a "$profile" != "" -a "$PROFIL" = "" ]; then
132 PROFIL=$profile
133 export ALERT_DIALOG='
134 <window title="CAUTION !" window_position="1">
135 <vbox>
136 <text use-markup="true"><label>"Profile for this version will be locked on: <b>'$PROFIL'</b>"</label></text>
137 <button ok></button>
138 </vbox>
139 </window>'
140 gtkdialog --program=ALERT_DIALOG
141 fi
142 break
143 fi
144 done
145 if [ $EXIT = "OK" -a "$PROFIL" != "" ]
146 then
147 echo "$BIN $NOREMOTE -P \"$PROFIL\" 1>/dev/null 2>&1"
148 $BIN $NOREMOTE -P "$PROFIL" 1>/dev/null 2>&1
149 fi