/** * I3cstat prints a configurable status bar for the i3 window manager * Copyright (C) 2022 Aaron Ball * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include #include #include "common.h" #include "config.h" #define xstr(s) str(s) #define str(s) #s int main(int argc, char* argv[]) { char confpath[256]; int sleeptime = 500 * 1000; // 500 ms struct node* list = NULL; struct node* cur = NULL; // Required for unicode symbols to work setlocale(LC_ALL, ""); // Build the config path sprintf(confpath, "%s/.config/i3cstat.conf", getenv("HOME")); list = config_load(confpath); if(!list) { printf("Error: Could load config file from %s\n", confpath); return 2; } cur = list; printf("{ \"version\": 1 }\n"); printf("[\n[],\n"); while(1) { printf("[\n"); while(cur) { if(time(NULL) - cur->lastrun >= cur->interval) { cur->loadfunc(cur); cur->lastrun = time(NULL); } node_print(cur); cur = cur->next; } cur = list; printf("],\n"); usleep(sleeptime); } config_free(cur); return 0; }