Commit Graph

96 Commits (80fb589fe7b5d5bb53d90dd0adec12c3fe0ca498)

Author SHA1 Message Date
Kenny Levinsen 80fb589fe7 readme: Fix the list of forced modes 2024-01-29 18:01:21 +01:00
Kelvin C 77c06ff336 Update man-page
- For each option's description, prefer capitalizing and ending with a period.

- Also, prefer lowercasing 'Day' as it appears to be the norm in NAME sections.
2024-01-29 17:59:01 +01:00
Kelvin C 440805981c Update README
- Since commit c59bbbd6, xdg-output-unstable-v1 became unsupported in wlsunset.
2024-01-29 17:56:02 +01:00
Mukund Sivaraman 5190631bc6 Fix typo in manpage 2024-01-29 17:55:43 +01:00
Kenny Levinsen c7b622e8dc Explain the use of multiple locus better
It was not entirely trivial to understand why the two locus were
implemented, and why there was a transition between them. Explain this
more explicitly.
2023-12-12 16:22:06 +01:00
Kenny Levinsen b6cfe1761d Free output name, skip storing description 2023-09-01 15:45:46 +02:00
Kenny Levinsen aa8015064a Improve logging 2023-09-01 15:44:41 +02:00
Kenny Levinsen c59bbbd6e3 Remove xdg-output support
xdg-output was used to extract the output name, which can be obtained
from wl_output as of interface version 4, release in Wayland 1.20 almost
two years ago.
2023-09-01 15:00:28 +02:00
Kenny Levinsen 966728a29b Calculate blend factor as double 2023-09-01 14:12:02 +02:00
Kenny Levinsen 29d5b255e5 Change steps from 25K to 10K 2023-09-01 14:06:53 +02:00
Kenny Levinsen 81cfb0b4f8 Force mode on SIGUSR1
Sending SIGUSR1 will make wlsunset cycle between forcing the temperature
high, forcing it low, and returning to automatic temperature control.
2023-06-02 11:58:05 +02:00
Kenny Levinsen eac926fc21 Bump version to 0.3.0 2023-05-24 16:47:43 +02:00
Kenny Levinsen cc9251d5c3 display_dispatch: Terminate poll loop on EPIPE
display_dispatch tried to flush the display in a loop until it no longer
returns an error that is EAGAIN or EPIPE. This becomes an infinite loop
if the socket is closed.

Stop flushing if we hit EPIPE, as the connection is dead. We still try
to read what we were sent to the protocol error shows up in debug
output.
2023-01-23 14:59:20 +01:00
Kenny Levinsen cee422b440 ci: Build on archlinux 2022-05-04 11:09:55 +02:00
Kenny Levinsen e3cec522cf Negate longitude_time_offset
Instead of negating at every single point of use, just negate the
calculation.
2022-05-04 11:06:47 +02:00
Kenny Levinsen 5afa1d2819 Use timezone as time offset for manual time
When entering manual time, the timezone was adjusted in the time input
instead of storing the time offset. The time offset is necessary to
calculate the correct day boundaries.

Remove the timezone correction of time input and instead adjust the time
offset accordingly.
2022-05-04 11:01:10 +02:00
Kenny Levinsen 8d1067a5aa Move feature defines to C files 2022-05-04 10:58:42 +02:00
Kenny Levinsen 09c5e9a8dd Ensure step time is at least 1 second
When configured to perform a very quick transition, the step time for 25
kelvin may end up being less than 1 second, rounding to zero. A zero
step time does not make any sense.
2022-05-02 10:44:21 +02:00
Kenny Levinsen 2e7d793bb6 Store enabled state on output
This allows us to check the name just once when we receive the
xdg_output::name event instead of every time we set the temperature.
2022-01-25 11:23:42 +01:00
Kenny Levinsen b7ef7d0ce8 Only set up xdg-output once 2022-01-25 11:23:08 +01:00
Artur Sinila 20d37fb751 Refactor RGB & XYZ colors into structs 2022-01-25 11:23:07 +01:00
Artur Sinila afc09a90c6 Support running only for specific outputs (displays)
Useful for laptops with external displays connected. External displays
usually have an ability to adjust color temperature via built-in menu,
so you can run `wlsunset` exclusively for laptop's internal display.

