aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gamma-randr.c11
-rw-r--r--src/gamma-randr.h2
-rw-r--r--src/gamma-vidmode.c10
-rw-r--r--src/gamma-vidmode.h2
-rw-r--r--src/gamma-w32gdi.c15
-rw-r--r--src/gamma-w32gdi.h1
-rw-r--r--src/location-gnome-clock.c12
-rw-r--r--src/location-gnome-clock.h2
-rw-r--r--src/location-manual.c11
-rw-r--r--src/location-manual.h1
-rw-r--r--src/redshift.c38
-rw-r--r--src/redshift.h7
12 files changed, 111 insertions, 1 deletions
diff --git a/src/gamma-randr.c b/src/gamma-randr.c
index ec70746..990ac91 100644
--- a/src/gamma-randr.c
+++ b/src/gamma-randr.c
@@ -290,6 +290,17 @@ randr_free(randr_state_t *state)
xcb_disconnect(state->conn);
}
+void
+randr_print_help(FILE *f)
+{
+ fputs(_("Adjust gamma ramps with the X RANDR extension.\n"), f);
+ fputs("\n", f);
+
+ fputs(_(" screen=N\tX screen to apply adjustments to\n"
+ " crtc=N\tCRTC to apply adjustments to\n"), f);
+ fputs("\n", f);
+}
+
static int
randr_set_temperature_for_crtc(randr_state_t *state, int crtc_num, int temp,
float gamma[3])
diff --git a/src/gamma-randr.h b/src/gamma-randr.h
index 307bdd2..c51c911 100644
--- a/src/gamma-randr.h
+++ b/src/gamma-randr.h
@@ -20,6 +20,7 @@
#ifndef _REDSHIFT_GAMMA_RANDR_H
#define _REDSHIFT_GAMMA_RANDR_H
+#include <stdio.h>
#include <stdint.h>
#include <xcb/xcb.h>
@@ -45,6 +46,7 @@ typedef struct {
int randr_init(randr_state_t *state, char *args);
void randr_free(randr_state_t *state);
+void randr_print_help(FILE *f);
void randr_restore(randr_state_t *state);
int randr_set_temperature(randr_state_t *state, int temp, float gamma[3]);
diff --git a/src/gamma-vidmode.c b/src/gamma-vidmode.c
index f9be408..e8f6d63 100644
--- a/src/gamma-vidmode.c
+++ b/src/gamma-vidmode.c
@@ -143,6 +143,16 @@ vidmode_free(vidmode_state_t *state)
}
void
+vidmode_print_help(FILE *f)
+{
+ fputs(_("Adjust gamma ramps with the X VidMode extension.\n"), f);
+ fputs("\n", f);
+
+ fputs(_(" screen=N\tX screen to apply adjustments to\n"), f);
+ fputs("\n", f);
+}
+
+void
vidmode_restore(vidmode_state_t *state)
{
uint16_t *gamma_r = &state->saved_ramps[0*state->ramp_size];
diff --git a/src/gamma-vidmode.h b/src/gamma-vidmode.h
index 7c351c9..8a4ef9f 100644
--- a/src/gamma-vidmode.h
+++ b/src/gamma-vidmode.h
@@ -20,6 +20,7 @@
#ifndef _REDSHIFT_GAMMA_VIDMODE_H
#define _REDSHIFT_GAMMA_VIDMODE_H
+#include <stdio.h>
#include <stdint.h>
#include <X11/Xlib.h>
@@ -33,6 +34,7 @@ typedef struct {
int vidmode_init(vidmode_state_t *state, char *args);
void vidmode_free(vidmode_state_t *state);
+void vidmode_print_help(FILE *f);
void vidmode_restore(vidmode_state_t *state);
int vidmode_set_temperature(vidmode_state_t *state, int temp, float gamma[3]);
diff --git a/src/gamma-w32gdi.c b/src/gamma-w32gdi.c
index 7425370..2dc12f3 100644
--- a/src/gamma-w32gdi.c
+++ b/src/gamma-w32gdi.c
@@ -17,8 +17,8 @@
Copyright (c) 2010 Jon Lund Steffensen <jonlst@gmail.com>
*/
-#include <stdlib.h>
#include <stdio.h>
+#include <stdlib.h>
#define WINVER 0x0500
#include <windows.h>
@@ -42,6 +42,11 @@ w32gdi_init(w32gdi_state_t *state, char *args)
{
BOOL r;
+ if (args != NULL) {
+ fputs(_("Too many arguments.\n"), stderr);
+ return -1;
+ }
+
/* Open device context */
state->hDC = GetDC(NULL);
if (state->hDC == NULL) {
@@ -86,6 +91,14 @@ w32gdi_free(w32gdi_state_t *state)
ReleaseDC(NULL, state->hDC);
}
+
+void
+w32gdi_print_help(FILE *f)
+{
+ fputs(_("Adjust gamma ramps with the Windows GDI.\n"), f);
+ fputs("\n", f);
+}
+
void
w32gdi_restore(w32gdi_state_t *state)
{
diff --git a/src/gamma-w32gdi.h b/src/gamma-w32gdi.h
index 48787da..082fcc8 100644
--- a/src/gamma-w32gdi.h
+++ b/src/gamma-w32gdi.h
@@ -31,6 +31,7 @@ typedef struct {
int w32gdi_init(w32gdi_state_t *state, char *args);
void w32gdi_free(w32gdi_state_t *state);
+void w32gdi_print_help(FILE *f);
void w32gdi_restore(w32gdi_state_t *state);
int w32gdi_set_temperature(w32gdi_state_t *state, int temp, float gamma[3]);
diff --git a/src/location-gnome-clock.c b/src/location-gnome-clock.c
index 3136ff2..1c08ce6 100644
--- a/src/location-gnome-clock.c
+++ b/src/location-gnome-clock.c
@@ -35,6 +35,11 @@
int
location_gnome_clock_init(location_gnome_clock_state_t *state, char *args)
{
+ if (args != NULL) {
+ fputs(_("Too many arguments.\n"), stderr);
+ return -1;
+ }
+
g_type_init();
GError *error = NULL;
@@ -128,6 +133,13 @@ location_gnome_clock_free(location_gnome_clock_state_t *state)
{
}
+void
+location_gnome_clock_print_help(FILE *f)
+{
+ fputs(_("Use the location as set in the GNOME Clock applet.\n"), f);
+ fputs("\n", f);
+}
+
int
location_gnome_clock_get_location(location_gnome_clock_state_t *state,
float *lat, float *lon)
diff --git a/src/location-gnome-clock.h b/src/location-gnome-clock.h
index 6687c30..f3fc47d 100644
--- a/src/location-gnome-clock.h
+++ b/src/location-gnome-clock.h
@@ -20,6 +20,7 @@
#ifndef _REDSHIFT_LOCATION_GNOME_CLOCK_H
#define _REDSHIFT_LOCATION_GNOME_CLOCK_H
+#include <stdio.h>
typedef struct {
float lat;
@@ -29,6 +30,7 @@ typedef struct {
int location_gnome_clock_init(location_gnome_clock_state_t *state, char *args);
void location_gnome_clock_free(location_gnome_clock_state_t *state);
+void location_gnome_clock_print_help(FILE *f);
int location_gnome_clock_get_location(location_gnome_clock_state_t *state,
float *lat, float *lon);
diff --git a/src/location-manual.c b/src/location-manual.c
index 1eca22e..d14fe98 100644
--- a/src/location-manual.c
+++ b/src/location-manual.c
@@ -82,6 +82,17 @@ location_manual_free(location_manual_state_t *state)
{
}
+void
+location_manual_print_help(FILE *f)
+{
+ fputs(_("Specify location manually.\n"), f);
+ fputs("\n", f);
+
+ fputs(_(" First argument is latitude,\n"
+ " second argument is longitude\n"), f);
+ fputs("\n", f);
+}
+
int
location_manual_get_location(location_manual_state_t *state, float *lat,
float *lon)
diff --git a/src/location-manual.h b/src/location-manual.h
index 372cf33..9c763ac 100644
--- a/src/location-manual.h
+++ b/src/location-manual.h
@@ -29,6 +29,7 @@ typedef struct {
int location_manual_init(location_manual_state_t *state, char *args);
void location_manual_free(location_manual_state_t *state);
+void location_manual_print_help(FILE *f);
int location_manual_get_location(location_manual_state_t *state, float *lat,
float *lon);
diff --git a/src/redshift.c b/src/redshift.c
index fd14a64..e2d8964 100644
--- a/src/redshift.c
+++ b/src/redshift.c
@@ -97,6 +97,7 @@ static const gamma_method_t gamma_methods[] = {
"RANDR",
(gamma_method_init_func *)randr_init,
(gamma_method_free_func *)randr_free,
+ (gamma_method_print_help_func *)randr_print_help,
(gamma_method_restore_func *)randr_restore,
(gamma_method_set_temperature_func *)randr_set_temperature
},
@@ -106,6 +107,7 @@ static const gamma_method_t gamma_methods[] = {
"VidMode",
(gamma_method_init_func *)vidmode_init,
(gamma_method_free_func *)vidmode_free,
+ (gamma_method_print_help_func *)vidmode_print_help,
(gamma_method_restore_func *)vidmode_restore,
(gamma_method_set_temperature_func *)vidmode_set_temperature
},
@@ -115,6 +117,7 @@ static const gamma_method_t gamma_methods[] = {
"WinGDI",
(gamma_method_init_func *)w32gdi_init,
(gamma_method_free_func *)w32gdi_free,
+ (gamma_method_print_help_func *)w32gdi_print_help,
(gamma_method_restore_func *)w32gdi_restore,
(gamma_method_set_temperature_func *)w32gdi_set_temperature
},
@@ -139,6 +142,8 @@ static const location_provider_t location_providers[] = {
"GNOME-Clock",
(location_provider_init_func *)location_gnome_clock_init,
(location_provider_free_func *)location_gnome_clock_free,
+ (location_provider_print_help_func *)
+ location_gnome_clock_print_help,
(location_provider_get_location_func *)
location_gnome_clock_get_location
},
@@ -147,6 +152,8 @@ static const location_provider_t location_providers[] = {
"Manual",
(location_provider_init_func *)location_manual_init,
(location_provider_free_func *)location_manual_free,
+ (location_provider_print_help_func *)
+ location_manual_print_help,
(location_provider_get_location_func *)
location_manual_get_location
},
@@ -288,6 +295,11 @@ print_method_list()
for (int i = 0; gamma_methods[i].name != NULL; i++) {
printf(" %s\n", gamma_methods[i].name);
}
+
+ fputs("\n", stdout);
+ fputs(_("Specify colon-separated options with"
+ " `-m METHOD:OPTIONS'.\n"), stdout);
+ fputs(_("Try `-m METHOD:help' for help.\n"), stdout);
}
static void
@@ -297,6 +309,11 @@ print_provider_list()
for (int i = 0; location_providers[i].name != NULL; i++) {
printf(" %s\n", location_providers[i].name);
}
+
+ fputs("\n", stdout);
+ fputs(_("Specify colon-separated options with"
+ "`-l PROVIDER:OPTIONS'.\n"), stdout);
+ fputs(_("Try `-l PROVIDER:help' for help.\n"), stdout);
}
@@ -406,6 +423,13 @@ main(int argc, char *argv[])
" `%s'.\n"), provider_name);
exit(EXIT_FAILURE);
}
+
+ /* Print provider help if arg is `help'. */
+ if (provider_args != NULL &&
+ strcasecmp(provider_args, "help") == 0) {
+ provider->print_help(stdout);
+ exit(EXIT_FAILURE);
+ }
break;
case 'm':
/* Print list of methods if argument is `list' */
@@ -414,6 +438,13 @@ main(int argc, char *argv[])
exit(EXIT_SUCCESS);
}
+ /* Split off method arguments. */
+ s = strchr(optarg, ':');
+ if (s != NULL) {
+ *(s++) = '\0';
+ method_args = s;
+ }
+
/* Lookup argument in gamma methods table */
for (int i = 0; gamma_methods[i].name != NULL; i++) {
const gamma_method_t *m =
@@ -430,6 +461,13 @@ main(int argc, char *argv[])
optarg);
exit(EXIT_FAILURE);
}
+
+ /* Print method help if arg is `help'. */
+ if (method_args != NULL &&
+ strcasecmp(method_args, "help") == 0) {
+ method->print_help(stdout);
+ exit(EXIT_FAILURE);
+ }
break;
case 'o':
one_shot = 1;
diff --git a/src/redshift.h b/src/redshift.h
index 1cb73f6..18b087e 100644
--- a/src/redshift.h
+++ b/src/redshift.h
@@ -20,10 +20,14 @@
#ifndef _REDSHIFT_REDSHIFT_H
#define _REDSHIFT_REDSHIFT_H
+#include <stdio.h>
+#include <stdlib.h>
+
/* Gamma adjustment method */
typedef int gamma_method_init_func(void *state, char *args);
typedef void gamma_method_free_func(void *state);
+typedef void gamma_method_print_help_func(FILE *f);
typedef void gamma_method_restore_func(void *state);
typedef int gamma_method_set_temperature_func(void *state, int temp,
float gamma[3]);
@@ -32,6 +36,7 @@ typedef struct {
char *name;
gamma_method_init_func *init;
gamma_method_free_func *free;
+ gamma_method_print_help_func *print_help;
gamma_method_restore_func *restore;
gamma_method_set_temperature_func *set_temperature;
} gamma_method_t;
@@ -40,6 +45,7 @@ typedef struct {
/* Location provider */
typedef int location_provider_init_func(void *state, char *args);
typedef void location_provider_free_func(void *state);
+typedef void location_provider_print_help_func(FILE *f);
typedef int location_provider_get_location_func(void *state, float *lat,
float *lon);
@@ -47,6 +53,7 @@ typedef struct {
char *name;
location_provider_init_func *init;
location_provider_free_func *free;
+ location_provider_print_help_func *print_help;
location_provider_get_location_func *get_location;
} location_provider_t;