X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=i3bar%2Fsrc%2Fmain.c;h=a818dd9710eda58c3647a029f612ff5e0bf6146b;hb=64e7646c7ee3cec9803597c5fde5d5a907881249;hp=32425319ed3c5afc59a9516d1f434a208ad59fbf;hpb=b1974a469f2dec2af753ea4735f1b1c5d37161da;p=i3%2Fi3 diff --git a/i3bar/src/main.c b/i3bar/src/main.c index 32425319..a818dd97 100644 --- a/i3bar/src/main.c +++ b/i3bar/src/main.c @@ -5,6 +5,8 @@ * © 2010 Axel Wagner and contributors (see also: LICENSE) * */ +#include "common.h" + #include #include #include @@ -15,8 +17,6 @@ #include #include -#include "common.h" - /* * Having verboselog(), errorlog() and debuglog() is necessary when using libi3. * @@ -44,7 +44,7 @@ void debuglog(char *fmt, ...) { * Glob path, i.e. expand ~ * */ -char *expand_path(char *path) { +static char *expand_path(char *path) { static glob_t globbuf; if (glob(path, GLOB_NOCHECK | GLOB_TILDE, NULL, &globbuf) < 0) { ELOG("glob() failed\n"); @@ -55,13 +55,14 @@ char *expand_path(char *path) { return result; } -void print_usage(char *elf_name) { +static void print_usage(char *elf_name) { printf("Usage: %s -b bar_id [-s sock_path] [-h] [-v]\n", elf_name); printf("\n"); printf("-b, --bar_id \tBar ID for which to get the configuration\n"); printf("-s, --socket \tConnect to i3 via \n"); printf("-h, --help Display this help message and exit\n"); printf("-v, --version Display version number and exit\n"); + printf("-V, --verbose Enable verbose mode\n"); printf("\n"); printf(" PLEASE NOTE that i3bar will be automatically started by i3\n" " as soon as there is a 'bar' configuration block in your\n" @@ -75,7 +76,7 @@ void print_usage(char *elf_name) { * in main() with that * */ -void sig_cb(struct ev_loop *loop, ev_signal *watcher, int revents) { +static void sig_cb(struct ev_loop *loop, ev_signal *watcher, int revents) { switch (watcher->signum) { case SIGTERM: DLOG("Got a SIGTERM, stopping\n"); @@ -93,6 +94,9 @@ int main(int argc, char **argv) { int opt; int option_index = 0; char *socket_path = getenv("I3SOCK"); + if (socket_path != NULL) { + socket_path = sstrdup(socket_path); + } char *i3_default_sock_path = "/tmp/i3-ipc.sock"; /* Initialize the standard config to use 0 as default */ @@ -103,9 +107,10 @@ int main(int argc, char **argv) { {"bar_id", required_argument, 0, 'b'}, {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'v'}, + {"verbose", no_argument, 0, 'V'}, {NULL, 0, 0, 0}}; - while ((opt = getopt_long(argc, argv, "b:s:hv", long_opt, &option_index)) != -1) { + while ((opt = getopt_long(argc, argv, "b:s:hvV", long_opt, &option_index)) != -1) { switch (opt) { case 's': socket_path = expand_path(optarg); @@ -117,6 +122,9 @@ int main(int argc, char **argv) { case 'b': config.bar_id = sstrdup(optarg); break; + case 'V': + config.verbose = true; + break; default: print_usage(argv[0]); exit(EXIT_SUCCESS); @@ -137,6 +145,8 @@ int main(int argc, char **argv) { if (socket_path == NULL) { socket_path = atom_sock_path; + } else { + free(atom_sock_path); } if (socket_path == NULL) { @@ -144,11 +154,14 @@ int main(int argc, char **argv) { socket_path = expand_path(i3_default_sock_path); } + init_dpi(); + init_outputs(); if (init_connection(socket_path)) { /* Request the bar configuration. When it arrives, we fill the config array. */ i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_BAR_CONFIG, config.bar_id); } + free(socket_path); /* We listen to SIGTERM/QUIT/INT and try to exit cleanly, by stopping the main loop. * We only need those watchers on the stack, so putting them on the stack saves us @@ -174,7 +187,5 @@ int main(int argc, char **argv) { clean_xcb(); ev_default_destroy(); - free_workspaces(); - return 0; }