Make imv-dir act like imv when called with multiple arguments

This commit allows user to select a few files and open only them using
imv-dir. When user opens just one file (typically by double-clicking on
it in a file manager), imv-dir will behave like it used to and open
open the whole directory.

I think this behavior is more reasonable doesn't add much complexity to
imv-dir. Now imv-dir conveniently accomodates the three use-cases which
I think must be quite common:

1. If user wants to cycle through all files in current directory, they
   can just double click on one of them.

2. If the user wants to cycle through just a few specific files (say,
   if they have many files in this directory and don't want to see them
   all), they select them and hit Enter.

3. If the user wants to see just one file and doesn't care about cycling
   through them, they just click on one file. The cycling is available,
   but they don't have to use it.

For me, 1 and 2 were the main use-cases and to accomodate them I had to
switch between imv and imv-dir as default image viewers, which is rather
suboptimal. Now both are cheaply accomodated by imv-dir.
This commit is contained in:
Ivan Oleynikov 2022-05-30 14:56:29 +03:00 committed by Harry Jeffery
parent 1817ef3df1
commit 6776568b6c
2 changed files with 7 additions and 3 deletions

View file

@ -1,2 +1,6 @@
#!/bin/sh
exec imv -n "$1" "$(dirname "$1")"
#!/bin/sh -efu
if [ $# -ge 2 ]; then
exec imv "$@"
else
exec imv -n "$1" "$(dirname "$1")"
fi

View file

@ -4,7 +4,7 @@ Name[en_US]=imv
GenericName=Image viewer
GenericName[en_US]=Image viewer
Comment=Fast freeimage-based Image Viewer | Open all images in a directory
Exec=imv-dir %f
Exec=imv-dir %F
NoDisplay=true
Terminal=false
Type=Application