artemsen / swayimg

Image viewer for Wayland
MIT License
380 stars 31 forks source link

reads all images in directory when passed a single file #133

Closed jonassmedegaard closed 6 months ago

jonassmedegaard commented 6 months ago

In a directory containing two PNG images I run swayimg PCDM_Multi_Page_Text-circles.png and expect only that image to load, but both images load. If I pass two paths, for a single image in two different directories, then all images of both directories get shown, where I would expect only the two explicitly stated files to load.

Tested with swayimg 2.2 packaged for Debian.

artemsen commented 6 months ago

Works as designed. By default, swayimg reads all images from the directory. You can change this behavior in the config file.

jonassmedegaard commented 6 months ago

Do you mean to say that even when told to load a single file, the intended behavior is to ignore that and load all images in the same folder as that single file?

In that case, it seems the manual page is misleading, because prominently as the first sentence of the description is this (emphasis mine):

If no input files or directories are specified, the viewer will try to read all files in the current directory.

If the intended design is to try read all files regardless if passed files, then I suggest to drop the first half of the sentence.

artemsen commented 6 months ago

Actually, it doesn't "load all files" (but preloads the next one). Swayimg creates the file list with all files and set the starting entry to the specified file. If you don't specify any file, it creates a list of all files in the current current directory and tries to open the first entry.

Sorry, English is not my native language, so there may be some misunderstanding in the documentation. Please, feel free to create a pull request with the fix =)

jonassmedegaard commented 6 months ago

Ok, I think it begins to dawn on me now: This application never only loads what you pass it as command-line options. Instead it always (pre)loads all image files it can find, taking command-line options only as a) files to place in front of the viewing queue, and b) places to look for images in. Is that correctly understood?

I base this interpretation also on adding the following at /etc/xdg/swayimg/config:

[general]
all = no

With the above config file, running swayimg FILE1 in a directory which contains FILE1 and FILE2 shows FILE1 but when hitting space it shows FILE2, and if instead running swayimg FILE2 then FILE2 is show at first and FILE1 is shown when hitting space.

If that is the intended behaviour, then there is no need for patching the code (which I am incapable of doing any, as I don't grok C, but thanks for the encouragement), and I am not really in the mood for patching documentation for an application that I have lost interest in using, because its design is non-sensible to me.

artemsen commented 6 months ago

This application never only loads what you pass it as command-line options. Instead it always (pre)loads all image files it can find, taking command-line options only as a) files to place in front of the viewing queue, and b) places to look for images in. Is that correctly understood?

No, it is not correct.

  1. By default (all = yes), the application creates the image list with all files in the same directory, but loads only one specified in the command line and preloads next one image.
  2. If you set all to no, then swayimg will load only specified image. But if you don't specify any file - the image list will contain all files in the current directory and swayimg loads the first available image and preloads the next one.

I base this interpretation also on adding the following at /etc/xdg/swayimg/config

It is a system-wide config. I would recommend $HOME/.config/swayimg/config.

[general] all = no

Wrong section. You should use list instead of general. See example.

jonassmedegaard commented 6 months ago

Wrong section. You should use list instead of general. See example.

Ah, my mistake. With that correction (which was totally my mistake not reading manual page carefully enough) the tool behaves how I would expect it to.

I still find it weird that all = yes is the default behaviour, but sounds like you are not open to changing that, so no point in offering patches, and I'll simply close this as a non-bug.

artemsen commented 6 months ago

I still find it weird that all = yes is the default behaviour, but sounds like you are not open to changing that

Some people want to open an image and see its neighbors. It's convenient for me too =)

jonassmedegaard commented 6 months ago

I understand now that (by default) swayimg treats FILE argument passed as command-line argument not (as is the default in many many other similar tools, and many of them the only possible behaviour) to only display FILE, but instead to display all files in same directory as FILE, with FILE being displayed first.

I see a point in it being possible to hint at prioritization rather than selection, but find it quite odd to have that behavior be the default behavior.

What I would find a more sensible way to get same behavior was to call it as swayimg FILE *.

jonassmedegaard commented 6 months ago

...or more concretely, to clarify my imagined behavior for a case of FILE being in a subdir:

swayimg subdir/myimg.png subdir/*

...but sure, that is more typing than the (to me weird) current behavior. I just wish it wasn't the default, because I imagine that my expectations for an image viewer is more common than yours - but obviously you have absolutely no need to care for anyone else than yourself :-)