Add dummy gamma adjustment method

This method does not do anything but print the temperature to the terminal.
An external program implementing a color temperature adjustment scheme that
is not supported by redshift can use this method to determine the desired
color temperature. It is also useful for testing other parts of redshift on
systems where neither RandR nor VidMode works.
This commit is contained in:
Jon Lund Steffensen
2013-12-09 10:48:45 -05:00
parent 3297f52f48
commit 2d4a5ad26b
5 changed files with 127 additions and 11 deletions
+2 -1
View File
@@ -14,7 +14,8 @@ redshift_SOURCES = \
config-ini.c config-ini.h \
location-manual.c location-manual.h \
solar.c solar.h \
systemtime.c systemtime.h
systemtime.c systemtime.h \
gamma-dummy.c gamma-dummy.h
EXTRA_redshift_SOURCES = \
gamma-randr.c gamma-randr.h \
+76
View File
@@ -0,0 +1,76 @@
/* gamma-randr.c -- No-op gamma adjustment
This file is part of Redshift.
Redshift is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Redshift is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Redshift. If not, see <http://www.gnu.org/licenses/>.
Copyright (c) 2013 Jon Lund Steffensen <jonlst@gmail.com>
*/
#include <stdio.h>
#include <stdlib.h>
#ifdef ENABLE_NLS
# include <libintl.h>
# define _(s) gettext(s)
#else
# define _(s) s
#endif
#include "gamma-randr.h"
int
gamma_dummy_init(void *state)
{
return 0;
}
int
gamma_dummy_start(void *state)
{
fputs(_("WARNING: Using dummy gamma method! Display will not be affected by this gamma method.\n"), stderr);
return 0;
}
void
gamma_dummy_restore(void *state)
{
}
void
gamma_dummy_free(void *state)
{
}
void
gamma_dummy_print_help(FILE *f)
{
fputs(_("Does not affect the display but prints the color temperature to the terminal.\n"), f);
fputs("\n", f);
}
int
gamma_dummy_set_option(void *state, const char *key, const char *value)
{
fprintf(stderr, _("Unknown method parameter: `%s'.\n"), key);
return -1;
}
int
gamma_dummy_set_temperature(void *state, int temp, float brightness,
float gamma[3])
{
printf(_("Temperature: %i\n"), temp);
return 0;
}
+38
View File
@@ -0,0 +1,38 @@
/* gamma-dummy.h -- No-op gamma adjustment header
This file is part of Redshift.
Redshift is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Redshift is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Redshift. If not, see <http://www.gnu.org/licenses/>.
Copyright (c) 2013 Jon Lund Steffensen <jonlst@gmail.com>
*/
#ifndef _REDSHIFT_GAMMA_DUMMY_H
#define _REDSHIFT_GAMMA_DUMMY_H
#include "redshift.h"
int gamma_dummy_init(void *state);
int gamma_dummy_start(void *state);
void gamma_dummy_free(void *state);
void gamma_dummy_print_help(FILE *f);
int gamma_dummy_set_option(void *state, const char *key, const char *value);
void gamma_dummy_restore(void *state);
int gamma_dummy_set_temperature(void *state, int temp, float brightness,
float gamma[3]);
#endif /* ! _REDSHIFT_GAMMA_DUMMY_H */
+11 -5
View File
@@ -51,11 +51,7 @@
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#if !(defined(ENABLE_RANDR) || \
defined(ENABLE_VIDMODE) || \
defined(ENABLE_WINGDI))
# error "At least one of RANDR, VidMode or WinGDI must be enabled."
#endif
#include "gamma-dummy.h"
#ifdef ENABLE_RANDR
# include "gamma-randr.h"
@@ -133,6 +129,16 @@ static const gamma_method_t gamma_methods[] = {
(gamma_method_set_temperature_func *)w32gdi_set_temperature
},
#endif
{
"dummy",
(gamma_method_init_func *)gamma_dummy_init,
(gamma_method_start_func *)gamma_dummy_start,
(gamma_method_free_func *)gamma_dummy_free,
(gamma_method_print_help_func *)gamma_dummy_print_help,
(gamma_method_set_option_func *)gamma_dummy_set_option,
(gamma_method_restore_func *)gamma_dummy_restore,
(gamma_method_set_temperature_func *)gamma_dummy_set_temperature
},
{ NULL }
};