diff --git a/COLORSCHEMES.md b/COLORSCHEMES.md index 1f629662..08ef522a 100644 --- a/COLORSCHEMES.md +++ b/COLORSCHEMES.md @@ -104,8 +104,6 @@ proportion is configurable, like this for a 80/20 proportion: Now that we are happy with the content of `FooBar.ini`, we can call the script `add_color_scheme.sh` stored in `data/color_schemes/` as seen below: -`add_color_scheme.sh eet ~/.config/terminology/colorschemes.eet FooBar.ini` +`add_color_scheme.sh eet ~/.config/terminology/colorschemes/FooBar.eet FooBar.ini` Now you should be able to select your color scheme in Terminology! - - diff --git a/data/colorschemes/add_color_scheme.sh b/data/colorschemes/add_color_scheme.sh index 1edf5c24..37c404f5 100755 --- a/data/colorschemes/add_color_scheme.sh +++ b/data/colorschemes/add_color_scheme.sh @@ -6,6 +6,8 @@ COMPRESS=1 EET=$1 shift +EET_FILE=$1 +shift INI=$1 shift @@ -14,17 +16,18 @@ GET_NAME=$(dirname "$0")/get_name.py NAME=$($GET_NAME "$INI") +# ensure output directory exists +mkdir -p "$(dirname "$EET_FILE")" + # generate desc on a temporary file TMP_DESC=$(mktemp "$NAME-DESC-XXXXXX") +TMP_EET=$(mktemp "$NAME-EET-XXXXXX") # trap to avoid creating orphan files -trap 'rm -f "$TMP_DESC"' INT TERM HUP EXIT +trap 'rm -f "$TMP_DESC" "$TMP_EET"' INT TERM HUP EXIT NAME=$($GET_NAME "$INI") -mkdir -p "data/colorschemes" -EET_FILE="data/colorschemes/$NAME.eet" - [ ! -w "$EET_FILE" ] && touch "$EET_FILE" echo "Generating $EET_FILE" diff --git a/data/colorschemes/builder.sh b/data/colorschemes/builder.sh deleted file mode 100755 index 28e778ab..00000000 --- a/data/colorschemes/builder.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -set -e -set -u - -EET=$1 -shift -ADD_COLOR_SCHEME=$(dirname "$0")/add_color_scheme.sh - -for INI in "$@" -do - echo "Building $INI" - # use the name, without extension as key in eet - $ADD_COLOR_SCHEME "$EET" "$INI" -done diff --git a/data/colorschemes/meson.build b/data/colorschemes/meson.build index 87e4e082..c23add2f 100644 --- a/data/colorschemes/meson.build +++ b/data/colorschemes/meson.build @@ -1,46 +1,52 @@ -colorschemes_desc = [ - 'Belafonte Day.ini', - 'Belafonte Night.ini', - 'Black.ini', - 'Cobalt2.ini', - 'Dracula.ini', - 'Fahrenheit.ini', - 'Material.ini', - 'Mild.ini', - 'Mustang.ini', - 'Nord.ini', - 'Ocean Dark.ini', - 'One Dark.ini', - 'PaleNight.ini', - 'PaperColor.ini', - 'Smyck.ini', - 'Soft Era.ini', - 'Solarized.ini', - 'Solarized Light.ini', - 'Tango Dark.ini', - 'Tango Light.ini', - 'Tomorrow Night Burns.ini', +colorschemes = [ + 'Belafonte Day', + 'Belafonte Night', + 'Black', + 'Cobalt2', + 'Dracula', + 'Fahrenheit', + 'Material', + 'Mild', + 'Mustang', + 'Nord', + 'Ocean Dark', + 'One Dark', + 'PaleNight', + 'PaperColor', + 'Smyck', + 'Soft Era', + 'Solarized', + 'Solarized Light', + 'Tango Dark', + 'Tango Light', + 'Tomorrow Night Burns', ] -colorschemes_out = [] +add_color_scheme_sh = find_program( + 'add_color_scheme.sh', + native: false, + required: true, + dirs: [join_paths(meson.source_root(), 'data', 'colorschemes')]) -foreach c : colorschemes_desc - colorschemes_out += c.replace('ini','eet') -endforeach +cs_builder = [add_color_scheme_sh, + eet_bin, '@OUTPUT@', '@INPUT@'] -cs_builder = [join_paths(meson.source_root(), - 'data', 'colorschemes', 'builder.sh'), - eet_bin, '@INPUT@'] cs_install_dir = join_paths(get_option('datadir'), - meson.project_name(), - 'colorschemes') + meson.project_name()) + +cs_install_dir = join_paths( + get_option('datadir'), + meson.project_name(), + 'colorschemes') -custom_target('colorschemes', - install:true, - install_dir: cs_install_dir, - install_mode: 'rw-r--r--', - depend_files: ['builder.sh', 'ini2desc.py', 'get_name.py', 'add_color_scheme.sh'], - command: cs_builder, - input: colorschemes_desc, - output: colorschemes_out) +foreach c : colorschemes + custom_target(c, + install:true, + install_dir: cs_install_dir, + install_mode: 'rw-r--r--', + depend_files : ['ini2desc.py', 'get_name.py', 'add_color_scheme.sh'], + command: cs_builder, + input: [c + '.ini'], + output: [c + '.eet']) +endforeach