Also different screens happen to look differently after setting the same
color temperature. Possibly has to do with the technology which
display is based on (TN or IPS).
2022-01-25 11:22:20 +01:00
Artur Sinila e18ab2cbdd Add .gitignore
`.cache` is for `clangd` cache
2022-01-24 13:36:50 +01:00
Kenny Levinsen 813e6640c5 Add .editorconfig 2022-01-16 14:35:34 +01:00
Evgeniy Khramtsov 601dfc87ff main.c: define timezone to tm.tm_gmtoff on FreeBSD
FreeBSD has BSD extension timezone, which conflicts with XSI extension
with the same name, according to time.h:

char *timezone(int, int);	/* XXX XSI conflict */
...

FreeBSD also has long tm_gmtoff member of struct tm, which is offset
from UTC in seconds, according to time.h:

struct tm {
...
long    tm_gmtoff;	/* offset from UTC in seconds */
char	*tm_zone;	/* timezone abbreviation */
}

which is the same as XSI extension timezone.

Co-authored-by: Jan Beich <jbeich@FreeBSD.org> (downstream patch)
Reviewed by: Kenny Levinsen <kl@kl.wtf>
2021-11-29 08:14:26 +01:00
Kenny Levinsen f32f6963b9 readme: Update discuss section 2021-05-19 17:52:41 +02:00
Kenny Levinsen 7be432057f meson: Copy seatd's scdoc handling
This fixes cross-compiling, and avoids unnecessary search for a shell.
2021-04-30 20:03:43 +02:00
Kenny Levinsen 3d7979a148 readme: Update mailing list 2021-04-25 22:59:11 +02:00
Kenny Levinsen 21763c66a1 Bump version to 0.2.0 2021-04-25 22:56:30 +02:00
Kenny Levinsen 53d19e4c76 Add version command line flag 2021-02-01 13:24:17 +01:00
Kenny Levinsen 111181106e Add support for manual sunset/sunrise
The new -S/-s/-d flags allow for manually specifying the time of sunset,
ssunrise in the format of HH:MM, and the transitional animation duration
in seconds, respectively.

This is implemented by sidestepping the calc_sun call in manual mode.
The rest of wlsunset operates as usual.
2021-01-29 17:32:51 +01:00
Kenny Levinsen 93d7d01bad Give config gamma as double to set_temperature
The gamma argument to set_temperature was incorrectly typed as an int,
causing unfortunate rounding.
2021-01-29 16:39:06 +01:00
Kenny Levinsen bcbca9e065 Use illuminant D for the majority of temperatures
D65, the natural whitepoint that wlsunset assumes, is defined on
illuminant D, which simulates daylight with atmospheric effects.
However, we used planckian locus for all values under 6500 K, which
meant that there was a significant jump in color - specifically, a
sudden reduction in green and blue - as we started reducing the color
temperature.

Instead, we purely use illuminant D down to 4000 K where it is well
defined. Below 4000 K, illuminant D starts unintentionally approaching
the planckian locus, before finally breaking completely at 2000 K. We
extend the boundary of illuminant D to 2500 K and perform a
sine-smoothed transition to planckian locus from 4000 K to 2500 K to
extend the range of wlsunset down to 1667 K, where planckian locus ends
and we finally give up.

The end-result is a smooth transition along all valid temperature
values, with no sudden jumps as we had before. However, we do end up
with slightly greener/bluer colors than earlier. We'll have to see how
that holds up.
2020-11-11 16:40:37 +01:00
Kenny Levinsen 49ad3ce7a8 meson: Disable implicit-fallthrough
Clang cannot decide how it wishes to handle implicit-fallthrough, with
different solutions across different versions, which presents a problem
on FreeBSD where several majors of clang remain relevant.

Disable implicit-fallthrough until clang has figured out what it wants
to do in life.
2020-11-09 21:50:21 +01:00
Kenny Levinsen 22589b8f1f ci: Add FreeBSD to CI 2020-11-09 17:11:37 +01:00
Jan Beich ec0c1614af meson: explicitly depend on libwayland for includes
On BSDs base compiler doesn't search packages by default, making it
easy for vendors to depend only on base system.

