]> git.alsa-project.org Git - alsa-utils.git/commitdiff
alsamixer: Fix regression in color setup
authorTakashi Iwai <tiwai@suse.de>
Thu, 20 Jan 2022 07:49:17 +0000 (08:49 +0100)
committerTakashi Iwai <tiwai@suse.de>
Thu, 20 Jan 2022 07:58:48 +0000 (08:58 +0100)
The recent change to add the background config broke the color setup
via the config file due.  Fix the regression by restoring the
initialization order back again, and changing the logic for the
default background color to be re-initializing color pairs instead.

Link: https://github.com/alsa-project/alsa-utils/issues/137
Signed-off-by: Takashi Iwai <tiwai@suse.de>
alsamixer/cli.c
alsamixer/colors.c
alsamixer/colors.h
alsamixer/configparser.c

index 63c4949bab963399df82a27ce5a2977b6d28129d..f153f280cd9fec5c31d94192c249fb0d14929074 100644 (file)
@@ -152,15 +152,15 @@ int main(int argc, char *argv[])
 
        parse_options(argc, argv);
 
+       create_mixer_object(&selem_regopt);
+
+       initialize_curses(use_color, use_mouse);
+
        if (config_file == CONFIG_DEFAULT)
                parse_default_config_file();
        else if (config_file)
                parse_config_file(config_file);
 
-       create_mixer_object(&selem_regopt);
-
-       initialize_curses(use_color, use_mouse);
-
        create_mixer_widget();
 
        mainloop();
index f76dc26ef3809788c07d60f2167a93c9310a0541..cca5233e82cdbe79e648c6ffda6ec1f27afc968f 100644 (file)
@@ -23,7 +23,7 @@
 #include "colors.h"
 
 struct attributes attrs;
-short background_color = -1;
+static short background_color = -1;
 
 int get_color_pair(short fg, short bg)
 {
@@ -45,6 +45,17 @@ int get_color_pair(short fg, short bg)
        return 0;
 }
 
+void reinit_colors(short bg)
+{
+       if (bg == background_color)
+               return;
+       init_pair(1, COLOR_CYAN, bg);
+       init_pair(2, COLOR_YELLOW, bg);
+       init_pair(4, COLOR_RED, bg);
+       init_pair(5, COLOR_WHITE, bg);
+       background_color = bg;
+}
+
 void init_colors(int use_color)
 {
        if (!!has_colors() == !!use_color) {
index 1c7bff8e7d32900ec16d929c135ac2de1f605bc9..ac404e9ccc167543ebdce969ed76c5c568693788 100644 (file)
@@ -34,9 +34,9 @@ struct attributes {
 };
 
 extern struct attributes attrs;
-extern short background_color;
 
 void init_colors(int use_color);
+void reinit_colors(short bg);
 int get_color_pair(short fg, short bg);
 
 #endif
index 4396d4ff302e6a04dc06e0cff3bcba2a615abd19..b2b55f4754bc00e3d6f5d7e8bb4483a2df60b9df 100644 (file)
@@ -451,7 +451,7 @@ static int cfg_set(char **argv, unsigned int argc)
                                error_cause = argv[1];
                                return ERROR_CONFIG;
                        }
-                       background_color = bg_color;
+                       reinit_colors(bg_color);
                }
                else {
                        error_message = _("unknown option");