LinuxCommandLibrary

wlsunset

Adjust screen color temperature based on time

TLDR

Automatically compute sunset/sunrise times based on the specified location

$ wlsunset -l [latitude] -L [longitude]
copy

Manually set the sunset/sunrise times (time format: HH:MM)
$ wlsunset -s [sunset_time] -S [sunrise_time]
copy

Set the high and low temperatures (default: high - 6500, low - 4000)
$ wlsunset -T [high_temp] -t [low_temp]
copy

Set the animation time to n seconds (only applicable when using manual sunset/sunrise times)
$ wlsunset -d [n] -s [sunset_time] -S [sunrise_time]
copy

Set the gamma (default: 1.0)
$ wlsunset -g [gamma_value]
copy

SYNOPSIS

wlsunset [-l ] [-L ] [-t :] [-g ] [-S :] [-T ] [-m ]

PARAMETERS

-l
    Set latitude manually. Overrides automatic location detection.

-L
    Set longitude manually. Overrides automatic location detection.

-t :
    Set daytime and nighttime color temperatures in Kelvin (K). Example: 6500:4500. Default is 6500:4500.

-g
    Set gamma value for red, green, and blue channels. Can be a single value applied to all channels, or separate values separated by colons. Example: 1.0 or 0.8:0.7:0.9. Default is 1.0.

-S :
    Set custom sunrise and sunset times, overriding calculations based on location and time. Times should be in HH:MM format. Example: 07:00:19:00.

-T
    Set custom transition time between color temperatures, overriding calculated transition time. Time should be in minutes. Example: 60.

-m
    Specify location detection method. Options include 'geoclue2', 'manual', 'locationd', 'ipinfo', or 'whereami'. If none specified, wlsunset will attempt to use each method successively until it obtains the location.

-p
    Print current parameters to standard output.

-v
    Verbose output (for debugging).

-h
    Display help message.

-V
    Display version information.

DESCRIPTION

wlsunset is a command-line utility designed to automatically adjust the color temperature of your screen based on the position of the sun. This simulates the changing natural light throughout the day, reducing eye strain, particularly in the evening.

The core functionality involves gradually shifting the screen's color temperature from cooler, bluer tones during the day to warmer, more yellow tones as the sun sets. This mimics the natural light environment and helps regulate melatonin production, potentially improving sleep quality. wlsunset uses your location (either determined automatically or configured manually) along with the current time to calculate the sun's position and adjust the color temperature accordingly.

Unlike some other similar utilities, wlsunset is specifically built to work with Wayland compositors using the wlr-gamma-control protocol, providing a Wayland-native solution for color temperature adjustment. It does not require root privileges to execute and can be easily configured to run automatically on system startup. Correct function requires a Wayland compositor that supports wlr-gamma-control v1 or newer.

CAVEATS

wlsunset only works with Wayland compositors that implement the wlr-gamma-control protocol. If your compositor doesn't support this, wlsunset will not function. Automatic location detection requires appropriate services to be installed and configured (e.g., GeoClue2). Manual location setting is more reliable if automatic detection fails.

Incorrect latitude or longitude will cause the program to function incorrectly. Make sure the program can identify your location correctly or set it manually.

CONFIGURATION

While wlsunset can be run directly from the command line, it's typically configured to start automatically on system login. This can be achieved using systemd user units, desktop environment autostart mechanisms, or through a script executed at login. Configuration files are not directly used by wlsunset, instead it relies on command line arguments.

Example systemd user unit:

[Unit]
Description=wlsunset

[Service]
ExecStart=/usr/bin/wlsunset -l -L -t 6500:4500

[Install]
WantedBy=graphical-session.target

Replace and with correct values.

LOCATION DETECTION METHODS

wlsunset employs different methods to determine your location. When geoclue2 is used, it depends on Geoclue2 service. The service needs to be configured correctly and has permission to determine the location. When method is set to ipinfo, wlsunset uses external API. See ipinfo.io for more details. Locationd is not available on most distributions, it relies on Apple's CoreLocation framework.

HISTORY

The need for tools like wlsunset arose from increased screen usage and its impact on sleep cycles. By automatically adjusting the screen's color temperature, it aims to mitigate the negative effects of blue light exposure at night. wlsunset has evolved to provide a Wayland-native alternative, specifically targeting the growing Wayland ecosystem. Its development focused on being lightweight and easy to integrate into Wayland environments.

SEE ALSO

Copied to clipboard