You are not logged in.

#251 2011-10-17 17:40:07

bloom
Member
Registered: 2010-08-18
Posts: 749
Website

Re: sxiv - Simple image viewer written in C

lolilolicon wrote:
bloom wrote:
#! /bin/sh

Use #!/bin/bash when you mean it.

I didn't (and I prefer to keep the space after the exclamation mark).
What lead you to that?

Very twisted and error-prone. Catch this:

if (( ! $? )) && [[ -n $destination ]]; then
    # Good enough if you don't need to support ~user or ~- expansions
    _destination=${destination/#\~/~}
    mv -t "$_destination" "$@"
    { printf '%s\n' "$destination"; cat "$move_places"; } | sort | ... > "$places_temp"
    mv -T "$places_temp" "$move_places"
fi

Oh I see!
Would this syntax work with '/bin/sh'?
Is the '-T' option really necessary in the second 'mv'?


gh · da · ds

Offline

#252 2011-10-17 18:00:29

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: sxiv - Simple image viewer written in C

bloom wrote:
lolilolicon wrote:
bloom wrote:
#! /bin/sh

Use #!/bin/bash when you mean it.

I didn't (and I prefer to keep the space after the exclamation mark).
What lead you to that?

If you didn't realize that you were using bashism, apologies for misunderstanding your mistake.  I should have simply put "You want #!/bin/bash here."
The space is irrelevant.

bloom wrote:

Very twisted and error-prone. Catch this:

if (( ! $? )) && [[ -n $destination ]]; then
    # Good enough if you don't need to support ~user or ~- expansions
    _destination=${destination/#\~/~}
    mv -t "$_destination" "$@"
    { printf '%s\n' "$destination"; cat "$move_places"; } | sort | ... > "$places_temp"
    mv -T "$places_temp" "$move_places"
fi

Oh I see!
Would this syntax work with '/bin/sh'?

As I said, this parameter expansion syntax is bashism that you already are using. See http://mywiki.wooledge.org/Bashism
BTW, in case you're not aware, /bin/sh is a symlink to bash in Arch.  Although when bash is invoked as sh, it is meant to behave more like sh, it is not.

bloom wrote:

Is the '-T' option really necessary in the second 'mv'?

Not really necessary but being explicit about what you mean is never a bad thing.

JFTR, I don't apologize for being arrogant once in a while.


This silver ladybug at line 28...

Offline

#253 2011-10-27 14:36:11

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: sxiv - Simple image viewer written in C

I am going to release version 1.0 early next week.

I won't have much time to work on sxiv in the future. So, it would be great, if the users of the git-version could look for issues and report them.

Thanks for using sxiv and for all your feedback.

Offline

#254 2011-11-01 23:06:24

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: sxiv - Simple image viewer written in C

ber_t, I was just looking into your Makefile. Question: What do you think about this patch

diff -paur sxiv/Makefile sxiv-build/Makefile
--- sxiv/Makefile	2011-11-01 23:58:48.173359004 +0100
+++ sxiv-build/Makefile	2011-11-02 00:00:19.116654374 +0100
@@ -1,8 +1,8 @@
 VERSION = git-20111101
 
 CC      = gcc
-CFLAGS  = -ansi -Wall -pedantic -O2
-LDFLAGS =
+CFLAGS  += -ansi -Wall -pedantic
+LDFLAGS +=
 LIBS    = -lX11 -lImlib2
 
 PREFIX    = /usr/local

so it's up to the user to decide, which FLAGS are being used?

Offline

#255 2011-11-02 07:40:06

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: sxiv - Simple image viewer written in C

I want the Makefile to strictly adhere to the POSIX standard. There are other possibilities to overwrite the macros defined in the Makefile, apart from the (gnu-like) "+=", please see http://pubs.opengroup.org/onlinepubs/00 … 4_84_13_04 for more information.

Offline

#256 2011-11-05 22:27:14

hadrianw
Member
From: Szczecin, Poland
Registered: 2011-09-15
Posts: 5
Website

Re: sxiv - Simple image viewer written in C

I managed to code XEmbed support today. So here is the patch:
http://www.hawski.com/suckless/sxiv/000 … tion.patch

Last edited by hadrianw (2011-11-05 22:47:06)


Gentoo user here

Offline

#257 2011-11-06 20:15:57

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: sxiv - Simple image viewer written in C

I changed the SCALE_MODE to SCALE_FIT in the config.h. I know that this behavior is controllable with -d/-s/-Z/-z. But is it possible to bind a key to toggle between those two options?
edit: Simple solution: 'w' = SCALE_FIT, '=' almost = SCALE_DOWN => perfect!

Last edited by Army (2011-11-07 15:58:54)

Offline

#258 2011-11-07 14:58:05

ibrunton
Member
From: Canada
Registered: 2011-05-05
Posts: 270

Re: sxiv - Simple image viewer written in C

I'm finding that with v 1.0, when I open a large image and then press '=' to zoom to 100%, and then 'W' to resize the window, the image is offset, not matched up with the window.  Hitting '=' a second time shifts the image into the proper position.  This is new with v 1.0, never had this happen with previous versions.

Offline

#259 2011-11-08 14:31:13

SuNjACk
Member
Registered: 2011-02-27
Posts: 102

Re: sxiv - Simple image viewer written in C

ibrunton wrote:

I'm finding that with v 1.0, when I open a large image and then press '=' to zoom to 100%, and then 'W' to resize the window, the image is offset, not matched up with the window.  Hitting '=' a second time shifts the image into the proper position.  This is new with v 1.0, never had this happen with previous versions.

I have the same problem.

Offline

#260 2011-11-11 16:25:20

N30N
Member
Registered: 2007-04-08
Posts: 273

Re: sxiv - Simple image viewer written in C

Great little viewer, switching from gliv, Thanks!

ber_t wrote:
karol wrote:

qiv hides the mouse cursor if I'm not moving it while viewing the pictures, sxiv keeps the cursor visible at all times. Is it the intended behaviour? Do you plan to change it? ;P Is there an option I can use to hide the cursor (other than moving it to the bottom right corner of the screen)?

Never thought of that, but implemented it right away. Can be found in the current head...

This could have been left to programs like unclutter if you wanted to be more suckless.

Offline

#261 2011-11-11 19:39:45

gorilla
Member
From: Berlin
Registered: 2010-06-15
Posts: 72

Re: sxiv - Simple image viewer written in C

N30N wrote:

This could have been left to programs like unclutter if you wanted to be more suckless.

+1

Offline

#262 2011-11-11 22:57:55

ber_t
Member
From: Berlin, Germany
Registered: 2010-03-10
Posts: 214
Website

Re: sxiv - Simple image viewer written in C

SuNjACk wrote:
ibrunton wrote:

I'm finding that with v 1.0, when I open a large image and then press '=' to zoom to 100%, and then 'W' to resize the window, the image is offset, not matched up with the window.  Hitting '=' a second time shifts the image into the proper position.  This is new with v 1.0, never had this happen with previous versions.

I have the same problem.

Should be fixed in the current head.

Offline

#263 2011-11-12 00:16:44

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: sxiv - Simple image viewer written in C

gorilla wrote:
N30N wrote:

This could have been left to programs like unclutter if you wanted to be more suckless.

+1

Totally disagreed.


This silver ladybug at line 28...

Offline

#264 2011-11-24 00:18:34

MadCatMk2
Member
Registered: 2010-05-10
Posts: 84

Re: sxiv - Simple image viewer written in C

I modified the bash script that floats around here with the assistance of some really helpful folks at #bash.

In short,

./sx.sh 4
Pictures by ctime: 1 2 3 4 5 6 7 8
You end up here:         ^

Forgive my weak scripting. Might need more testing.

#!/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=()
z=0 #file number we should be taken to
st=0 #stop counting flag
shift #a button on the keyboard

cd -- "$dir"
while read -rd '' _ path; do
    arr+=("$path")
    if [ "$st" -eq "0" ]; then
	let z=z+1
    [[ "$path" == "./$file" ]] && st=1 
    fi
done < <(find . -maxdepth 1\
       	\( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.gif' \)\
       	-type f\
       	-printf '%C@ %p\0'\
       	| sort -znr)

exec sxiv "$@" -n "$z" -- "${arr[@]}" 

Last edited by MadCatMk2 (2011-11-24 00:20:08)

Offline

#265 2012-04-20 18:47:01

drrossum
Member
From: Chicago
Registered: 2009-02-24
Posts: 82

Re: sxiv - Simple image viewer written in C

This viewer is great!!!  It's exactly what I had been looking for in the past ~5 years.

I'm a big fan!

Daan

Offline

#266 2012-05-30 11:44:02

Isola
Member
Registered: 2010-02-02
Posts: 99

Re: sxiv - Simple image viewer written in C

Thank you for the best image viewer!

I have a feature request

I would like the current image number to be set as a environment variable, just like $SXIV_IMG.

I tried to do this myself, but failed.

The code you use to set the environment variable $SXIV_IMG is:

setenv("SXIV_IMG", files[n].path, 1)

So I thought this would work, but it didn't:

setenv("SXIV_NUMBER", n, 1)

Offline

#267 2012-06-16 19:52:31

El_Belgicano
Member
Registered: 2011-09-15
Posts: 4

Re: sxiv - Simple image viewer written in C

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?

Last edited by El_Belgicano (2012-06-16 19:55:07)

Offline

#268 2012-06-16 20:49:48

Cloudef
Member
Registered: 2010-10-12
Posts: 636

Re: sxiv - Simple image viewer written in C

Isola wrote:

So I thought this would work, but it didn't:

setenv("SXIV_NUMBER", n, 1)

Try something like:

char buffer[5]; /* increase size of buffer, if your number is more than 4 digits */
memset(buffer, 0, sizeof(buffer));
snprintf(buffer, sizeof(buffer)-1, "%d", n);
setenv("SXIV_NUMBER",buffer,1);

Last edited by Cloudef (2012-06-17 21:47:27)

Offline

#269 2012-06-17 01:29:16

igndenok
Member
From: Sidoarjo, Indonesia
Registered: 2010-06-07
Posts: 160

Re: sxiv - Simple image viewer written in C

Speaking of script, @MadCatMk2 does it work with path that contain [blablabla] ?
Sorry I didn't try your script, just want to ask first.


Ask, and it shall be given you.
Seek, and ye shall find.
Knock, and it shall be opened unto you.

Offline

#270 2012-06-17 09:14:47

MadCatMk2
Member
Registered: 2010-05-10
Posts: 84

Re: sxiv - Simple image viewer written in C

igndenok wrote:

Speaking of script, @MadCatMk2 does it work with path that contain [blablabla] ?
Sorry I didn't try your script, just want to ask first.

It should, but testing it should convince you better. ranger has amazing support for sxiv these days so I don't use it anymore.
Edit: Take a look at this script as well right here: https://bbs.archlinux.org/viewtopic.php … 1#p1078381

Last edited by MadCatMk2 (2012-06-17 09:22:20)

Offline

#271 2012-06-18 16:27:48

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

Re: sxiv - Simple image viewer written in C

I just started using this program (amazing application, I love it!). I read this thread sometimes before I used this and somewhere I read that the developer would look into setting the background with sxiv. I don't see this option yet so I wondered if it's going to happen or if it has been dropped (seeing the dev adheres to suckless very strictly - which is good!)

What do you use to set the background now? I'd like to get rid of feh now that I have sxiv.


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

#272 2012-06-18 16:30:48

thestinger
Package Maintainer (PM)
From: Toronto, Canada
Registered: 2010-01-23
Posts: 478

Re: sxiv - Simple image viewer written in C

Unia wrote:

I just started using this program (amazing application, I love it!). I read this thread sometimes before I used this and somewhere I read that the developer would look into setting the background with sxiv. I don't see this option yet so I wondered if it's going to happen or if it has been dropped (seeing the dev adheres to suckless very strictly - which is good!)

What do you use to set the background now? I'd like to get rid of feh now that I have sxiv.

hsetroot or another of the many alternatives

Offline

#273 2012-06-18 20:36:18

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: sxiv - Simple image viewer written in C

ber_t, what do you think about an option in the config.h to configure, if the bar should be shown by default or not? Most of the time I don't need the bar, so I hide it with "b", it's a bit annoying.

Offline

#274 2012-06-18 20:56:29

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

Re: sxiv - Simple image viewer written in C

Army wrote:

ber_t, what do you think about an option in the config.h to configure, if the bar should be shown by default or not? Most of the time I don't need the bar, so I hide it with "b", it's a bit annoying.

Perhaps another workound: use -b option when you open it. You can create a script or set this in your WM's keyboard section

Last edited by Unia (2012-06-18 20:56:37)


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

#275 2012-06-30 11:02:51

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

Re: sxiv - Simple image viewer written in C

Is it correct the slideshow option has been removed? I was going through the manpage to edit the shortcuts to match with those I changed in config.h and I came across the slideshow ones. I don't have these in my config.h though and also the files on GitHub don't show anything about it. I'm using the git version.


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

Board footer

Powered by FluxBB