You are not logged in.
Pages: 1
Topic closed
I'm trying to use feh to browse images, as I'm sure you could gather from the subject. I want to be able to click on an image in a folder and then be able to use the left and right arrow keys to browse the other images in that folder. I would think that this would be fairly easy to figure out but I've spent way too much time googling this and haven't really found exactly what I'm looking for.
I found this old forum post asking to do the same thing. The last post mentions implementing this with Thunar (which would be great since that's what I use) but it mentions the use of a "%d" parameter, which I can not see mention of in the feh manpage. Also the little shell script is nice but it just starts browsing the images from the first file in the directory, not what I'm looking for. Is there a way to do this without a shell script?
Last edited by Eiki (2011-01-28 16:26:48)
Offline
The %d is handled by Thunar, not feh.
aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies
Offline
Well shoot, that would explain why I didn't see it in the feh manpage, wouldn't it?
So by using the custom command "feh -F -Z %d", I got the image to open up and then I could cycle through the images, which is fine, but they're all out of order. I tried "feh -F -Z -S filename %d" and it starts from the beginning of the folder, which is not what I want. Any other suggestions out there?
Offline
I think '%d' is a Thunar custom action parameter.
Offline
*edit*
This is now on the Feh wiki page.
Try this:
#!/bin/bash
# Change the input field separator to avoid problems with spaces.
IFS='
'
# Get the target file, its name, directory, and the other files in the
directory.
_fpath="${1/%\/}"
_fname="$(basename "$_fpath")"
_dpath="$(dirname "$_fpath")"
_flist=($(ls "$_dpath"))
# Determine the index of the target file in the file list array.
_i=0
for _file in "${_flist[@]}"; do
[ "$_file" == "$_fname" ] && break
_i=$(($_i + 1))
done
# Remove the target file from the arguments, leaving any eventual arguments to
# feh.
shift
# Change to the directory and launch feh with the target file as the first
# argument, and the rest of the files in their normal order.
cd "$_dpath"
feh "$@" "${_flist[@]:$_i}" "${_flist[@]:0:$_i}"
Invoke it with the image path, e.g. "/path/to/script %f -F -Z". It should open that image in feh and let you browse through other images in the folder in the usual order, i.e. "feh /path/to/dir/*".
Last edited by Xyne (2011-01-28 15:46:19)
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Hey thanks a lot, it works perfectly. I really appreciate it. I hate to admit it but my scripting skills are pretty much nonexistent at this point but I am trying to learn. Ha, I guess this'll give me something to study.
Offline
One final chime-in from me, do you guys think it would be worth it for me to add that script to the feh wiki page?
Offline
You mean the arch wiki?
https://wiki.archlinux.org/index.php/Feh
I think it sounds like a swell idea, if Xyne approves.
Offline
yes please. Please give Xyne the appropriate credit though. Forum threads tend to get lost after a while, if it's on the wiki, it will be much more accessible.
There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !
Offline
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"
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
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.
Thanks a lot also for the addition of comments. Helps a lot with the learning and whatnot.
Offline
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.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
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
Last edited by Eiki (2011-01-28 17:26:26)
Offline
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.
thayer williams ~ cinderwick.ca
Offline
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.
Last edited by Xyne (2011-02-01 11:07:44)
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
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.
thayer williams ~ cinderwick.ca
Offline
The script works fine for me, but with the version I copied yesterday (sometime during 12:00-17:00 Feb 1`) I get this warning:
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.
Offline
...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).
Last edited by penguin (2011-02-09 14:25:35)
Offline
For the record, the required functionality can be achieved with the --start-at command line option of feh.
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
“First principle, Clarice. Simplicity” – Dr. Hannibal Lecter
Offline
So I'm trying out the --start-at solution again after initially being unsuccessful when it was first posted and still not able to get it to work how I want it to. Maybe someone can tell me what I'm doing wrong.
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.
Offline
The parameter %f returns the full path of the file, but feh doesn’t accept full path at the --start-at option. (That’s why I use %p, not %f in mc.) In thunar, try this custom command:
feh --start-at ./%n
“First principle, Clarice. Simplicity” – Dr. Hannibal Lecter
Offline
It works! Thanks very much.
Offline
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}"
Offline
Please use code tags. And don't bump old threads. You could edit the wiki (if this still exists there, which I can't be bothered checking). In any case, closing for necrobump.
Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.
Offline
Pages: 1
Topic closed