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
'--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

View File

@ -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

View File

@ -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\

View File

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