You are not logged in.

#301 2013-06-01 15:35:54

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: sxiv - Simple image viewer written in C

On my sxiv-patches repo on GitHub you can now also find a patch that adds Pango support to sxiv - something I wanted considering I also switched DWM and dmenu over to Pango.

Cheers.


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#302 2013-06-02 22:11:04

LuX
Member
From: France
Registered: 2010-06-14
Posts: 79

Re: sxiv - Simple image viewer written in C

Hello

I'm answering to myself.

LuX wrote:

1) Exif information view.
Note: Apparently this is already available in version 1.1, thanks for that, but only 1.0-3 is available at the moment in [Community] thus I haven't tested it yet.

No, this is not available but it is explained in the manpage how to customize the status bar, a very nice feature that I didn't notice at first. Thus I obtained what I wanted by putting the following in ~/.sxiv/exec/image-info.

#!/bin/sh

filename=$(basename "$1")
filesize=$(du -Hh "$1" | cut -f 1)
dategeom=$(identify -format "%[EXIF:DateTimeOriginal] | %[width]x%[height]" $1)

echo "$filename | $dategeom ($filesize)" | sed 's/|[ |]*/| /g' 
LuX wrote:

2) Easier customization with .config/sxivrc file instead of config.h.

3) * Last but not least! *
Interactive (that means with file name completion) 'open file' command, like vim's ':edit' or zathura's ':open'.

It's probably a question of taste but I'm quite surprised that this last feature is not available by default. Every document viewer I know, even the most 'suckless' ones, have such an 'open' feature.

I have seen at various places a script which allows to browse through all the images of a directory after a given image in this directory has been opened using sxiv, but this is quite different. I haven't seen any way to launch sxiv with no argument (for example from dmenu instead of ranger) and then browse through the file tree in order to choose and open an image file.

Best regards,
LuX

Last edited by LuX (2013-06-15 22:34:27)

Offline

#303 2013-06-02 22:15:59

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: sxiv - Simple image viewer written in C

Do you mean something like

    /* open current image with given program: */
    { true,   XK_g,             it_open_with,         (arg_t) "gimp" },

in config.h but with a filename completion?

Many shells have such completion, so why not use them?

Last edited by karol (2013-06-02 22:18:17)

Offline

#304 2013-06-04 21:08:31

LuX
Member
From: France
Registered: 2010-06-14
Posts: 79

Re: sxiv - Simple image viewer written in C

Hello!

karol wrote:

Do you mean something like

I really mean something like :edit in vim or :open in zathura.

karol wrote:

Many shells have such completion, so why not use them?

Is sxiv required to be launched from a terminal emulator or a file manager? Why should it be?

There are several widely used habits in viewing documents on a PC:
- some people first open a terminal emulator and then type a command which links a program name to a file name;
- some people first look for a document (using a file manager) and then for a program to open it;
- some people, including me, first open a document viewer and then look from inside it for the document(s) they want to see.

This last category of people is very large. Some of them launch a document viewer using the applications menu or an icon in a panel, others --more suckless addicts wink-- prefer to define key bindings for their favourite programs or a text-based launcher like dmenu, or whatever. But for ALL of them an 'open' function is mandatory in every document viewer. This is probably the reason why all the document viewers that I know provide natively this feature.

Sxiv is the only exception I ever met, and as I already said I do regret this because I really like this image viewer.

Regards,
LuX

Last edited by LuX (2013-06-05 11:27:10)

Offline

#305 2013-06-04 21:14:25

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: sxiv - Simple image viewer written in C

LuX wrote:

Is sxiv required to be launched from a terminal emulator or a file manager? Why should it be?

Because its author wants it this way?

Offline

#306 2013-06-05 11:25:26

LuX
Member
From: France
Registered: 2010-06-14
Posts: 79

Re: sxiv - Simple image viewer written in C

@karol: The authors made a great job building sxiv. Do you really think that they want to force sxiv users to launch it only the two first ways I mentionned and not the third one? I can't imagine any reason why they would...

