I've added it to the wiki. I've also made some changes to the script:
added comments
all arguments after the filepath are now passed to feh, e.g. "/path/to/script %f -F -Z"
Thanks very much, maybe this little modification is useful if images are mixed with other files pdfs, txt, etc ?
#!/bin/bash
shopt -s nullglob
if [[ ! -f $1 ]]; then
echo "$0: first argument is not a file" >&2
exit 1
fi
file=$(basename -- "$1")
dir=$(dirname -- "$1")
arr=()
shift
cd -- "$dir"
frmt="*.jpg *.jpeg *.png *.bmp *.gif *.xcf *.ico *.tif *.tiff "
frmtall=${frmt}${frmt^^}
for i in $frmtall; do
[[ -f $i ]] || continue
arr+=("$i")
[[ $i == $file ]] && c=$((${#arr[@]} - 1))
done
exec feh "$@" -- "${arr[@]:c}" "${arr[@]:0:c}"
]]>feh --start-at ./%n
I've got it working fine on the command line as long as I'm in the directory where the image in question is located. I can't get it to work if I'm not working out of the same directory, neither by passing the relative nor the absolute path to the image. If I do, I get the error message:
feh ERROR: --start-at /path/to/foo.jpg: File not found in filelist
What I'd really like to get working though, is to be able to open the image straight from Thunar. I've tried using 'feh --start-at ./%f' as a custom command to open images but it does not work.
Using the script that's in the wiki now has worked just fine for me so far but if there's an easier way to get this functionality with feh, then I'll go with that.
]]>feh --start-at ./foo.jpg .
View all images in the current directory, starting with foo.jpg.
All other images are still in the slideshow and can be viewed
normallyfeh --start-at foo.jpg *
Same as above
The exact (and working) string I have in ~/.mc/bindings is
feh --start-at ./%p
...perhaps that should be added to the wiki?
I added it my self to the wiki. Hope this was OK:
"-F" and "-Z" are feh arguments. "-F" opens the image in fullscreen mode, and "-Z" autozooms the image. Adding the -q flag (quiet) suppresses error-messages to the terminal when feh tries loading non-image files in current folder.
Also, this script could be expanded with: "else-if TERM = linux use feh instead". This would make it very versatile with midnight commander. (alas, I'm no bash-scripting guru).
]]>
vandelay ~ $ ./feh2.sh zen.png
./feh.sh: line 5: [[ !: command not found
Just tried it again on a different computer, and that works fine. I'll try again on the other computer when I get home.
-q is another good argument for this script, since it suppresses any warnings if there are non-image files in the same folder (when browsing with the script). (perhaps that should be added to the wiki?)
Oops, thought you might have a different nick for the wiki (some of us do) and I didn't scroll down far enough to see otherwise.
I've noticed that it is difficult to have the same nick on AUR, Forum, and Wiki. I wish one could have the same on all three, since that would make everything a lot easier for everybody.
]]>thayer wrote:Xyne wrote:I've added it to the wiki. I've also made some changes to the script:
You've also broken the script
Look at the edit history. Lavandero broke it.
Oops, thought you might have a different nick for the wiki (some of us do) and I didn't scroll down far enough to see otherwise.
Here's a working version that incorporates Lavandero's changes: https://wiki.archlinux.org/index.php?ti … did=129544
I've also made some notes on the discussion page.
Thanks for the fix and I couldn't agree more about your comments.
]]>Xyne wrote:I've added it to the wiki. I've also made some changes to the script:
You've also broken the script
Look at the edit history. Lavandero broke it. If it weren't broken, I would be upset that he deleted the part that credits me as the original author.
Here's what I posted:
https://wiki.archlinux.org/index.php?ti … did=129228
*edit*
Here's a working version that incorporates Lavandero's changes: https://wiki.archlinux.org/index.php?ti … did=129544
I've also made some notes on the discussion page.
I've added it to the wiki. I've also made some changes to the script:
You've also broken the script
My bash foo is inferior, but when I use the wiki script I get:
/home/thayer/bin/fehbrowse: line 5: [[ !: command not found
feh loads, but displays the first image in the directory, not the one specified on the command line. The original script posted above however appears to work as expected.
]]>You did research before posting, so you're not a help vampire.
I just noticed that you asked for a way to do this "without a shell script"... oops.
Ha thanks. I definitely did try researching this before posting. I had found this thread from the Ubuntu forums with Google, discussing this very issue. I was wondering if there might be a simpler approach to this, hence why I asked if it was possible without a shell script. I had tried looking through the feh manpage to see if it was possible but didn't see a solution there.
I can definitely live with your shell script cause I'll at least be able to sit down and decipher it, unlike the one in the thread I just linked which has a solution written up in ruby (which I don't know two shakes about).
If you have any questions, feel free to post them here or send me a message.
Will do
]]>Ah, looks like I was beaten to the punch. Just wanted to give a little back so that I wasn't just being a help vampire there.
You did research before posting, so you're not a help vampire.
I just noticed that you asked for a way to do this "without a shell script"... oops.
Thanks a lot also for the addition of comments. Helps a lot with the learning and whatnot.
If you have any questions, feel free to post them here or send me a message.
]]>Thanks a lot also for the addition of comments. Helps a lot with the learning and whatnot.
]]>added comments
all arguments after the filepath are now passed to feh, e.g. "/path/to/script %f -F -Z"