blob: e7c3866d679ff30343abb0d6aeb1c88d8f7e02cb (
plain)
1 /**
2 * I3cstatus prints a configurable status bar for the i3 window manager
3 * Copyright (C) 2020 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_time.h"
19
20 void config_time_init(struct node* n) {
21 n->data = malloc(sizeof(struct config_time));
22 n->type = CTYPE_TIME;
23 n->loadfunc = &config_time_load;
24 n->loadkey = &load_time_key;
25 }
26
27
28 void load_time_key(struct node* n, char* key, char* val) {
29 if(strcmp(key, "tz") == 0)
30 strcpy(((struct config_time*) n->data)->tz, val);
31 else
32 printf("ERROR: Unknown time key %s\n", key);
33 }
34
35
36 int config_time_load(struct node* n) {
37 time_t timep;
38 struct tm* info;
39
40 setenv("TZ", ((struct config_time*)n->data)->tz, 1);
41 time(&timep);
42 info = localtime(&timep);
43
44 strftime(n->text, 256, "%T", info);
45
46 strcpy(n->color, C_DGREY);
47 strcpy(n->label_color, C_LGREY);
48
49 return 0;
50 }
|