setup niri colors file; delete watcher script #2

merged
opened by thomas.rocks targeting main from niri-rewrite
+2 -2
private_dot_config/matugen/config.toml
··· 46 output_path = '~/.config/rofi/colors/matugen.rasi' 47 48 [templates.niri] 49 - input_path = './templates/niri-colors.conf' 50 - output_path = '~/.config/niri/colors.conf'
··· 46 output_path = '~/.config/rofi/colors/matugen.rasi' 47 48 [templates.niri] 49 + input_path = './templates/niri-colors.kdl' 50 + output_path = '~/.config/niri/colors.kdl'
-3
private_dot_config/matugen/templates/niri-colors.conf
··· 1 - <* for name, value in colors *> 2 - @{{name}} = {{value.default.hex}} 3 - <* endfor *>
···
+26
private_dot_config/matugen/templates/niri-colors.kdl
···
··· 1 + layout { 2 + focus-ring { 3 + // Color of the ring on the active monitor. 4 + active-color "{{ colors.primary.default.hex }}" 5 + 6 + // Color of the ring on inactive monitors. 7 + inactive-color "{{ colors.outline.default.hex }}" 8 + } 9 + 10 + border { 11 + active-color "{{ colors.secondary.default.hex }}" 12 + inactive-color "{{ colors.outline.default.hex }}" 13 + 14 + // Color of the border around windows that request your attention. 15 + urgent-color "{{ colors.error.default.hex }}" 16 + 17 + // active-gradient from="#ffbb66" to="#ffc880" angle=45 relative-to="workspace-view" 18 + // inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view" 19 + } 20 + 21 + shadow { 22 + // You can also change the shadow color and opacity. 23 + color "{{ colors.shadow.default.hex }}" 24 + } 25 + 26 + }
+2 -17
private_dot_config/niri/config.tmpl.kdl private_dot_config/niri/config.kdl
··· 3 // Check the wiki for a full description of the configuration: 4 // https://github.com/YaLTeR/niri/wiki/Configuration:-Introduction 5 6 // Input device configuration. 7 // Find the full list of options on the wiki: 8 // https://github.com/YaLTeR/niri/wiki/Configuration:-Input ··· 161 // - RGB hex: "#rgb", "#rgba", "#rrggbb", "#rrggbbaa" 162 // - CSS-like notation: "rgb(255, 127, 0)", rgba(), hsl() and a few others. 163 164 - // Color of the ring on the active monitor. 165 - active-color "@primary" 166 - 167 - // Color of the ring on inactive monitors. 168 - inactive-color "@outline" 169 - 170 // You can also use gradients. They take precedence over solid colors. 171 // Gradients are rendered the same as CSS linear-gradient(angle, from, to). 172 // The angle is the same as in linear-gradient, and is optional, ··· 190 off 191 192 width 4 193 - active-color "@secondary" 194 - inactive-color "@outline" 195 - 196 - // Color of the border around windows that request your attention. 197 - urgent-color "@error" 198 - 199 - // active-gradient from="#ffbb66" to="#ffc880" angle=45 relative-to="workspace-view" 200 - // inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view" 201 } 202 203 // You can enable drop shadows for windows. ··· 232 233 // Offset moves the shadow relative to the window. 234 offset x=0 y=5 235 - 236 - // You can also change the shadow color and opacity. 237 - color "@shadow" 238 } 239 240 // Struts shrink the area occupied by windows, similarly to layer-shell panels.
··· 3 // Check the wiki for a full description of the configuration: 4 // https://github.com/YaLTeR/niri/wiki/Configuration:-Introduction 5 6 + include "colors.kdl" 7 + 8 // Input device configuration. 9 // Find the full list of options on the wiki: 10 // https://github.com/YaLTeR/niri/wiki/Configuration:-Input ··· 163 // - RGB hex: "#rgb", "#rgba", "#rrggbb", "#rrggbbaa" 164 // - CSS-like notation: "rgb(255, 127, 0)", rgba(), hsl() and a few others. 165 166 // You can also use gradients. They take precedence over solid colors. 167 // Gradients are rendered the same as CSS linear-gradient(angle, from, to). 168 // The angle is the same as in linear-gradient, and is optional, ··· 186 off 187 188 width 4 189 } 190 191 // You can enable drop shadows for windows. ··· 220 221 // Offset moves the shadow relative to the window. 222 offset x=0 y=5 223 } 224 225 // Struts shrink the area occupied by windows, similarly to layer-shell panels.
-78
private_dot_config/niri/executable_generate-config.sh
··· 1 - #!/usr/bin/env bash 2 - 3 - # Paths 4 - TEMPLATE_FILE="$HOME/.config/niri/config.tmpl.kdl" 5 - COLORS_FILE="$HOME/.config/niri/colors.conf" 6 - OUTPUT_FILE="$HOME/.config/niri/config.kdl" 7 - 8 - # Function to generate config 9 - generate_config() { 10 - echo "Regenerating niri config..." 11 - 12 - # Check if colors file exists 13 - if [[ ! -f "$COLORS_FILE" ]]; then 14 - echo "Colors file not found: $COLORS_FILE" 15 - return 1 16 - fi 17 - 18 - # Check if template file exists 19 - if [[ ! -f "$TEMPLATE_FILE" ]]; then 20 - echo "Template file not found: $TEMPLATE_FILE" 21 - return 1 22 - fi 23 - 24 - # Check if template file is not empty 25 - if [[ ! -s "$TEMPLATE_FILE" ]]; then 26 - echo "Template file is empty: $TEMPLATE_FILE" 27 - return 1 28 - fi 29 - 30 - # Read colors and create temporary variables 31 - declare -A colors 32 - while IFS='=' read -r key value; do 33 - if [[ $key =~ ^@([a-zA-Z_][a-zA-Z0-9_]*) ]]; then 34 - color_name="${BASH_REMATCH[1]}" 35 - color_value=$(echo "$value" | tr -d ' ') 36 - colors["$color_name"]="$color_value" 37 - fi 38 - done < "$COLORS_FILE" 39 - 40 - # Create temporary file for atomic write 41 - TEMP_FILE="${OUTPUT_FILE}.tmp" 42 - 43 - # Copy template to temporary file 44 - if ! cp "$TEMPLATE_FILE" "$TEMP_FILE"; then 45 - echo "Failed to copy template file" 46 - rm -f "$TEMP_FILE" 47 - return 1 48 - fi 49 - 50 - # Replace @color_name with actual color values 51 - for color_name in "${!colors[@]}"; do 52 - if ! sed -i "s/@${color_name}/${colors[$color_name]}/g" "$TEMP_FILE"; then 53 - echo "Failed to substitute colors" 54 - rm -f "$TEMP_FILE" 55 - return 1 56 - fi 57 - done 58 - 59 - # Verify the temporary file is not empty 60 - if [[ ! -s "$TEMP_FILE" ]]; then 61 - echo "Generated config is empty, not overwriting existing config" 62 - rm -f "$TEMP_FILE" 63 - return 1 64 - fi 65 - 66 - # Atomically move temp file to final location 67 - if mv "$TEMP_FILE" "$OUTPUT_FILE"; then 68 - echo "Config regenerated successfully!" 69 - return 0 70 - else 71 - echo "Failed to move config to final location" 72 - rm -f "$TEMP_FILE" 73 - return 1 74 - fi 75 - } 76 - 77 - # Generate config once on startup 78 - generate_config
···
-27
private_dot_config/niri/executable_niri-watcher.sh
··· 1 - #!/usr/bin/env bash 2 - 3 - # Paths 4 - TEMPLATE_FILE="$HOME/.config/niri/config.tmpl.kdl" 5 - COLORS_FILE="$HOME/.config/niri/colors.conf" 6 - OUTPUT_FILE="$HOME/.config/niri/config.kdl" 7 - 8 - 9 - # Call ./generate-config.sh 10 - generate_config() { 11 - "$HOME/.config/niri/generate-config.sh" 12 - } 13 - 14 - generate_config 15 - 16 - # Watch for changes 17 - echo "Watching for changes in $TEMPLATE_FILE and $COLORS_FILE..." 18 - inotifywait -m -e modify,create,delete,move,close_write \ 19 - "$(dirname "$TEMPLATE_FILE")" \ 20 - "$(dirname "$COLORS_FILE")" | 21 - while read -r path events filename; do 22 - if [[ "$path$filename" == "$TEMPLATE_FILE" || "$path$filename" == "$COLORS_FILE" ]]; then 23 - echo "Detected change: $events in $path$filename" 24 - sleep 0.2 25 - generate_config 26 - fi 27 - done
···