Sxiv: [功能请求] 加载同一文件夹中的所有图像

创建于 2014-10-12  ·  3评论  ·  资料来源: muennich/sxiv

如果我单击文件管理器中的图片,它只会打开单击的图片。 我真的很想看到将所有图片加载到同一文件夹中的功能,以便我可以浏览图片。

最有用的评论

所有3条评论

sxiv 是为命令行用户设计的。 请为此使用包装脚本。 谷歌sxiv-rifle或使用以下之一:

#!/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;
        }'

如果-n选项也可以使用“文件名”而不仅仅是“索引号”,那就太好了,就像打开一个选择了特定文件的文件管理器一样。 有了这个,你可以使用类似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--;

编辑:刚刚注意到已经有一个拉取请求(https://github.com/muennich/sxiv/pull/371)。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

rpdelaney picture rpdelaney  ·  9评论

MimaHakurei picture MimaHakurei  ·  3评论

Knusper picture Knusper  ·  4评论

astier picture astier  ·  17评论

SammysHP picture SammysHP  ·  3评论