From e8b9a33167dbae87c4e80953fec2cf2c8180df51 Mon Sep 17 00:00:00 2001 From: Davide Madrisan Date: Sat, 10 Nov 2012 21:01:37 +0100 Subject: [PATCH] lib/libmsgmng.lib, conf/Makefile: move theme settings to configuration files (color-theme.*) Signed-off-by: Davide Madrisan --- ChangeLog | 3 +++ autospec.spec.in | 2 ++ conf/Makefile | 11 +++++++---- lib/libmsgmng.lib.in | 41 ++++++----------------------------------- 4 files changed, 18 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index 31061a0..1c3d029 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,9 @@ Changes in version 1.14.2 A color scheme can be selected now by using the new command-line option '--colorize-theme'. + * lib/libmsgmng.lib, conf/Makefile - Davide Madrisan: + Move theme settings to configuration files (color-theme.*) + ------------------------------------------------------------------------------- Changes in version 1.14.1 - _TO*Hacklab release diff --git a/autospec.spec.in b/autospec.spec.in index 505f539..3968ef9 100644 --- a/autospec.spec.in +++ b/autospec.spec.in @@ -162,8 +162,10 @@ make install DESTDIR=%{buildroot} prefix=%{_prefix} %dir %{_sysconfdir}/%{name}.d %if %{rpmbuild_group} == "root" %config %attr(644,root,root) %{_sysconfdir}/%{name}.d/*.conf +%config %attr(644,root,root) %{_sysconfdir}/%{name}.d/color-theme.* %else %config %attr(640,root,%{rpmbuild_group}) %{_sysconfdir}/%{name}.d/*.conf +%config %attr(644,root,%{rpmbuild_group}) %{_sysconfdir}/%{name}.d/color-theme.* %endif %files libs diff --git a/conf/Makefile b/conf/Makefile index 58c01e8..5939d00 100644 --- a/conf/Makefile +++ b/conf/Makefile @@ -39,18 +39,21 @@ pck_confs := autospec.conf \ pck_confs_infiles := $(wildcard *.in) +pck_color_themes := color-theme.terminal-dark \ + color-theme.terminal-white color-theme.web + all: -check: $(pck_confs) - @for f in $(pck_confs); do\ +check: $(pck_confs) $(pck_color_themes) + @for f in $(pck_confs) $(pck_color_themes); do\ echo -n "checking $$f... ";\ bash -n $$f \ && echo "[PASSED]" || { echo "[FAILED]"; exit 1; };\ done -install: $(pck_confs) +install: $(pck_confs) $(pck_color_themes) @$(INSTALL_DIR) $(DESTDIR)$(confdir) - for f in $(pck_confs); do\ + for f in $(pck_confs) $(pck_color_themes); do\ if [ $${f} = "autospec.conf" ]; then\ $(INSTALL_DATA) $${f} $(DESTDIR)$(sysconfdir)/$${f};\ else\ diff --git a/lib/libmsgmng.lib.in b/lib/libmsgmng.lib.in index 694b217..623f723 100644 --- a/lib/libmsgmng.lib.in +++ b/lib/libmsgmng.lib.in @@ -57,42 +57,13 @@ function notify.enable_colors() { # for backward compatibility [ "$colorize_theme" ] || colorize_theme="terminal-dark" - case "$colorize_theme" in - "web") - CRIT="" - NOTE="" - WARN="" - EXIT="$CRIT" - NORM="" - ;; - "terminal-white") - if [[ -t 1 && "$TERM" != raw && "$TERM" != dumb ]]; then - ESC=$(echo -en "\033") # ascii ESCape - [ "$NOTE" ] || NOTE="${ESC}[1;34m" # switch on blu - [ "$WARN" ] || WARN="${ESC}[1;31m" - [ "$EXIT" ] || EXIT="${ESC}[1;31m" - [ "$NORM" ] || NORM=$(echo -en "${ESC}[m\017") - else - ESC= CRIT= NOTE= WARN= EXIT= NORM= - fi - ;; - "terminal-dark") - if [[ -t 1 && "$TERM" != raw && "$TERM" != dumb ]]; then - ESC=$(echo -en "\033") # ascii ESCape - [ "$CRIT" ] || CRIT="${ESC}[1;31m" # switch on red - [ "$NOTE" ] || NOTE="${ESC}[1;33m" # switch on yellow - [ "$WARN" ] || WARN="${ESC}[1;31m" - [ "$EXIT" ] || EXIT="${ESC}[1;31m" - [ "$NORM" ] || NORM=$(echo -en "${ESC}[m\017") - else - ESC= CRIT= NOTE= WARN= EXIT= NORM= - fi - ;; - *) echo \ + if [ -r /etc/@package@.d/color-theme.${colorize_theme} ]; then + . /etc/@package@.d/color-theme.${colorize_theme} + else + notify.warning \ $"unknown color theme \`$colorize_theme': colors will be disabled" - ESC= CRIT= NOTE= WARN= EXIT= NORM= - ;; - esac + ESC= CRIT= NOTE= WARN= EXIT= NORM= + fi } # function notify.disable_colors