summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-11-19 18:34:31 +0100
committerDaniel Friesel <derf@finalrewind.org>2018-11-19 18:34:31 +0100
commit391a9bfd489d3f2e0cc74a2f698938b3e621d25b (patch)
treed1a19ae9998cf4a5312fa0ded0cd5c89a9f6fa33 /src
parent55c27c4babcf63989192f930ba7a75dac691e1e5 (diff)
--start-at: Auto-load directory when no other files are specified
This changes the behaviour of "feh --start-at FILENAME" as follows: Previously, this would cause feh to load all files in the current working directory, since no files or filelists were specified on the command line. Now this is a special case: feh will extract the directory component from FILENAME, load all files in that directory, and display FILENAME. This way, it's possible to use "feh --start-at ~%f" in XDG Desktop files and browse files in feh using the prev/next keys Closes #372 Closes #420
Diffstat (limited to 'src')
-rw-r--r--src/options.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/options.c b/src/options.c
index 894e29f..333c8c7 100644
--- a/src/options.c
+++ b/src/options.c
@@ -812,6 +812,19 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
add_file_to_filelist_recursively(argv[optind++], FILELIST_FIRST);
}
}
+ else if (finalrun && !opt.filelistfile && !opt.bgmode) {
+ if (opt.start_list_at && !path_is_url(opt.start_list_at) && strrchr(opt.start_list_at, '/')) {
+ char *target_directory = estrdup(opt.start_list_at);
+ char *filename_start = strrchr(target_directory, '/');
+ if (filename_start) {
+ *filename_start = '\0';
+ }
+ add_file_to_filelist_recursively(target_directory, FILELIST_FIRST);
+ free(target_directory);
+ } else {
+ add_file_to_filelist_recursively(".", FILELIST_FIRST);
+ }
+ }
else if (finalrun && !opt.filelistfile && !opt.bgmode)
add_file_to_filelist_recursively(".", FILELIST_FIRST);