# HG changeset patch # User Babaorum # Date 1306764614 -3600 # Node ID cc32aec9351e51a8a4208b1132aad429fb6a25ef # Parent c9f517d25721d987c33a12512a2cce75cc3be8d6 Baba scripts diff -r c9f517d25721 -r cc32aec9351e baba-scripts/edf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/baba-scripts/edf Mon May 30 15:10:14 2011 +0100 @@ -0,0 +1,34 @@ +#!/bin/sh + +MAIN_DIALOG=' + + + + + + +' +I=$IFS; IFS=$'\n' +for line in `df -h | tail -n +2 | grep ^/dev/ | sed -e "s/ \+/|/g"` +do + device=`echo $line | cut -d'|' -f1` + total=`echo $line | cut -d'|' -f2` + occupied=`echo $line | cut -d'|' -f3` + free=`echo $line | cut -d'|' -f4` + ratio=`echo $line | cut -d'|' -f5` + mount=`echo $line | cut -d'|' -f6` + MAIN_DIALOG=$MAIN_DIALOG" + $device|$mount|$total|$occupied|$ratio|$free" +done +IFS=$I +MAIN_DIALOG=$MAIN_DIALOG' + + + + +' +export MAIN_DIALOG + +gtkdialog -p MAIN_DIALOG + + diff -r c9f517d25721 -r cc32aec9351e baba-scripts/rename.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/baba-scripts/rename.pl Mon May 30 15:10:14 2011 +0100 @@ -0,0 +1,22 @@ +#! /usr/bin/perl +$testmode = 0; #false +if ($ARGV[0] eq '-t') { + $testmode = 1; #true + shift; +} +($regexp = shift @ARGV) || die "Usage: rename [-t] perlexpr [filenames]\n-t : option to test action (nothing really done)\n"; +if (!@ARGV) { + @ARGV = ; + chomp(@ARGV); +} +print "Test mode\n" if ($testmode); +foreach $_ (@ARGV) { + $old_name = $_; + eval $regexp; + die $@ if $@; + unless ($old_name eq $_) { + print "$old_name -> $_\n"; + rename($old_name, $_) unless $testmode; + } +} +exit(0); diff -r c9f517d25721 -r cc32aec9351e baba-scripts/reninc.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/baba-scripts/reninc.pl Mon May 30 15:10:14 2011 +0100 @@ -0,0 +1,45 @@ +#! /usr/bin/perl +#check for help +chomp (my $workdir = `pwd`); +chomp (my $scriptname=`basename "$0"`); +scalar @ARGV > 0 || die < 0) +{ + my $arg = shift @ARGV; + if ($arg eq "-p") { $pref = shift @ARGV; next; } + elsif ($arg eq "-s") { $suff = shift @ARGV; next; } + elsif ($arg eq "-d") { $start = shift @ARGV; next; } + elsif ($arg eq "-n") { $num_length = shift(@ARGV) - 1; next; } + elsif (-d $arg) { $dir = shift @ARGV; next; } + elsif ($arg eq "here") { $dir = $workdir; next; } +} +#main routine +chdir $dir; +foreach (<*>) +{ + my $counter = $start; + my ($purename, $ext) = (m/^(.+?)\.([^\.]+)$/); + for (my $n = 1; $n <= $num_length; $n++) + { + last if ($num_length eq 0); + if ($start < 10**$n) { $counter = '0'.$counter; } + } + $start++; + print "Rename \"$_\" in $pref$counter$suff.$ext\n"; + rename $_, $pref.$counter.$suff.'.'.$ext; +} diff -r c9f517d25721 -r cc32aec9351e baba-scripts/renup.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/baba-scripts/renup.pl Mon May 30 15:10:14 2011 +0100 @@ -0,0 +1,59 @@ +#! /usr/bin/perl -w +chomp (my $scriptname = `basename "$0"`); +chomp (my $workdir = `pwd`); +my $help = <); +} +#look for subdirectories in $workdir +print "Scanning subdirectories in $workdir...\n"; +chdir $workdir; +foreach $f (<*>) +{ + my $path = $workdir.'/'.$f; + if (-d $path) + { + chdir $path; + my @all = <*>; + my @regularfiles = grep { -f } @all; + printf "\n> %s : %d files\n", $f, scalar @regularfiles; + next if (scalar @regularfiles == 0); #skip if empty + #parse numeric part of $path to use in rename.pl's pattern + $path =~ /(\d+)/; + my $num = $1; + system 'rename.pl '.($testmode == 1? '-t ':'').'"s/^/'.$prefix.$num.'_/" *'; #call rename.pl + #update files data (changed because of renaming) + @all = <*>; + @regularfiles = grep { -f } @all; + #~ print join ("\n", @regularfiles), "\n"; + map { rename $_, $workdir.'/'.$_ } @regularfiles unless ($testmode); #move files one level up + #check for subdirectory inside + if (scalar (grep { -d } @all) > 0) { warn "Caution: subdirectory found in $f => not deleted\n"; next; } + chdir $workdir; + unless ($testmode) { rmdir $path or die "$!\n"; } + } +} diff -r c9f517d25721 -r cc32aec9351e baba-scripts/xdf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/baba-scripts/xdf Mon May 30 15:10:14 2011 +0100 @@ -0,0 +1,39 @@ +#!/bin/sh +field() { + textwidth=`length "$1"` + freewidth=$(( $2 - $textwidth )) + fieldtext="$1" + position=${3-after} + for i in `seq 1 $freewidth`; do + case $position in + before) fieldtext=" $fieldtext" ;; + after) fieldtext="$fieldtext " ;; + esac + done + echo "$fieldtext" +} +#df -h | grep ^/dev/ | grep -v ^/dev/root | sed "s/ \+/ /g" | while read line; do +df -h | grep ^/dev/ | sed "s/ \+/ /g" | while read line; do + device=`echo $line | cut -d' ' -f1` + device=`field $device 8` + size=`echo $line | cut -d' ' -f2` + size=`field $size 6 before` + used=`echo $line | cut -d' ' -f3` + used=`field $used 6 before` + free=`echo $line | cut -d' ' -f4` + free=`field $free 6 before` + usepercent=`echo $line | cut -d' ' -f5` + usebar="|" + counter=`expr ${usepercent%\%} '/' 10` + for i in `seq 1 $counter`; do + usebar="${usebar}>" + done + for i in `seq $counter 9`; do + usebar="${usebar}." + done + usebar="${usebar}|" + usepercent=`field $usepercent 4 before` + mntpoint=`echo $line | cut -d' ' -f6` + mntpoint=`field "($mntpoint)" 20` + echo "$device $mntpoint $used/$size $usebar $usepercent - $free free" +done diff -r c9f517d25721 -r cc32aec9351e baba-scripts/yaff --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/baba-scripts/yaff Mon May 30 15:10:14 2011 +0100 @@ -0,0 +1,198 @@ +#!/bin/sh +BIN=`which firefox` +PROFILE_DIR=$HOME/.mozilla/firefox +CONFDIR=$HOME/.yaff +VERCONF=$CONFDIR/versions.conf +PROFCONF=$CONFDIR/profiles.conf +INSTANCES=`ps | grep firefox-bin | grep -v 'grep firefox-bin' | grep -v /bin/sh | wc -l` +[ $INSTANCES -gt 0 ] && NOREMOTE='-no-remote' || NOREMOTE='' +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' +PROFILES="" + +add_new_versions() { + local tmp=`mktemp -t -p $CONFDIR` + ADD_VERSIONS=' + + + + + VERNUMBER + + + +' + export ADD_VERSIONS + gtkdialog --program=ADD_VERSIONS &> $tmp + cat $tmp + [ -f "$tmp" ] && rm -f $tmp +} + +[ ! -d "$CONFDIR" ] && mkdir -p $CONFDIR +#~ [ ! -f "$VERCONF" -o `stat -c %s $VERCONF` -eq 0 ] && add_new_versions +[ ! -f "$VERCONF" -o `stat -c %s $VERCONF` -eq 0 ] + +[ ! -f "$PROFCONF" ] && touch $PROFCONF; echo -n "" > $PROFCONF +for firefox in $FIREFOX +do + version=`echo $firefox | cut -d '#' -f 1` + exec=`echo $firefox | cut -d '#' -f 2` + profile=`echo $firefox | cut -d '#' -f 3` + echo "$profile|$version" >> $PROFCONF + [ -n "$profile" -a "$profile" != "" ] && echo "$version|$profile" >> $PROFCONF +done + + +MAIN_DIALOG=' + + + + + + PROFIL' +[ ! -d $PROFILE_DIR ] && echo "Directory $PROFILE_DIR not found" >&2 && exit 1 +cd $PROFILE_DIR +for dir in $(ls -F $PROFILE_DIR | grep -iv "Crash" | grep -iv "reports" | grep \/$ | grep -v "~/$") +#~ for dir in $(echo "$PROFILES") +do + [ ! -d $dir -o ! -r $dir ] && continue + dir=${dir#*.} + MAIN_DIALOG=${MAIN_DIALOG}''${dir%%/}'' +done +MAIN_DIALOG=$MAIN_DIALOG' + + + + + ' +for firefox in $FIREFOX +do + version=`echo $firefox | cut -d '#' -f 1` + exec=`echo $firefox | cut -d '#' -f 2` + profile=`echo $firefox | cut -d '#' -f 3` + radio='F'${version//./_}'' + #echo $radio + MAIN_DIALOG=$MAIN_DIALOG$radio +done +MAIN_DIALOG=$MAIN_DIALOG' + + + + + + + + + + + DEFAULT_PROFILE' +for firefox in $FIREFOX +do + version=`echo $firefox | cut -d'#' -f1` + exec=`echo $firefox | cut -d'#' -f2` + profile=`echo $firefox | cut -d'#' -f3` + MAIN_DIALOG=$MAIN_DIALOG"$version|$profile" +done +MAIN_DIALOG=$MAIN_DIALOG' + + + + + + + ENTRY_VERSION_NUMBER + + + + + + + + ENTRY_VERSION_BIN + + + + + + + + ENTRY_VERSION_DEFAULT_PROFILE + + + + + + + + + + + + + + + + + + + + + + + + + + +' +export MAIN_DIALOG +VARIABLES=$(gtkdialog --program=MAIN_DIALOG) +eval $VARIABLES +for firefox in $FIREFOX +do + version=`echo $firefox | cut -d '#' -f 1` + bin=`echo $firefox | cut -d '#' -f 2` + profile=`echo $firefox | cut -d '#' -f 3` + name_var="F${version}" + name_var=${name_var//./_} + eval "version_var=\$$name_var" + if [ "$version_var" = "true" ] + then + BIN=$bin + if [ -n $profile -a "$profile" != "" -a "$PROFIL" = "" ]; then + PROFIL=$profile + export ALERT_DIALOG=' + + + + + + ' + gtkdialog --program=ALERT_DIALOG + fi + break + fi +done +if [ $EXIT = "OK" -a "$PROFIL" != "" ] +then + echo "$BIN $NOREMOTE -P \"$PROFIL\" 1>/dev/null 2>&1" + $BIN $NOREMOTE -P "$PROFIL" 1>/dev/null 2>&1 +fi