Fix colors in light theme terminals #7

Instead of having color themes and making cli a bit more complicated I
added a fix to make bacgkround black by default.
I attached alacritty light theme. Test it with `alacritty --config-file
alacritty.light.toml` and then run `xdgctl`.
This could be improved in the future.

Author Mitja Felicijan <mitja.felicijan@gmail.com> 2026-01-26 13:12:11 +0100
Committer Mitja Felicijan <mitja.felicijan@gmail.com> 2026-01-26 13:12:11 +0100
Commit 98a0702d56754f80eb6b9da017de10502548d14b (patch)
-rw-r--r-- alacritty.light.toml 31
-rw-r--r-- main.c 18
2 files changed, 41 insertions, 8 deletions
diff --git a/alacritty.light.toml b/alacritty.light.toml
  
1
[colors.primary]
  
2
background = "#FFFFFF"
  
3
foreground = "#1A1A1A"
  
4
  
  
5
[colors.cursor]
  
6
text = "#FFFFFF"
  
7
cursor = "#1A1A1A"
  
8
  
  
9
[colors.selection]
  
10
text = "#1A1A1A"
  
11
background = "#E5E5E5"
  
12
  
  
13
[colors.normal]
  
14
black   = "#000000"
  
15
red     = "#CC0000"
  
16
green   = "#008800"
  
17
yellow  = "#AA8800"
  
18
blue    = "#0033CC"
  
19
magenta = "#880088"
  
20
cyan    = "#008888"
  
21
white   = "#E6E6E6"
  
22
  
  
23
[colors.bright]
  
24
black   = "#666666"
  
25
red     = "#FF3333"
  
26
green   = "#22AA22"
  
27
yellow  = "#E6B800"
  
28
blue    = "#3366FF"
  
29
magenta = "#CC33CC"
  
30
cyan    = "#33CCCC"
  
31
white   = "#FFFFFF"
diff --git a/main.c b/main.c
...
23
#define COLOR_TITLE (TB_YELLOW | TB_BOLD)
23
#define COLOR_TITLE (TB_YELLOW | TB_BOLD)
24
#define COLOR_SELECTED TB_BLUE
24
#define COLOR_SELECTED TB_BLUE
25
#define COLOR_DEFAULT TB_WHITE
25
#define COLOR_DEFAULT TB_WHITE
26
#define COLOR_DIM TB_DIM
26
#define COLOR_BG TB_BLACK
  
27
#define COLOR_DIM TB_WHITE
27
#define COLOR_SUCCESS TB_GREEN
28
#define COLOR_SUCCESS TB_GREEN
28
#define COLOR_ERROR TB_RED
29
#define COLOR_ERROR TB_RED
29
  
30
  
...
100
}
101
}
101
  
102
  
102
void draw_titles() {
103
void draw_titles() {
103
	tb_print(X_OFF_CATEGORIES, Y_OFF_TITLES, COLOR_TITLE, TB_DEFAULT, "CATEGORIES");
104
	tb_print(X_OFF_CATEGORIES, Y_OFF_TITLES, COLOR_TITLE, COLOR_BG, "CATEGORIES");
104
	tb_print(X_OFF_APPS, Y_OFF_TITLES, COLOR_TITLE, TB_DEFAULT, "APPLICATIONS");
105
	tb_print(X_OFF_APPS, Y_OFF_TITLES, COLOR_TITLE, COLOR_BG, "APPLICATIONS");
105
	tb_print(X_OFF_FILE, Y_OFF_TITLES, COLOR_TITLE, TB_DEFAULT, "FILE");
106
	tb_print(X_OFF_FILE, Y_OFF_TITLES, COLOR_TITLE, COLOR_BG, "FILE");
106
}
107
}
107
  
108
  
108
void draw_categories(State *state) {
109
void draw_categories(State *state) {
...
111
	for (int i = 0; i < height && (i + state->category_offset) < count; ++i) {
112
	for (int i = 0; i < height && (i + state->category_offset) < count; ++i) {
112
		int idx = i + state->category_offset;
113
		int idx = i + state->category_offset;
113
		uint16_t fg = COLOR_DEFAULT;
114
		uint16_t fg = COLOR_DEFAULT;
114
		uint16_t bg = TB_DEFAULT;
115
		uint16_t bg = COLOR_BG;
115
		if (state->col == 0 && state->category_idx == idx) {
116
		if (state->col == 0 && state->category_idx == idx) {
116
			bg = COLOR_SELECTED;
117
			bg = COLOR_SELECTED;
117
		} else if (state->category_idx == idx) {
118
		} else if (state->category_idx == idx) {
...
131
			int idx = i + state->app_offset;
132
			int idx = i + state->app_offset;
132
			char *app_name = (char *)l->data;
133
			char *app_name = (char *)l->data;
133
			uint16_t fg = COLOR_DEFAULT;
134
			uint16_t fg = COLOR_DEFAULT;
134
			uint16_t bg = TB_DEFAULT;
135
			uint16_t bg = COLOR_BG;
135
			if (state->col == 1 && state->app_idx == idx) {
136
			if (state->col == 1 && state->app_idx == idx) {
136
				bg = COLOR_SELECTED;
137
				bg = COLOR_SELECTED;
137
			}
138
			}
...
166
		int idx = i + state->app_offset;
167
		int idx = i + state->app_offset;
167
		GAppInfo *app = (GAppInfo *)l->data;
168
		GAppInfo *app = (GAppInfo *)l->data;
168
		uint16_t fg = COLOR_DEFAULT;
169
		uint16_t fg = COLOR_DEFAULT;
169
		uint16_t bg = TB_DEFAULT;
170
		uint16_t bg = COLOR_BG;
170
		if (state->col == 1 && state->app_idx == idx) {
171
		if (state->col == 1 && state->app_idx == idx) {
171
			bg = COLOR_SELECTED;
172
			bg = COLOR_SELECTED;
172
		}
173
		}
...
204
		if (strncmp(state->message, "Failed", 6) == 0) {
205
		if (strncmp(state->message, "Failed", 6) == 0) {
205
			msg_col = COLOR_ERROR;
206
			msg_col = COLOR_ERROR;
206
		}
207
		}
207
		tb_print(X_OFF_CATEGORIES, tb_height() - 1, msg_col, TB_DEFAULT, state->message);
208
		tb_print(X_OFF_CATEGORIES, tb_height() - 1, msg_col, COLOR_BG, state->message);
208
	}
209
	}
209
  
210
  
210
	tb_present();
211
	tb_present();
...
214
	if (tb_init() != 0) {
215
	if (tb_init() != 0) {
215
		return 1;
216
		return 1;
216
	}
217
	}
  
218
	tb_set_clear_attrs(COLOR_DEFAULT, COLOR_BG);
217
  
219
  
218
	State state = {0, 0, 0, 0, 0, {0}, NULL, 0, 0};
220
	State state = {0, 0, 0, 0, 0, {0}, NULL, 0, 0};
219
	char *dev_env = getenv("XDGCTL_DEV");
221
	char *dev_env = getenv("XDGCTL_DEV");
...