If i click a picture in filemanager it opens only the clicked picture. I would really like to see feature to load all pictures in the same folder so i could browse through the pictures.
sxiv is designed for command line users. Please use a wrapper script for that. Google sxiv-rifle
or use the following one:
#!/bin/sh
if [ $# -ne 1 -o ! -f "$1" ]; then
echo "usage: ${0##*/} FILE" >&2
exit 1
fi
file -i "$(dirname "$1")"/* \
| awk -F ': *' -v f="$1" '
$2 ~ "^image" {
files[cnt++] = $1;
if ($1 == f)
n = cnt;
}
END {
for (i = 0; i < cnt; i++)
print files[i] | "sxiv -i -n " n;
}'
It would be good if -n
option can also take "file name" instead of just "index number", like opening a file manager with a specific file selected. With this, you can use something like sxiv -n x.png *.png
diff --git a/options.c b/options.c
index de02407..b9ca468 100644
--- a/options.c
+++ b/options.c
@@ -45,6 +45,7 @@ void parse_options(int argc, char **argv)
int n, opt;
char *end, *s;
const char *scalemodes = "dfwh";
+ char *opt_n = NULL; /* -n (starting picture number) can be index or filename */
progname = strrchr(argv[0], '/');
progname = progname ? progname + 1 : argv[0];
@@ -117,10 +118,7 @@ void parse_options(int argc, char **argv)
_options.from_stdin = true;
break;
case 'n':
- n = strtol(optarg, &end, 0);
- if (*end != '\0' || n <= 0)
- error(EXIT_FAILURE, 0, "Invalid argument for option -n: %s", optarg);
- _options.startnum = n - 1;
+ opt_n = optarg;
break;
case 'N':
_options.res_name = optarg;
@@ -172,6 +170,21 @@ void parse_options(int argc, char **argv)
_options.filenames = argv + optind;
_options.filecnt = argc - optind;
+ if (opt_n != NULL) {
+ for (n = 0; n < _options.filecnt; n++) {
+ if (strcmp(_options.filenames[n], opt_n) == 0)
+ break;
+ }
+ if (n < _options.filecnt) {
+ _options.startnum = n;
+ } else {
+ n = strtol(opt_n, &end, 0);
+ if (*end != '\0' || n <= 0)
+ error(EXIT_FAILURE, 0, "Invalid argument for option -n: %s", optarg);
+ _options.startnum = n - 1;
+ }
+ }
+
if (_options.filecnt == 1 && STREQ(_options.filenames[0], "-")) {
_options.filenames++;
_options.filecnt--;
EDIT: Just noticed that there is already a pull request (https://github.com/muennich/sxiv/pull/371).
My workaround for this:
https://github.com/Parveshdhull/misc/tree/master/linux
Most helpful comment
My workaround for this:
https://github.com/Parveshdhull/misc/tree/master/linux