aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README15
-rw-r--r--radharc.128
-rw-r--r--radharc.c68
3 files changed, 103 insertions, 8 deletions
diff --git a/README b/README
index 8b820f5..df9fcb0 100644
--- a/README
+++ b/README
@@ -4,7 +4,7 @@ NAME
SYNOPSIS
radharc [-M method] [-S site] [-c crtc] ... [-R rule] [-p priority] [-f fade-in]
[-F fade-out] [-h [high-temp][@high-elev]] [-l [low-temp][@low-elev]]
- (-L latitude:longitude | -t temperature [-d] | -x)
+ [-W options] ... (-L latitude:longitude | -t temperature [-d] | -x)
DESCRIPTION
radharc adjusts the colour temperature of your monitor according
@@ -97,6 +97,19 @@ OPTIONS
If temperature is '?' or 'get', the utility will print the
currently applied temperature.
+ -W options
+ Comma-separated list of implementation-specific options.
+
+ Supported options are:
+
+ linear=value
+
+ If value is 'yes', the effect will be surrounded
+ by an effect equivalent to that of cg-linear(1),
+ the two effects will be applied as one.
+
+ If value is 'no', the above will not be done.
+
-x
Remove the currently applied filter.
diff --git a/radharc.1 b/radharc.1
index cea8802..6e0d2b9 100644
--- a/radharc.1
+++ b/radharc.1
@@ -9,7 +9,7 @@ radharc \- Adjust display colour temperature after the Sun
[-S
.IR site ]
[-c
-.IR crtc "] ..."
+.IR crtc "] ..."\,
[-R
.IR rule ]
[-p
@@ -22,6 +22,8 @@ radharc \- Adjust display colour temperature after the Sun
.RI [ high-temp ][\fB@\fP high-elev ]]
[-l
.RI [ low-temp ][\fB@\fP low-elev ]]
+[-W
+.IR options "] ..."\,
(-L
.IR latitude : longitude
| -t
@@ -162,6 +164,30 @@ or
.RB ' get ',
the utility will print the currently applied temperature.
.TP
+.BR -W \ \fIoptions\fP
+Comma-separated list of implementation-specific options.
+
+Supported options are:
+
+.RS
+.TP
+.BI linear= value
+If
+.I value
+is
+.RB ' yes ',
+the effect will be surrounded by an effect equivalent
+to that of
+.BR cg-linear (1).
+The two effects will be applied as one.
+
+If
+.I value
+is
+.RB ' no ',
+the above will not be done.
+.RE
+.TP
.B -x
Remove the currently applied filter.
diff --git a/radharc.c b/radharc.c
index 0805b33..ac53ca3 100644
--- a/radharc.c
+++ b/radharc.c
@@ -12,11 +12,7 @@
#include <libred.h>
-#if 0
-# define IF_LINEARISING(...) __VA_ARGS__
-#else
-# define IF_LINEARISING(...) ((void)0)
-#endif
+#define IF_LINEARISING(...) do { if (linearise) { __VA_ARGS__; } } while (0)
/**
@@ -106,6 +102,14 @@ static int xflag = 0;
*/
static int print_temperature = 0;
+/**
+ * Whether the effect shall be put into an embedded
+ * cg-linear(1) equivalent block. This is generally
+ * a good idea unless you are using cg-linear(1)
+ * explicitly.
+ */
+static int linearise = 1;
+
/**
* Set to 1 by `handle_args` if the used arguments
@@ -167,7 +171,7 @@ usage(void)
fprintf(stderr,
"usage: %s [-M method] [-S site] [-c crtc] ... [-R rule] [-p priority]"
" [-f fade-in] [-F fade-out] [-h [high-temp][@high-elev]] [-l [low-temp][@low-elev]]"
- " (-L latitude:longitude | -t temperature [-d] | -x)\n", argv0);
+ " [-W options] ... (-L latitude:longitude | -t temperature [-d] | -x)\n", argv0);
exit(1);
}
@@ -194,6 +198,55 @@ parse_double(double *out, const char *str)
/**
+ * Parse -W argument
+ */
+static void
+vendor_options(char *arg)
+{
+ char *next, *value;
+
+ for (; arg; arg = next) {
+ while (*arg == ',')
+ arg++;
+ if (!*arg)
+ break;
+
+ next = strchr(arg, ',');
+ if (next)
+ *next++ = '\0';
+
+ value = strchr(arg, '=');
+ if (value)
+ *value++ = '\0';
+
+ if (!strcmp(arg, "linear")) {
+ if (!value)
+ goto missing_value;
+ else if (!strcmp(value, "yes"))
+ linearise = 1;
+ else if (!strcmp(value, "no"))
+ linearise = 0;
+ else
+ goto invalid_value;
+ } else {
+ fprintf(stderr, "%s: invalid -W option: %s\n", argv0, arg);
+ exit(1);
+ }
+ }
+
+ return;
+
+missing_value:
+ fprintf(stderr, "%s: invalid -W option '%s' is missing associated value\n", argv0, arg);
+ exit(1);
+
+invalid_value:
+ fprintf(stderr, "%s: invalid value on -W option '%s': %s\n", argv0, arg, value);
+ exit(1);
+}
+
+
+/**
* Handle a command line option
*
* @param opt The option, it is a NUL-terminate two-character
@@ -269,6 +322,9 @@ handle_opt(char *opt, char *arg)
xflag = 0;
}
return 1;
+ case 'W':
+ vendor_options(arg);
+ return 1;
case 'x':
xflag = 1;
dflag = 0;