hyprsunset

repository·main·Indexed 19 days ago

https://github.com/hyprwm/hyprsunset

A blue-light filter utility for the Hyprland compositor that adjusts screen color temperature and gamma. Requires Hyprland version 0.45.0 or newer and support for the hyprland-ctm-control-v1 protocol.

Tokens
1.2K
Snippets
4
Records
7
Agent score
67%

What's inside hyprsunset

  1. Requirements for using hyprsunset

    main

    To use hyprsunset, you must meet the following requirements:

    • Hyprland Version: You must be running hyprland >= 0.45.0.
    • Protocol Support: The compositor must support the hyprland-ctm-control-v1 protocol. Because of this dependency, hyprsunset is likely exclusive to Hyprland.
  2. Configure hyprsunset temperature and gamma

    main

    The CHyprsunset class manages the blue-light filter state through several configurable parameters. You can set the color temperature in Kelvin and adjust the gamma levels.

    Note that kelvinSet and identity flags are used to track whether these values have been explicitly modified from their defaults. Setting identity to true typically reverts the color transformation to a neutral state.

    CHyprsunset sunset;
    sunset.KELVIN = 3000;      // Set temperature to 3000K
    sunset.kelvinSet = true;
    sunset.GAMMA = 0.8f;       // Adjust gamma
    sunset.MAX_GAMMA = 1.0f;
  3. Control the hyprsunset lifecycle

    main

    The CHyprsunset class provides methods to manage the application lifecycle and the application of color transformation matrices (CTM) to Wayland outputs:

    • init(): Initializes the application state and Wayland connections.
    • calculateMatrix(): Computes the color transformation matrix based on current settings.
    • tick(): Advances the internal state (used in the event loop).
    • loadCurrentProfile(): Loads the profile matching the current time.
    • getCurrentProfile(): Returns an std::optional<SSunsetProfile> representing the active profile.
    • terminate(): Gracefully shuts down the application.
  4. Manage sunset profiles

    main

    Hyprsunset supports scheduled profiles via the SSunsetProfile struct. Each profile defines a specific time (hour and minute) and associated color settings (temperature in Kelvin and gamma).

    • SSunsetProfile::time: A struct containing hour and minute.
    • SSunsetProfile::temperature: The target Kelvin value (default 6000).
    • SSunsetProfile::gamma: The target gamma value (default 1.0f).
    • SSunsetProfile::identity: A boolean flag.

    You can retrieve the currently active profile using getCurrentProfile().

    // Example of what a profile looks like
    SSunsetProfile profile;
    profile.time.hour = 20;
    profile.time.minute = 30;
    profile.temperature = 2500;
    profile.gamma = 1.0f;
  5. Access sunset profiles and gamma settings via CConfigManager

    main

    The CConfigManager class is responsible for managing application settings and configuration state. It uses hyprlang internally to parse configuration files. Developers interacting with the configuration state can retrieve the following:

    • getSunsetProfiles(): Returns a std::vector<SSunsetProfile> containing the available sunset profiles.
    • getMaxGamma(): Returns the maximum gamma value allowed by the configuration.

    To use the manager, it must be initialized via init().

    // Conceptual usage of the CConfigManager API
    g_pConfigManager->init();
    auto profiles = g_pConfigManager->getSunsetProfiles();
    float maxGamma = g_pConfigManager->getMaxGamma();
  6. Use hyprsunset CLI flags

    main

    The hyprsunset command-line interface allows you to control display color temperature and gamma settings. You can specify temperature in Kelvin, adjust gamma levels, or use the identity matrix to disable color changes.

    Available Flags

    FlagShortDescription
    --temperature-tSet the temperature in K (default 6000)
    --gamma-gSet the display gamma (default 100%)
    --gamma_maxSet the maximum display gamma (default 100%, maximum 200%)
    --identity-iUse the identity matrix (no color change)
    --config-cSpecify a path to a configuration file
    --verbosePrint more logging
    --version-vPrint the version
    --help-hPrint this info
    # Example: Set temperature to 3000K and gamma to 80%
    hyprsunset -t 3000 -g 80
    
    # Example: Use a specific config file
    hyprsunset --config /path/to/config.json