-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.c
More file actions
37 lines (31 loc) · 1.27 KB
/
config.c
File metadata and controls
37 lines (31 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "notewm.h"
unsigned long color_to_ulong(const char* color_str);
unsigned long color_to_ulong(const char* color_str)
{
if (color_str[0] == '#') {
color_str++;
}
return strtoul(color_str, NULL, 16);
}
int conf_handler(void* user, const char* section, const char* name, const char* value)
{
NoteWM_Config* pconfig = (NoteWM_Config*)user;
#define MATCH(s, n) strcmp(section, s) == 0 && strcmp(name, n) == 0
if (MATCH("Colors", "title-bar"))
pconfig->title_bar_color = color_to_ulong(value);
else if (MATCH("Colors", "border"))
pconfig->border_color = color_to_ulong(value);
else if (MATCH("Colors", "background"))
pconfig->bg_color = color_to_ulong(value);
else if (MATCH("Colors", "foreground"))
pconfig->fg_color = color_to_ulong(value);
else if (MATCH("Colors", "button-close"))
pconfig->close_color = color_to_ulong(value);
else if (MATCH("Colors", "button-expand"))
pconfig->expand_color = color_to_ulong(value);
else if (MATCH("Colors", "button-split"))
pconfig->split_color = color_to_ulong(value);
else
return 0;
return 1;
}