FAILED: wlsunset.p/main.c.o
cc -Iwlsunset.p -I. -I.. -Xclang -fcolor-diagnostics -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -Werror -std=c11 -g -Wundef -Wunused -Wlogical-op -Wmissing-include-dirs -Wold-style-definition -Wpointer-arith -Wstrict-prototypes -Wimplicit-fallthrough -Wmissing-prototypes -Wno-unknown-warning-option -Wno-unused-command-line-argument -Wvla -Wl,--exclude-libs=ALL -D_USE_MATH_DEFINES -D_XOPEN_SOURCE=700 -MD -MQ wlsunset.p/main.c.o -MF wlsunset.p/main.c.o.d -o wlsunset.p/main.c.o -c ../main.c
../main.c:14:10: fatal error: 'wayland-client-protocol.h' file not found
 #include <wayland-client-protocol.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
2020-11-09 15:13:08 +01:00
Kenny Levinsen 33c64bc929 man: Remove reference to missing features 2020-10-31 01:57:31 +01:00
Rohan Kumar fa2bd44253 Add manpage 2020-10-27 10:10:09 +01:00
Kenny Levinsen 0569fb45bd Option cleanup 2020-10-21 01:41:49 +02:00
Kenny Levinsen 0da97df89e Use clock_gettime for all time requests 2020-10-21 00:49:35 +02:00
Kenny Levinsen 0703fbcc0e Minor line length reduction 2020-10-21 00:41:50 +02:00
Kenny Levinsen b9f0b8e3c0 Move longitude time correction out of calc_sun
calc_sun reported sun trajectory in seconds since the start of a UTC
day, as they would occur for the specified UTC day. The caller would
then add the UTC timestamp for the start of a UTC day to these numbers.
This lead to complications, as e.g. a sunrise in China would be a
negative value, as it occurred in the last UTC day.

Futhermore, the start of a UTC day was used to signal the need for new
sun calculations. This would lead to recalculations to possibly occur
after its results were needed, such as after sunrise when the target
longitude deviated significantly from the prime meridian.

To fix this, we apply longitude time correction to the start of day
calculation. This way recalculation will occur on the start of the
longitude local day, close midnight for the observer.

We also remove the longitude time correction from calc_sun, so that it
simply returning the number of seconds since the start of the local day
of the observer. The caller then adds the start of the longitude local
day to get the final numbers.
2020-10-19 14:18:28 +02:00
Kenny Levinsen b43cd9f343 Sort sun and wayland code 2020-10-19 00:39:38 +02:00
Kenny Levinsen 1da4343e31 Remove manual duration for now 2020-10-19 00:37:47 +02:00
Kenny Levinsen 5c497febb7 Do not use -1 for sun calc error 2020-10-19 00:37:02 +02:00
Kenny Levinsen c7c8dad01d Self-pipe timer signal handling 2020-10-18 22:41:22 +02:00
Kenny Levinsen f66842c020 Split up main a bit 2020-10-18 01:19:47 +02:00
Kenny Levinsen fdcdb04023 Remove clamp from color_math.h 2020-10-18 00:45:36 +02:00
Kenny Levinsen 75b0a71d99 Simplify speedrun code a bit 2020-10-18 00:36:52 +02:00
Kenny Levinsen e14e8efcf3 Gracefully handle midnight sun/polar night
The sun trajectory calculation previously emitted garbage if midnight
sun or polar night phenomena was in effect. To fix this, the calculation
is overhauled to report if the computation failed, and if so, which
specific phenomena was the cause.

Timing recalulation uses this information to change out of the normal
state that uses the four sun position timings, into a static state where
wlsunset simply waits a day at a time for a normal sun trajectory
pattern to be restored. In this state, a fixedc high/low temperature is
set as appropriate for the phenomena.

A transition phase replicating the previous day's sunrise is used to
smooth out entry into a midnight sun, which would otherwise cause a
jarring instant-daylight setting.
2020-10-18 00:36:52 +02:00