1080*80 ad

Nightlight in Hyprland

A Practical Guide to Setting Up a Night Light in Hyprland

If you spend long hours in front of your computer, especially late at night, you’re likely familiar with the harshness of a bright, blue-toned screen. This blue light can lead to eye strain and disrupt your natural sleep cycle. Fortunately, most modern operating systems offer a “night light” feature that warms the screen’s color temperature after sunset. For users of the highly customizable Hyprland window manager on Wayland, setting this up is simple and incredibly effective.

This guide will walk you through implementing a robust night light feature in your Hyprland setup using wlsunset, a lightweight and powerful tool designed for Wayland compositors.

Why a Night Light is Essential

Before diving into the setup, it’s worth understanding the benefits. The primary goal of a night light is to reduce the amount of blue light emitted by your display. Scientific studies suggest that blue light exposure, particularly in the evening, can suppress the production of melatonin, the hormone that regulates sleep. By shifting your screen’s color to a warmer, more reddish hue, a night light can:

  • Reduce eye strain and fatigue.
  • Help maintain your natural circadian rhythm.
  • Potentially improve the quality of your sleep.

Getting Started with wlsunset

The recommended tool for this task is wlsunset. It’s a native Wayland utility that automatically adjusts your screen’s color temperature based on your geographical location and the time of day.

Installation

First, you need to install wlsunset using your distribution’s package manager. Here are the commands for a few popular systems:

For Arch Linux:

sudo pacman -S wlsunset

For Fedora:

sudo dnf install wlsunset

For Debian/Ubuntu (check availability in your version):

sudo apt-get install wlsunset

If it’s not available in your official repositories, you may need to build it from the source.

Basic Usage

To test wlsunset, simply run it from your terminal:

wlsunset

The application will attempt to use your system’s location services to determine your coordinates and automatically calculate sunrise and sunset times. However, if location services are unavailable or fail, you’ll need to provide your latitude and longitude manually.

You can do this with the -l (latitude) and -L (longitude) flags. For example:

wlsunset -l 40.7 -L -74.0

You can also manually set a specific color temperature (in Kelvin) with the -t flag. A lower value is warmer (more red), while a higher value is cooler (more blue).

# Set a warm temperature of 4000K
wlsunset -t 4000

Automating Night Light in Your hyprland.conf

Running a command manually every time you log in isn’t practical. The best way to manage this is to have Hyprland launch wlsunset for you automatically at startup.

To do this, you’ll add an exec-once command to your Hyprland configuration file, which is typically located at ~/.config/hypr/hyprland.conf.

  1. Open your hyprland.conf file in a text editor.

  2. Add the following line, usually in the section with other startup applications:

    exec-once = wlsunset
    

This exec-once directive ensures that wlsunset is started only once when you log into your Hyprland session. The application will then run quietly in the background, managing your screen’s color temperature throughout the day and night without any further intervention.

Advanced Customization with a Config File

For a more permanent and customized setup, you can create a configuration file for wlsunset. This is especially useful if you need to manually set your location or want to define specific day and night color temperatures.

  1. Create the configuration directory and file:

    mkdir -p ~/.config/wlsunset
    touch ~/.config/wlsunset/config
    
  2. Open the config file and add your desired settings. A typical configuration looks like this:

    # Your geographical coordinates
    lat=40.7
    lon=-74.0
    
    # Nighttime color temperature (e.g., 4000K)
    temp-low=4000
    
    # Daytime color temperature (e.g., 6500K for neutral)
    temp-high=6500
    

A quick tip for finding your coordinates: Simply search for “latitude and longitude of [your city]” in a web browser.

With this configuration file in place, you no longer need to pass flags to the command. Your exec-once = wlsunset line in hyprland.conf will now automatically use these settings on startup.

Managing the wlsunset Process

If you ever need to stop the night light effect, you can kill the wlsunset process. Open a terminal and run:

killall wlsunset

Your screen will immediately revert to its default color temperature. To restart it, you can either run wlsunset manually from the terminal or simply log out and back into your Hyprland session.

By integrating wlsunset into your Hyprland environment, you can create a more comfortable and eye-friendly computing experience that seamlessly adapts to the time of day. It’s a small change that can make a big difference to your digital well-being.

Source: https://itsfoss.com/nightlight-hyprland/

900*80 ad

      1080*80 ad