Last edited by LuX (2013-06-05 11:30:27)

Offline

#307 2013-06-05 11:45:03

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: sxiv - Simple image viewer written in C

I'm not saying I can read anyone's mind, but e.g. st has some limitations by design:
http://st.suckless.org/goals

Non-goals
* filters that change colour (should be done by tmux or something doing the higher layers in st)
* server to save sessions in case of X crash (should be done by dtach)
* unlimited scrollback buffer (done by dvtm)
* URL selecting/launching in browser similiar to vimperator’s mark mode and the urxvt script (patch?) (possibly piped through something like plumb to
        This one is done by a simple shortcut in dwm which will launch your plumber on the current select buffer. St has easy select through double-click. This keeps the complex logic out of the st context.

Offline

#308 2013-06-05 12:32:26

Doomcide
Member
Registered: 2011-08-22
Posts: 221

Re: sxiv - Simple image viewer written in C

LuX wrote:

It's probably a question of taste but I'm quite surprised that this last feature is not available by default. Every document viewer I know, even the most 'suckless' ones, have such an 'open' feature.
LuX

Look at mupdf.

In general, I think sxiv is good the way it is and feature-complete. If you don't like the shell, you can use a filemanager. That being said Maybe ber_t or someone else (you?) is nice enough to provide such a feature in a seperate branch or as a optional patch.

Offline

#309 2013-06-05 14:16:56

LuX
Member
From: France
Registered: 2010-06-14
Posts: 79

Re: sxiv - Simple image viewer written in C

Hello!

karol wrote:

st has some limitations by design:

And so does sxiv. I understand that 'limitation by design' is a good way of being more efficient, it is just what I like in sxiv and other suckless programs. However it appears that there is 'suckless' and 'suckless'! IMHO vim and mostly zathura are excellent programs with a suckless flavour (I could also mention mutt) although they are not part of the suckless.org project... and they provide an 'open' feature.

Also dmenu (more exactly dmenu_run), which is part of the suckless.org project, is commonly used for launching programs without file name arguments, that is just the 'third way' of viewing document in my post #304. Thus sxiv as it is now is not compatible with this suckless tool, or suckless way of doing. (Of course dmenu can be used in many other ways too.)

Doomcide wrote:

If you don't like the shell, you can use a filemanager.

I already answered to this: there is a third way, which can be used by suckless addicts as well as the two other ways that you prefer.

By the way I didn't know about mupdf, but now I know why I prefer zathura... (EDIT: Actually mupdf can be used as a plugin for zathura, alternatively to poppler.)

Doomcide wrote:

That being said Maybe ber_t or someone else (you?) is nice enough to provide such a feature in a seperate branch or as a optional patch.

I wish I could but I'm just an ordinary user, not a programmer. I wonder if it can be copy-pasted from zathura's source... wink

Nevertheless I agree with you that this feature could as well be provided separately, and most of all that the end decision belongs to ber_t (who is the single author of sxiv, isn't he?) to design sxiv for every 'suckless friendly' users or only for some of them.

Thank you for discussing, sheers,
LuX

Last edited by LuX (2013-06-06 11:16:24)

Offline

#310 2013-06-19 16:31:45

doggone
Member
Registered: 2013-06-19
Posts: 50

Re: sxiv - Simple image viewer written in C

Thank you for sxiv, I love it.

LuX wrote:

2) Easier customization with .config/sxivrc file instead of config.h.

This is a feature, it makes sxiv faster. dwm does the same thing.

Unia wrote:

On my sxiv-patches repo on GitHub you can now also find a patch that adds Pango support to sxiv - something I wanted considering I also switched DWM and dmenu over to Pango.

Cheers.

Thank you for these patches!

I changed the rifle_sxiv.sh script a bit, so when I execute "rifle_sxiv.sh <directory>" it will open all the images in the directory, starting with the first one.

#!/bin/sh
# Based on the original rifle_sxiv.sh, but this can take directories as a parameter.

[ "$1" == "--" ] && shift

if [ -z "$1" ]; then
    TARGET="$PWD"
elif [ -d "$1" ]; then
    TARGET="$(realpath "$1")"
elif [ -f "$1" ]; then
    TARGET="$(realpath $(dirname "$1"))"
else
    echo "Error: The given file or directory could not be found."
    exit 1
fi

listfiles() {
    find -L "$TARGET" -maxdepth 1 -type f -iregex '.*\(jpe?g\|bmp\|png\|gif\)$' -print0 | sort -z
}

COUNT="$(listfiles | grep -m 1 -ZznF "$1" | cut -d: -f1)"
echo $COUNT

if [ -n "$COUNT" ]; then
    listfiles | xargs -0 sxiv -q -n "$COUNT" --
else
    sxiv -q -- "$@" # fallback
fi

Last edited by doggone (2013-06-22 16:01:10)

Offline

#311 2013-06-21 13:16:22

LuX
Member
From: France
Registered: 2010-06-14
Posts: 79

Re: sxiv - Simple image viewer written in C

doggone wrote:
LuX wrote:

2) Easier customization with .config/sxivrc file instead of config.h.

