blob: 57edb2cbb34c5094cbda86ae0ae37bfee37bf259 (
plain)
1 /**
2 * I3cstatus prints a configurable status bar for the i3 window manager
3 * Copyright (C) 2021 Aaron Ball <nullspoon@oper.io>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #include "config_date.h"
19
20 void config_date_init(struct node* n) {
21 n->data = malloc(sizeof(struct config_date));
22 n->type = CTYPE_DATE;
23 n->loadfunc = &config_date_load;
24 n->loadkey = &load_date_key;
25 }
26
27 void load_date_key(struct node* n, char* key, char* val) {
28 if(strcmp(key, "tz") == 0)
29 strcpy(((struct config_date*) n->data)->tz, val);
30 else
31 printf("ERROR: Unknown time key %s\n", key);
32 }
33
34 int config_date_load(struct node* n) {
35 char buf[256];
36 time_t timep;
37 struct tm* info;
38
39 setenv("TZ", ((struct config_date*)n->data)->tz, 1);
40 time(&timep);
41 info = localtime(&timep);
42
43 strftime(buf, 256, "%F", info);
44 strcpy(n->label, buf);
45 strcpy(n->color, C_LGREY);
46 return 0;
47 }
|