You are not logged in.

#1 2013-11-12 20:15:08

mich04
Member
From: Illinois - United States
Registered: 2011-10-25
Posts: 390

Using feh to open images in pcmanfm [solved]

Hello,
So I have started to utilize scripts to perform task. I was trying to set up feh to view images in pcmanfm, but I seem to be having some problems. I did look at the wiki
https://wiki.archlinux.org/index.php/Fe … age_viewer

and saw the script

#!/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"

for i in *; do
	[[ -f $i ]] || continue
	arr+=("$i")
	[[ $i == $file ]] && c=$((${#arr[@]} - 1))
done

exec feh "$@" -- "${arr[@]:c}" "${arr[@]:0:c}"

I was trying to open pictures up to resize in the window so they are not so zoomed in. I tried to open the photo with a custom command of

feh -g 640x480 -d -S 

how do I combine this command with the above script?  And also how do I delete the custom commands that I created in pcmanfm.

Last edited by mich04 (2013-11-14 02:36:24)


I love computers, networking and Arch Linux. Sometimes I might ask a stupid question, but please have grace with me like I would with you.

Offline

#2 2013-11-13 00:34:02

dodo3773
Member
Registered: 2011-03-17
Posts: 820

Re: Using feh to open images in pcmanfm [solved]

What happens if you just change the last line? The one that starts exec. Like this:

exec feh -g 640x480 -d -S filename "$@" -- "${arr[@]:c}" "${a    rr[@]:0:c}"

Assuming filename is the one you want to sort by even though you did not specify (since that is default).

Offline

#3 2013-11-13 02:32:10

mich04
Member
From: Illinois - United States
Registered: 2011-10-25
Posts: 390

Re: Using feh to open images in pcmanfm [solved]

this might be a silly question but what do you mean by "assuming filename" I just want to view my pictures but have them resized in the window, but also be able to switch to the picture before and after the one I selected.


I love computers, networking and Arch Linux. Sometimes I might ask a stupid question, but please have grace with me like I would with you.

Offline

#4 2013-11-13 02:42:53

dodo3773
Member
Registered: 2011-03-17
Posts: 820

Re: Using feh to open images in pcmanfm [solved]

mich04 wrote:

this might be a silly question but what do you mean by "assuming filename" I just want to view my pictures but have them resized in the window, but also be able to switch to the picture before and after the one I selected.

Well what I mean is that in your custom command ( feh -g 640x480 -d -S ) the last switch "-S" takes an argument. The default argument is "filename" (-S being sort image by... ). Different options for that switch (name,filename,etc..etc...) you can find in the man page or gnu long options (--help switch I mean).

Offline

#5 2013-11-13 03:10:05

mich04
Member
From: Illinois - United States
Registered: 2011-10-25
Posts: 390

Re: Using feh to open images in pcmanfm [solved]

ok thank, I dont think this script is what I am looking for, I just want to click on a picture and have it open in feh and have it be resized to fit in the window. Do you know how to delete custom commands in pcmanfm "open file with..." "custom command"


I love computers, networking and Arch Linux. Sometimes I might ask a stupid question, but please have grace with me like I would with you.

Offline

#6 2013-11-13 03:17:43

dodo3773
Member
Registered: 2011-03-17
Posts: 820

Re: Using feh to open images in pcmanfm [solved]

mich04 wrote:

ok thank, I dont think this script is what I am looking for, I just want to click on a picture and have it open in feh and have it be resized to fit in the window. Do you know how to delete custom commands in pcmanfm "open file with..." "custom command"

I have no idea as I do not use pcmanfm. In thunar it is all in the "open with" menu. Just right click and remove launcher. Surprised there isn't something similar in pcmanfm. I can't really help much more I don't think. Probably something simple though keep digging in the options

Offline

#7 2013-11-14 02:09:38

mich04
Member
From: Illinois - United States
Registered: 2011-10-25
Posts: 390

Re: Using feh to open images in pcmanfm [solved]

when I was refering to a "custom command" I was refering to pcmans "open with" you can select a program or run a custom command to open files. I tried to use

feh -g 640x480 -d -S 

as the open with custom command on a JPG file, but it just opens up a terminal really fast and closes without actually opening the JPG. When I access a JPG from the terminal with that command it opens the picture exactly how I want it.


I love computers, networking and Arch Linux. Sometimes I might ask a stupid question, but please have grace with me like I would with you.

Offline

#8 2013-11-14 02:12:17

mich04
Member
From: Illinois - United States
Registered: 2011-10-25
Posts: 390

Re: Using feh to open images in pcmanfm [solved]

I am guesing it is doing that because it is not actually adding the filename to the end of

feh -g 640x480 -d -S 

I love computers, networking and Arch Linux. Sometimes I might ask a stupid question, but please have grace with me like I would with you.

Offline

#9 2013-11-14 02:36:04

mich04
Member
From: Illinois - United States
Registered: 2011-10-25
Posts: 390

Re: Using feh to open images in pcmanfm [solved]

I found the solution in this post from willwolfe I needed to run the script through a .desktop file in /usr/share/applications
https://bbs.archlinux.org/viewtopic.php?id=145354  also need to edit the script using dodo3773's original suggestion so it looks like this


#!/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"

for i in *; do
	[[ -f $i ]] || continue
	arr+=("$i")
	[[ $i == $file ]] && c=$((${#arr[@]} - 1))
done

exec feh -g 640x480 "$@" -- "${arr[@]:c}" "${arr[@]:0:c}" 

I love computers, networking and Arch Linux. Sometimes I might ask a stupid question, but please have grace with me like I would with you.

Offline

#10 2013-11-14 18:41:44

dodo3773
Member
Registered: 2011-03-17
Posts: 820

Re: Using feh to open images in pcmanfm [solved]

Oh cool. Glad you sorted it out.

Offline

Board footer

Powered by FluxBB