ctemp

Set color temperature
git clone git://git.akobets.xyz/ctemp
Log | Files | Refs | README | LICENSE

commit 2a66d1e3b8367e17ef5830811be64f3b235d77e4
parent f9c44a66650f1d7809bfd828d7d8b1811a30c57c
Author: Artem Kobets <artem@akobets.xyz>
Date:   Thu,  5 Mar 2020 11:31:54 +0200

add man page and LICENSE

Diffstat:
ALICENSE | 21+++++++++++++++++++++
MMakefile | 22+++++++++++++---------
Mcolors.c | 9+++++----
Mconfig.mk | 5+++++
Actemp.1 | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mctemp.c | 10++++++----
Mutil.c | 2++
Mutil.h | 2++
8 files changed, 115 insertions(+), 17 deletions(-)

diff --git a/LICENSE b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2020 Artem Kobets <artem@akobets.xyz> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile @@ -1,9 +1,11 @@ +# ctemp - set color temperature +# See LICENSE file for copyright and license details. + +.POSIX: + include config.mk -SRC = \ - colors.c \ - ctemp.c \ - util.c +SRC = colors.c ctemp.c util.c OBJ = $(SRC:.c=.o) all: ctemp @@ -19,10 +21,12 @@ ctemp: $(OBJ) clean: rm -f ctemp $(OBJ) -install: all - mkdir -p $(PREFIX)/bin - cp -f ctemp $(PREFIX)/bin - chmod 755 $(PREFIX)/bin/ctemp +install: ctemp + mkdir -p $(DESTDIR)$(PREFIX)/bin + cp -f ctemp $(DESTDIR)$(PREFIX)/bin + chmod 755 $(DESTDIR)$(PREFIX)/bin/ctemp + sed "s/VERSION/$(VERSION)/g" < ctemp.1 > $(DESTDIR)$(MANPREFIX)/man1/ctemp.1 uninstall: - rm -f $(PREFIX)/bin/ctemp + rm -f $(DESTDIR)$(PREFIX)/bin/ctemp + rm -f $(DESTDIR)$(MANPREFIX)/man1/ctemp.1 diff --git a/colors.c b/colors.c @@ -1,7 +1,8 @@ -/* Whitepoint values for temperatures at 100K intervals. - These will be interpolated for the actual temperature. - This table was originally provided by Ingo Thies, 2013, - for Redshift */ +/* See LICENSE file for copyright and license details. */ + +/* Cribbed from Redshift. This table data + * was released into public domain + * and originally provided by Ingo Thies, 2013 */ const struct { float r; float g; float b; } whitepoints[] = { { 1.00000000, 0.18172716, 0.00000000, }, /* 1000K */ { 1.00000000, 0.25503671, 0.00000000, }, /* 1100K */ diff --git a/config.mk b/config.mk @@ -1,6 +1,11 @@ +# ctemp version VERSION = 0.1.0 +# Customize below to fit your system + +# paths PREFIX = /usr/local +MANPREFIX = $(PREFIX)/share/man # DRM support ENABLE_DRM = ON diff --git a/ctemp.1 b/ctemp.1 @@ -0,0 +1,61 @@ +.TH CTEMP 1 ctemp\-VERSION +.SH NAME +ctemp \- set color temperature +.SH SYNOPSIS +.B ctemp +.RB [ \-hv ] +.RB \-i +.IR interface +.IR temperature +.SH DESCRIPTION +.B ctemp +sets color temperature for several graphical backends. +.SH OPTIONS +.TP +.B \-h +display help text and exit. +.TP +.B \-v +display version and exit. +.TP +.BI \-i " interface" +define interface to use. +.RS +.PP +.B drm +- use Direct Rendering Manager API. +.br +Use this in console mode (no X11). +.PP +.B quartz +- use Quartz API (macOS/OS X). +.br +Program will not exit after applying changes if this interface is used. +.br +This is due to OS X limitations of discarding color temperature changes on program exit. +.PP +.B x +- use X11 API. +.PP +If program was compiled with only one interface, +it will be used by default. +Use +.B -h +to see compiled options available. +.RE +.TP +.I temperature +Value between 1000 and 25000, with interval 100, rounded down. +6500 is the usual regular color temperature. +.SH EXAMPLES +# set console color temperature to "night mode" (less blue light) +.br +ctemp -i drm 4000 +.PP +# set regular color temperature in X11 session. +.br +ctemp -i x 6500 +.SH AUTHORS +Artem Kobets <artem@akobets.xyz> +.SH LICENSE +See the LICENSE file for the terms of redistribution. diff --git a/ctemp.c b/ctemp.c @@ -1,3 +1,5 @@ +/* See LICENSE for license details. */ + #if !defined(DRM_SUPPORT) && !defined(X_SUPPORT) && !defined(QUARTZ_SUPPORT) #error "No supported interface configured" #endif @@ -252,11 +254,10 @@ usage() } die( - "usage: %s -i interface temperature\n" + "usage: %s [-hv] -i interface temperature\n" " interface - one of [ %s ]\n" - " temperature - %i-%i, with interval %i, rounded down" - " (initial value is usually 6500)\n", - argv0, ifStr, TEMP_MIN, TEMP_MAX, TEMP_INTERVAL + " temperature - %i-%i\n", + argv0, ifStr, TEMP_MIN, TEMP_MAX ); } @@ -285,6 +286,7 @@ main(int argc, char **argv) { case 'v': puts("ctemp "VERSION); return 0; + case 'h': default: usage(); break; diff --git a/util.c b/util.c @@ -1,3 +1,5 @@ +/* See LICENSE for license details. */ + #include <stdlib.h> #include <stdio.h> #include <stdarg.h> diff --git a/util.h b/util.h @@ -1 +1,3 @@ +/* See LICENSE for license details. */ + void die(const char *fmt, ...);