lib/libmsgmng.lib, conf/Makefile: move theme settings to configuration files (color-theme.*)

Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>
This commit is contained in:
Davide Madrisan 2012-11-10 21:01:37 +01:00
parent cd7d6b663d
commit e8b9a33167
4 changed files with 18 additions and 39 deletions

View File

@ -18,6 +18,9 @@ Changes in version 1.14.2
A color scheme can be selected now by using the new command-line option A color scheme can be selected now by using the new command-line option
'--colorize-theme'. '--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 Changes in version 1.14.1 - _TO*Hacklab release

View File

@ -162,8 +162,10 @@ make install DESTDIR=%{buildroot} prefix=%{_prefix}
%dir %{_sysconfdir}/%{name}.d %dir %{_sysconfdir}/%{name}.d
%if %{rpmbuild_group} == "root" %if %{rpmbuild_group} == "root"
%config %attr(644,root,root) %{_sysconfdir}/%{name}.d/*.conf %config %attr(644,root,root) %{_sysconfdir}/%{name}.d/*.conf
%config %attr(644,root,root) %{_sysconfdir}/%{name}.d/color-theme.*
%else %else
%config %attr(640,root,%{rpmbuild_group}) %{_sysconfdir}/%{name}.d/*.conf %config %attr(640,root,%{rpmbuild_group}) %{_sysconfdir}/%{name}.d/*.conf
%config %attr(644,root,%{rpmbuild_group}) %{_sysconfdir}/%{name}.d/color-theme.*
%endif %endif
%files libs %files libs

View File

@ -39,18 +39,21 @@ pck_confs := autospec.conf \
pck_confs_infiles := $(wildcard *.in) pck_confs_infiles := $(wildcard *.in)
pck_color_themes := color-theme.terminal-dark \
color-theme.terminal-white color-theme.web
all: all:
check: $(pck_confs) check: $(pck_confs) $(pck_color_themes)
@for f in $(pck_confs); do\ @for f in $(pck_confs) $(pck_color_themes); do\
echo -n "checking $$f... ";\ echo -n "checking $$f... ";\
bash -n $$f \ bash -n $$f \
&& echo "[PASSED]" || { echo "[FAILED]"; exit 1; };\ && echo "[PASSED]" || { echo "[FAILED]"; exit 1; };\
done done
install: $(pck_confs) install: $(pck_confs) $(pck_color_themes)
@$(INSTALL_DIR) $(DESTDIR)$(confdir) @$(INSTALL_DIR) $(DESTDIR)$(confdir)
for f in $(pck_confs); do\ for f in $(pck_confs) $(pck_color_themes); do\
if [ $${f} = "autospec.conf" ]; then\ if [ $${f} = "autospec.conf" ]; then\
$(INSTALL_DATA) $${f} $(DESTDIR)$(sysconfdir)/$${f};\ $(INSTALL_DATA) $${f} $(DESTDIR)$(sysconfdir)/$${f};\
else\ else\

View File

@ -57,42 +57,13 @@ function notify.enable_colors() {
# for backward compatibility # for backward compatibility
[ "$colorize_theme" ] || colorize_theme="terminal-dark" [ "$colorize_theme" ] || colorize_theme="terminal-dark"
case "$colorize_theme" in if [ -r /etc/@package@.d/color-theme.${colorize_theme} ]; then
"web") . /etc/@package@.d/color-theme.${colorize_theme}
CRIT="<font color=white style=\"background-color:red\">"
NOTE="<font color=gold>"
WARN="<font color=red>"
EXIT="$CRIT"
NORM="</font>"
;;
"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 else
ESC= CRIT= NOTE= WARN= EXIT= NORM= notify.warning \
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 \
$"unknown color theme \`$colorize_theme': colors will be disabled" $"unknown color theme \`$colorize_theme': colors will be disabled"
ESC= CRIT= NOTE= WARN= EXIT= NORM= ESC= CRIT= NOTE= WARN= EXIT= NORM=
;; fi
esac
} }
# function notify.disable_colors # function notify.disable_colors