summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-01-23 22:13:19 +0100
committerDaniel Friesel <derf@finalrewind.org>2011-01-23 22:13:19 +0100
commit69b1fd25f1ad2f745245146d36fec0ae82c3adee (patch)
tree15375247b44ba9b35fcb261a99b026e723552716
parent718a2f4d66f355343c4c84abcaf306e3ae21a14f (diff)
Parse commandline options _after_ theme options (closes GH-23)
-rw-r--r--man/feh.pre4
-rw-r--r--src/options.c30
2 files changed, 28 insertions, 6 deletions
diff --git a/man/feh.pre b/man/feh.pre
index d2e8ce7..41dd66c 100644
--- a/man/feh.pre
+++ b/man/feh.pre
@@ -361,8 +361,8 @@ Load options from config file with name
.Ar theme
- see
.Sx THEMES CONFIG SYNTAX
-for more info. Note that options from the theme file always override
-commandline options. The theme can also be set via the program name
+for more info. Note that commandline options always override theme options.
+The theme can also be set via the program name
.Pq e.g. with symlinks ,
so by default
.Nm
diff --git a/src/options.c b/src/options.c
index 2ca04b5..3e2e343 100644
--- a/src/options.c
+++ b/src/options.c
@@ -29,6 +29,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "options.h"
static void check_options(void);
+static void feh_getopt_theme(int argc, char **argv);
static void feh_parse_option_array(int argc, char **argv);
static void feh_parse_environment_options(void);
static void feh_check_theme_options(int arg, char **argv);
@@ -93,13 +94,15 @@ void init_parse_options(int argc, char **argv)
/* Check for and parse any options in FEH_OPTIONS */
feh_parse_environment_options();
- D(("About to parse commandline options\n"));
- /* Parse the cmdline args */
- feh_parse_option_array(argc, argv);
+ feh_getopt_theme(argc, argv);
D(("About to check for theme configuration\n"));
feh_check_theme_options(argc, argv);
+ D(("About to parse commandline options\n"));
+ /* Parse the cmdline args */
+ feh_parse_option_array(argc, argv);
+
/* If we have a filelist to read, do it now */
if (opt.filelistfile) {
/* joining two reverse-sorted lists in this manner works nicely for us
@@ -318,8 +321,27 @@ char *feh_string_normalize(char *str)
return(estrdup(ret));
}
-static void feh_parse_option_array(int argc, char **argv)
+static void feh_getopt_theme(int argc, char **argv)
+{
+ static char stropts[] = "-T:";
+ static struct option lopts[] = {
+ {"theme", 1, 0, 'T'},
+ {0, 0, 0, 0}
+ };
+ int optch = 0, cmdx = 0;
+
+ opterr = 0;
+
+ while ((optch = getopt_long(argc, argv, stropts, lopts, &cmdx)) != EOF) {
+ if (optch == 'T')
+ theme = estrdup(optarg);
+ }
+ opterr = 1;
+ optind = 0;
+}
+
+static void feh_parse_option_array(int argc, char **argv)
{
static char stropts[] =
"a:A:b:B:cC:dD:e:E:f:Fg:GhH:iIj:J:kK:lL:mM:nNo:O:pPqQrR:sS:tT:uUvVwW:xXy:YzZ"