This is a feature, it makes sxiv faster.

How many milliseconds faster?

How much time spent editing the code and recompiling it? Specially when you are not a programmer and don't know anything about C?

Cheers

Last edited by LuX (2013-06-21 13:17:24)

Offline

#312 2013-06-21 13:55:07

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: sxiv - Simple image viewer written in C

LuX, if you are that eager for it, then make a feature request on their issue tracker.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#313 2013-07-07 14:00:20

spupy
Member
Registered: 2009-08-12
Posts: 218

Re: sxiv - Simple image viewer written in C

doggone wrote:

I changed the rifle_sxiv.sh script a bit, so when I execute "rifle_sxiv.sh <directory>" it will open all the images in the directory, starting with the first one.

--snip--

In my file manager I use this script with "s/sxiv/feh/" of course. Clicking an image in the file manager will open it in sxiv, while I am still able to browse all the images in the folder with the prev/next keys. Actually I have no idea how this script works (haven't looked it in detail), but it works for me (in ROX).


There are two types of people in this world - those who can count to 10 by using their fingers, and those who can count to 1023.

Offline

#314 2013-07-17 09:58:51

doggone
Member
Registered: 2013-06-19
Posts: 50

Re: sxiv - Simple image viewer written in C

El_Belgicano wrote:

Great piece of code you put together here.

I just noticed it's not possible to use the following settings together:

	{ false,  XK_Right,         i_navigate,           (arg_t) +1 },
	{ false,  XK_Left,          i_navigate,           (arg_t) -1 },

	{ false,  XK_Left,          it_scroll_move,       (arg_t) DIR_LEFT },
	{ false,  XK_Right,         it_scroll_move,       (arg_t) DIR_RIGHT },

Even though they do not occur in the same environment and *could* be used, the first works while the second does not.

Could it be this just requires an easy fix?

Could anyone please answer this? I'm looking for the same thing.

Offline

#315 2013-08-11 11:04:34

ccc1
Member
Registered: 2009-04-16
Posts: 111

Re: sxiv - Simple image viewer written in C

First of all: Thanks b_ert for this nice image viewer. I switched instantly from feh to sxiv smile
Unfortunately I'm encountering a strange problem:
When viewing pictures, sometimes my laptop suddently turns the backlight off. Switching to a VT with ctrl-alt-F1 and then back to X sometimes solves the issue. Sometimes X just crashes when i switch back. Quite strange. Anybody also have this problem? Guess it's a X Bug, but so far it only happend when using sxiv.

Here a log of the Xorg crash:

Aug 11 12:45:17 x230 slim[565]: (EE)
Aug 11 12:45:17 x230 slim[565]: (EE) Backtrace:
Aug 11 12:45:17 x230 slim[565]: (EE) 0: /usr/bin/X (xorg_backtrace+0x3d) [0x57f71d]
Aug 11 12:45:17 x230 slim[565]: (EE) 1: /usr/bin/X (0x400000+0x183489) [0x583489]
Aug 11 12:45:17 x230 slim[565]: (EE) 2: /usr/lib/libpthread.so.0 (0x7f76ef162000+0xf0e0) [0x7f76ef1710e0]
Aug 11 12:45:17 x230 slim[565]: (EE) 3: /usr/lib/xorg/modules/drivers/intel_drv.so (0x7f76ecd2c000+0x360b7) [0x7f76ecd620b7]
Aug 11 12:45:17 x230 slim[565]: (EE) 4: /usr/lib/xorg/modules/drivers/intel_drv.so (0x7f76ecd2c000+0x385a7) [0x7f76ecd645a7]
Aug 11 12:45:17 x230 slim[565]: (EE) 5: /usr/lib/xorg/modules/drivers/intel_drv.so (0x7f76ecd2c000+0x42ff3) [0x7f76ecd6eff3]
Aug 11 12:45:17 x230 slim[565]: (EE) 6: /usr/bin/X (miPaintWindow+0x1d1) [0x5621a1]
Aug 11 12:45:17 x230 slim[565]: (EE) 7: /usr/bin/X (miWindowExposures+0x1d5) [0x562a75]
Aug 11 12:45:17 x230 slim[565]: (EE) 8: /usr/bin/X (miHandleValidateExposures+0x68) [0x577e08]
Aug 11 12:45:17 x230 slim[565]: (EE) 9: /usr/bin/X (SetRootClip+0x1d0) [0x465c70]
Aug 11 12:45:17 x230 slim[565]: (EE) 10: /usr/bin/X (0x400000+0xb7594) [0x4b7594]
Aug 11 12:45:17 x230 slim[565]: (EE) 11: /usr/bin/X (xf86Wakeup+0x54a) [0x47476a]
Aug 11 12:45:17 x230 slim[565]: (EE) 12: /usr/bin/X (WakeupHandler+0x6d) [0x43b4fd]
Aug 11 12:45:17 x230 slim[565]: (EE) 13: /usr/bin/X (WaitForSomething+0x1af) [0x57ccef]
Aug 11 12:45:17 x230 slim[565]: (EE) 14: /usr/bin/X (0x400000+0x36fe1) [0x436fe1]
Aug 11 12:45:17 x230 slim[565]: (EE) 15: /usr/bin/X (0x400000+0x268b5) [0x4268b5]
Aug 11 12:45:17 x230 slim[565]: (EE) 16: /usr/lib/libc.so.6 (__libc_start_main+0xf5) [0x7f76ee1e8a15]
Aug 11 12:45:17 x230 slim[565]: (EE) 17: /usr/bin/X (0x400000+0x26bfd) [0x426bfd]
Aug 11 12:45:17 x230 slim[565]: (EE)
Aug 11 12:45:17 x230 slim[565]: (EE) Segmentation fault at address 0x0
Aug 11 12:45:17 x230 slim[565]: (EE)
Aug 11 12:45:17 x230 slim[565]: Fatal server error:
Aug 11 12:45:17 x230 slim[565]: (EE) Caught signal 11 (Segmentation fault). Server aborting
Aug 11 12:45:17 x230 slim[565]: (EE)
Aug 11 12:45:17 x230 slim[565]: (EE)
Aug 11 12:45:17 x230 slim[565]: Please consult the The X.Org Foundation support
Aug 11 12:45:17 x230 slim[565]: at http://wiki.x.org
Aug 11 12:45:17 x230 slim[565]: for help. 
Aug 11 12:45:17 x230 slim[565]: (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
Aug 11 12:45:17 x230 slim[565]: (EE)
Aug 11 12:45:17 x230 slim[565]: (II) AIGLX: Suspending AIGLX clients for VT switch
Aug 11 12:45:17 x230 slim[565]: xsetroot:  unable to open display ':0.0'
Aug 11 12:45:17 x230 slim[565]: (EE) Server terminated with error (1). Closing log file.

Last edited by ccc1 (2013-08-11 14:27:37)

Offline

#316 2013-08-12 02:17:22

ikuchan
Member
Registered: 2013-05-12
Posts: 3

Re: sxiv - Simple image viewer written in C

Is it possible to make sxiv read images from the standard input? Feh can do it, I think it's a pretty useful feature.

Offline

#317 2013-08-12 02:19:05

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: sxiv - Simple image viewer written in C

ikuchan wrote:

Is it possible to make sxiv read images from the standard input? Feh can do it, I think it's a pretty useful feature.

What does the man page say?

Offline

#318 2013-08-12 02:59:31

bohoomil
Member
Registered: 2010-09-04
Posts: 2,376
Website

Re: sxiv - Simple image viewer written in C

LuX wrote:

How much time spent editing the code and recompiling it? Specially when you are not a programmer and don't know anything about C?

Editing config.h is actually extremely easy: what it requires is basically some logic and copy and pasting. Previous experience in C is not required. The time needed to edit config.h is the same as for every other text file, while rebuilding should take no more than 15 seconds (including package upgrade: 'makepkg -srci' should take care of everything). Sounds sane I guess. wink

ccc1 wrote:

When viewing pictures, sometimes my laptop suddently turns the backlight off. Switching to a VT with ctrl-alt-F1 and then back to X sometimes solves the issue. Sometimes X just crashes when i switch back.

I have experienced exactly the same behaviour with mplayer2 & intel GPU recently, after upgrading ffmpeg. It occurred several times in a row, but restarting X helped somehow. I'm using sxiv-git and it's working just fine, so I believe that the culprit may indeed reside somewhere inside the video driver / X server chain. (Sorry for no logs: there's no trace of any segfault nor anything significant whatsoever.)


:: Registered Linux User No. 223384

:: github
:: infinality-bundle+fonts: good looking fonts made easy

Offline

#319 2013-08-12 12:27:50

ikuchan
Member
Registered: 2013-05-12
Posts: 3

Re: sxiv - Simple image viewer written in C

karol wrote:

What does the man page say?

There's -i to read image names to open, I'd like to be able to do that with the actual images.

Offline

#320 2013-08-12 12:30:33

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: sxiv - Simple image viewer written in C

ikuchan wrote:
karol wrote:

What does the man page say?

There's -i to read image names to open, I'd like to be able to do that with the actual images.

Standard input accepts text, so I don't know how do you plan to feed ti actual images.

Offline

#321 2013-08-12 15:54:32

Doomcide
Member
Registered: 2011-08-22
Posts: 221

Re: sxiv - Simple image viewer written in C

karol wrote:
ikuchan wrote:
karol wrote:

What does the man page say?

There's -i to read image names to open, I'd like to be able to do that with the actual images.

Standard input accepts text, so I don't know how do you plan to feed ti actual images.

cat image.png | sxiv -

Offline

#322 2013-08-12 15:59:38

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: sxiv - Simple image viewer written in C

Why would you do that?

ikuchan wrote:

I think it's a pretty useful feature.

What would be the use case?

Offline

#323 2013-09-07 01:10:18

dgz
Member
Registered: 2013-08-27
Posts: 98

Re: sxiv - Simple image viewer written in C

i can't seem to get images to fit to the window, the -d option does nothing, and different -z values are also not useful.

Offline

#324 2013-09-07 01:25:07

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: sxiv - Simple image viewer written in C

dgz wrote:

i can't seem to get images to fit to the window, the -d option does nothing, and different -z values are also not useful.

'-s'?

Offline

#325 2013-09-07 01:37:48

dgz
Member
Registered: 2013-08-27
Posts: 98

Re: sxiv - Simple image viewer written in C

same result as the other two. i still need to scroll to see the whole image.

Offline

Board footer

Powered by FluxBB