#!/bin/sh # # Fehfourite is a wrapper that loads feh with a sorted list of files as # an argument. # Files are only included from the current directory. Sorting works as # follows: # First file is the one that as been passed to this wrapper as an argument. # From here on all the files which follow alphabetically are added. Once the # last file is reached, files from the beginning of the alphabet up till the # original file are queued. # This means that the once feh is running, the rest of the directory's images # can be viewed as well - just like in any other bloated image-viewer (gqview, # gthumb, etc.). # TODO # The main loop needs to be reduced by variables and arrays. One array shoul # be sufficient. All the counters can be evaluated upon use. # version 0.4 # - complete rewrite using arrays instead of temp-files # which enhances the speed enourmosly. # - whitespaced filenames work fine # - reduced mem-usage # - fixed wrong regex pattern that caused trouble useing whitespaced # filenames # version 0.1 # - fixed most of the cirical issues # - heavy sed-usage # version 0.0 # - initial version, not really usable # Make sure we're in the right directory FOLDER=$(echo "$1" | sed -r 's/[^/]*\.\w*$//') cd $FOLDER INFILE=$(echo "$1" | sed -e 's/.*\///') echo echo $FOLDER echo echo $INFILE echo # Unique tmp-file FEHTMP=feh_tmp_$(date +%s) # First we need an array of all the files in the current directory count=0 for i in * do let count="$count"+1 FILES[$count]="$i" done # how many files did we find? let max="$count" # some initialisation count=0 count2=0 count3=0 # better: for elemtent in FILES-array for FILE_LIST in * do let count="$count"+1 if [ "$FILE_LIST" = "$INFILE" ] then # fill post-and pre arrays for l in `seq $count $max` do let count2="$count2"+1 BACK[$count2]="${FILES[$l]}" done for m in `seq 1 $count` do let count3="$count3"+1 FRONT[$count3]="${FILES[$m]}" done # output arrays to tmp-file # # from current image the last... let max2="$max"-"$count"+1 for n in `seq 1 $max2` do echo ${BACK[$n]} >> $HOME/$FEHTMP done # ...and then appending the first to current (aka wrap-around) for o in `seq 1 $count` do echo ${FRONT[$o]} >> $HOME/$FEHTMP done # take this! "feh -f -Z -g 1024x768 $HOME/$FEHTMP" # clean the tmp-file once we're finished rm $HOME/$FEHTMP exit 0 fi done