hyprshade

repository·main·Indexed 20 days ago

https://github.com/loqusion/hyprshade

A front-end for Hyprland's screen shader feature that automates switching shaders based on a schedule or manual commands. It serves as a replacement for color temperature adjustment tools like f.lux or redshift, providing a CLI to list, enable, disable, and toggle shaders, as well as systemd integration for automated scheduling via hyprshade.toml.

Tokens
3.8K
Snippets
19
Records
23
Agent score
68%

What's inside hyprshade

  1. Install the latest Hyprshade via AUR

    main

    If you require the latest features and want to avoid compatibility issues with older examples, install the hyprshade-git package from the Arch User Repository (AUR).

    # Use your preferred AUR helper (e.g., yay, paru)
    yay -S hyprshade-git
  2. Install Hyprshade

    main

    Hyprshade can be installed via Arch Linux AUR or PyPI using pipx.

    ### Arch Linux
    ```sh
    # Using an AUR helper
    paru -S hyprshade
    
    # Manual installation
    sudo pacman -S --needed base-devel
    git clone https://aur.archlinux.org/hyprshade.git
    cd hyprshade
    makepkg -si

    PyPI

    pipx install hyprshade
  3. Configure shader scheduling

    main

    To automate shader switching based on time, create a configuration file at ~/.config/hypr/hyprshade.toml or ~/.config/hyprshade/config.toml.

    Important Requirements:

    1. Environment Variable: systemd --user must have access to HYPRLAND_INSTANCE_SIGNATURE. Add this to your hyprland.conf: exec-once = dbus-update-activation-environment --systemd HYPRLAND_INSTANCE_SIGNATURE
    2. Systemd Units: You must install the user units and enable the timer.
    3. Syncing: Run hyprshade install whenever you modify your .toml config to keep units in sync.
    [[shades]]
    name = "vibrance"
    default = true  # activated when no other shader is scheduled
    
    [[shades]]
    name = "blue-light-filter"
    start_time = 19:00:00
    end_time = 06:00:00
    # 1. Setup environment in hyprland.conf
    # exec-once = dbus-update-activation-environment --systemd HYPRLAND_INSTANCE_SIGNATURE
    
    # 2. Install and enable timer
    hyprshade install
    systemctl --user enable --now hyprshade.timer
    
    # 3. Recommended: Ensure correct shader on login
    # Add to hyprland.conf:
    # exec = hyprshade auto
  4. Install the latest version of Hyprshade via AUR

    main

    To access the latest features and ensure compatibility with current shaders, the only officially supported method is to install the hyprshade-git package from the Arch User Repository (AUR).

    # Example using an AUR helper like yay
    yay -S hyprshade-git
  5. Compatibility Warning for Examples

    main

    The example files located in the examples/ directory are only compatible with Hyprshade v4.0.0. They are not compatible with the latest stable release.

    To use the latest features of Hyprshade, you should install the hyprshade-git package from the AUR instead of using these examples.

  6. Compatibility warning for files in the shaders directory

    main

    The shader files located in the shaders/ directory are only compatible with v4.0.0 and are not compatible with the latest stable release.

    Manually copying these files is generally unnecessary. If running hyprshade on fails to activate a shader, it is recommended to open a bug report rather than attempting manual file manipulation.

  7. Use Hyprshade CLI commands

    main

    Hyprshade provides several commands to manage screen shaders. When providing a shader name, you can use the basename (which searches in ~/.config/hypr/shaders and /usr/share/hyprshade) or the full path to a .glsl file.

    Usage: hyprshade [OPTIONS] COMMAND [ARGS]...
    
    Commands:
      auto     Set screen shader on schedule
      current  Print current screen shader
      install  Install systemd user units
      ls       List available screen shaders
      off      Turn off screen shader
      on       Turn on screen shader
      toggle   Toggle screen shader

    Examples

    Using basename

    hyprshade on blue-light-filter

    Using full path

    hyprshade on ~/.config/hypr/shaders/blue-light-filter.glsl

  8. Get the current Hyprland screen shader

    main

    Use get_screen_shader() to retrieve the path of the currently active screen shader from Hyprland.

    • Returns the absolute path to the shader file as a str (with environment variables and ~ expanded).
    • Returns None if no shader is currently set.
    • Raises HyprctlError if the hyprctl command fails.
    • Raises HyprctlJSONError if the output from Hyprland is not valid JSON or is missing the expected str property.
    from hyprshade.shader.hyprctl import get_screen_shader
    
    shader_path = get_screen_shader()
    if shader_path:
        print(f"Current shader: {shader_path}")
    else:
        print("No shader active")
  9. Set or clear the Hyprland screen shader

    main

    You can programmatically control the Hyprland screen shader using set_screen_shader and clear_screen_shader. These functions interact with hyprctl to modify the decoration:screen_shader configuration option.

    • set_screen_shader(shader_path: str): Sets the screen shader to the provided file path. The path is automatically escaped for Lua compatibility.
    • clear_screen_shader(): Removes the current screen shader by setting it to an empty value.
    from hyprshade.shader.hyprctl import set_screen_shader, clear_screen_shader
    
    # Set a specific shader
    set_screen_shader("/path/to/my/shader.glsl")
    
    # Remove the shader
    clear_screen_shader()
  10. Reference: `hyprshade toggle` options and arguments

    main

    The following arguments and options are available for the toggle command:

    Arguments:
      SHADER (optional)             The shader to toggle.
    
    Options:
      --fallback SHADER             Select a specific fallback shader.
      --fallback-default           Use the default shader defined in the config as the fallback.
      --fallback-auto              Automatically infer the fallback from the schedule configuration.
                                   (If the currently scheduled shader and SHADER are identical, 
                                   the fallback will be the default shader).
      --variables <VARS>           (via @variables_option) Pass shader variables.