From 3c08314627b38d85b9368815e07bb49ee9d4fb21 Mon Sep 17 00:00:00 2001 From: "Thomas G. Lopes" Date: Tue, 30 Dec 2025 00:31:19 +0000 Subject: [PATCH] setup niri colors file; delete watcher script Change-Id: lqwtqynotwoonqkmxzwxqtqlxttsoprr --- private_dot_config/matugen/config.toml | 4 +- .../matugen/templates/niri-colors.conf | 3 - .../matugen/templates/niri-colors.kdl | 26 +++++++ .../niri/{config.tmpl.kdl => config.kdl} | 19 +---- .../niri/executable_generate-config.sh | 78 ------------------- .../niri/executable_niri-watcher.sh | 27 ------- 6 files changed, 30 insertions(+), 127 deletions(-) delete mode 100644 private_dot_config/matugen/templates/niri-colors.conf create mode 100644 private_dot_config/matugen/templates/niri-colors.kdl rename private_dot_config/niri/{config.tmpl.kdl => config.kdl} (97%) delete mode 100644 private_dot_config/niri/executable_generate-config.sh delete mode 100644 private_dot_config/niri/executable_niri-watcher.sh diff --git a/private_dot_config/matugen/config.toml b/private_dot_config/matugen/config.toml index 5021ded..5ece5a3 100644 --- a/private_dot_config/matugen/config.toml +++ b/private_dot_config/matugen/config.toml @@ -46,5 +46,5 @@ input_path = './templates/rofi-colors.rasi' output_path = '~/.config/rofi/colors/matugen.rasi' [templates.niri] -input_path = './templates/niri-colors.conf' -output_path = '~/.config/niri/colors.conf' +input_path = './templates/niri-colors.kdl' +output_path = '~/.config/niri/colors.kdl' diff --git a/private_dot_config/matugen/templates/niri-colors.conf b/private_dot_config/matugen/templates/niri-colors.conf deleted file mode 100644 index 531f9a8..0000000 --- a/private_dot_config/matugen/templates/niri-colors.conf +++ /dev/null @@ -1,3 +0,0 @@ -<* for name, value in colors *> -@{{name}} = {{value.default.hex}} -<* endfor *> diff --git a/private_dot_config/matugen/templates/niri-colors.kdl b/private_dot_config/matugen/templates/niri-colors.kdl new file mode 100644 index 0000000..150e0b6 --- /dev/null +++ b/private_dot_config/matugen/templates/niri-colors.kdl @@ -0,0 +1,26 @@ +layout { + focus-ring { + // Color of the ring on the active monitor. + active-color "{{ colors.primary.default.hex }}" + + // Color of the ring on inactive monitors. + inactive-color "{{ colors.outline.default.hex }}" + } + + border { + active-color "{{ colors.secondary.default.hex }}" + inactive-color "{{ colors.outline.default.hex }}" + + // Color of the border around windows that request your attention. + urgent-color "{{ colors.error.default.hex }}" + + // active-gradient from="#ffbb66" to="#ffc880" angle=45 relative-to="workspace-view" + // inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view" + } + + shadow { + // You can also change the shadow color and opacity. + color "{{ colors.shadow.default.hex }}" + } + +} diff --git a/private_dot_config/niri/config.tmpl.kdl b/private_dot_config/niri/config.kdl similarity index 97% rename from private_dot_config/niri/config.tmpl.kdl rename to private_dot_config/niri/config.kdl index fb1fd7b..d605fde 100644 --- a/private_dot_config/niri/config.tmpl.kdl +++ b/private_dot_config/niri/config.kdl @@ -3,6 +3,8 @@ // Check the wiki for a full description of the configuration: // https://github.com/YaLTeR/niri/wiki/Configuration:-Introduction +include "colors.kdl" + // Input device configuration. // Find the full list of options on the wiki: // https://github.com/YaLTeR/niri/wiki/Configuration:-Input @@ -161,12 +163,6 @@ layout { // - RGB hex: "#rgb", "#rgba", "#rrggbb", "#rrggbbaa" // - CSS-like notation: "rgb(255, 127, 0)", rgba(), hsl() and a few others. - // Color of the ring on the active monitor. - active-color "@primary" - - // Color of the ring on inactive monitors. - inactive-color "@outline" - // You can also use gradients. They take precedence over solid colors. // Gradients are rendered the same as CSS linear-gradient(angle, from, to). // The angle is the same as in linear-gradient, and is optional, @@ -190,14 +186,6 @@ layout { off width 4 - active-color "@secondary" - inactive-color "@outline" - - // Color of the border around windows that request your attention. - urgent-color "@error" - - // active-gradient from="#ffbb66" to="#ffc880" angle=45 relative-to="workspace-view" - // inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view" } // You can enable drop shadows for windows. @@ -232,9 +220,6 @@ layout { // Offset moves the shadow relative to the window. offset x=0 y=5 - - // You can also change the shadow color and opacity. - color "@shadow" } // Struts shrink the area occupied by windows, similarly to layer-shell panels. diff --git a/private_dot_config/niri/executable_generate-config.sh b/private_dot_config/niri/executable_generate-config.sh deleted file mode 100644 index 02a8b98..0000000 --- a/private_dot_config/niri/executable_generate-config.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env bash - -# Paths -TEMPLATE_FILE="$HOME/.config/niri/config.tmpl.kdl" -COLORS_FILE="$HOME/.config/niri/colors.conf" -OUTPUT_FILE="$HOME/.config/niri/config.kdl" - -# Function to generate config -generate_config() { - echo "Regenerating niri config..." - - # Check if colors file exists - if [[ ! -f "$COLORS_FILE" ]]; then - echo "Colors file not found: $COLORS_FILE" - return 1 - fi - - # Check if template file exists - if [[ ! -f "$TEMPLATE_FILE" ]]; then - echo "Template file not found: $TEMPLATE_FILE" - return 1 - fi - - # Check if template file is not empty - if [[ ! -s "$TEMPLATE_FILE" ]]; then - echo "Template file is empty: $TEMPLATE_FILE" - return 1 - fi - - # Read colors and create temporary variables - declare -A colors - while IFS='=' read -r key value; do - if [[ $key =~ ^@([a-zA-Z_][a-zA-Z0-9_]*) ]]; then - color_name="${BASH_REMATCH[1]}" - color_value=$(echo "$value" | tr -d ' ') - colors["$color_name"]="$color_value" - fi - done < "$COLORS_FILE" - - # Create temporary file for atomic write - TEMP_FILE="${OUTPUT_FILE}.tmp" - - # Copy template to temporary file - if ! cp "$TEMPLATE_FILE" "$TEMP_FILE"; then - echo "Failed to copy template file" - rm -f "$TEMP_FILE" - return 1 - fi - - # Replace @color_name with actual color values - for color_name in "${!colors[@]}"; do - if ! sed -i "s/@${color_name}/${colors[$color_name]}/g" "$TEMP_FILE"; then - echo "Failed to substitute colors" - rm -f "$TEMP_FILE" - return 1 - fi - done - - # Verify the temporary file is not empty - if [[ ! -s "$TEMP_FILE" ]]; then - echo "Generated config is empty, not overwriting existing config" - rm -f "$TEMP_FILE" - return 1 - fi - - # Atomically move temp file to final location - if mv "$TEMP_FILE" "$OUTPUT_FILE"; then - echo "Config regenerated successfully!" - return 0 - else - echo "Failed to move config to final location" - rm -f "$TEMP_FILE" - return 1 - fi -} - -# Generate config once on startup -generate_config diff --git a/private_dot_config/niri/executable_niri-watcher.sh b/private_dot_config/niri/executable_niri-watcher.sh deleted file mode 100644 index 820beb5..0000000 --- a/private_dot_config/niri/executable_niri-watcher.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -# Paths -TEMPLATE_FILE="$HOME/.config/niri/config.tmpl.kdl" -COLORS_FILE="$HOME/.config/niri/colors.conf" -OUTPUT_FILE="$HOME/.config/niri/config.kdl" - - -# Call ./generate-config.sh -generate_config() { - "$HOME/.config/niri/generate-config.sh" -} - -generate_config - -# Watch for changes -echo "Watching for changes in $TEMPLATE_FILE and $COLORS_FILE..." -inotifywait -m -e modify,create,delete,move,close_write \ - "$(dirname "$TEMPLATE_FILE")" \ - "$(dirname "$COLORS_FILE")" | -while read -r path events filename; do - if [[ "$path$filename" == "$TEMPLATE_FILE" || "$path$filename" == "$COLORS_FILE" ]]; then - echo "Detected change: $events in $path$filename" - sleep 0.2 - generate_config - fi -done -- 2.43.0