} i3bar_child;
/*
- * Start a child-process with the specified command and reroute stdin.
+ * Start a child process with the specified command and reroute stdin.
* We actually start a $SHELL to execute the command so we don't have to care
* about arguments and such
*
void start_child(char *command);
/*
- * kill()s the child-process (if any). Called when exit()ing.
+ * kill()s the child process (if any). Called when exit()ing.
*
*/
void kill_child_at_exit(void);
/*
- * kill()s the child-process (if any) and closes and
- * free()s the stdin- and sigchild-watchers
+ * kill()s the child process (if any) and closes and
+ * free()s the stdin- and SIGCHLD-watchers
*
*/
void kill_child(void);
/*
- * Sends a SIGSTOP to the child-process (if existent)
+ * Sends a SIGSTOP to the child process (if existent)
*
*/
void stop_child(void);
/*
- * Sends a SIGCONT to the child-process (if existent)
+ * Sends a SIGCONT to the child process (if existent)
*
*/
void cont_child(void);
config_t config;
/**
- * Start parsing the received bar configuration json-string
+ * Start parsing the received bar configuration JSON string
*
*/
void parse_config_json(char *json);
/*
* Initiate a connection to i3.
- * socket-path must be a valid path to the ipc_socket of i3
+ * socket_path must be a valid path to the ipc_socket of i3
*
*/
int init_connection(const char *socket_path);
* i3bar - an xcb-based status- and ws-bar for i3
* © 2010-2012 Axel Wagner and contributors (see also: LICENSE)
*
- * mode.c: Handle mode-event and show current binding mode in the bar
+ * mode.c: Handle "mode" event and show current binding mode in the bar
*
*/
#pragma once
typedef struct mode mode;
/*
- * Start parsing the received json-string
+ * Start parsing the received JSON string
*
*/
void parse_mode_json(char *json);
* i3bar - an xcb-based status- and ws-bar for i3
* © 2010-2012 Axel Wagner and contributors (see also: LICENSE)
*
- * outputs.c: Maintaining the output-list
+ * outputs.c: Maintaining the outputs list
*
*/
#pragma once
struct outputs_head* outputs;
/*
- * Start parsing the received json-string
+ * Start parsing the received JSON string
*
*/
void parse_outputs_json(char* json);
/*
- * Initiate the output-list
+ * Initiate the outputs list
*
*/
void init_outputs(void);
bool primary; /* If it is the primary output */
bool visible; /* If the bar is visible on this output */
int ws; /* The number of the currently visible ws */
- rect rect; /* The rect (relative to the root-win) */
+ rect rect; /* The rect (relative to the root window) */
xcb_window_t bar; /* The id of the bar of the output */
xcb_pixmap_t buffer; /* An extra pixmap for double-buffering */
#if defined(DLOG)
#undef DLOG
#endif
-/* Use cool logging-macros */
+/* Use cool logging macros */
#define DLOG(fmt, ...) \
do { \
if (config.verbose) { \
* i3bar - an xcb-based status- and ws-bar for i3
* © 2010-2012 Axel Wagner and contributors (see also: LICENSE)
*
- * workspaces.c: Maintaining the workspace-lists
+ * workspaces.c: Maintaining the workspace lists
*
*/
#pragma once
TAILQ_HEAD(ws_head, i3_ws);
/*
- * Start parsing the received json-string
+ * Start parsing the received JSON string
*
*/
void parse_workspaces_json(char *json);
/*
- * free() all workspace data-structures
+ * free() all workspace data structures
*
*/
void free_workspaces(void);
int name_width; /* The rendered width of the name */
bool visible; /* If the ws is currently visible on an output */
bool focused; /* If the ws is currently focused */
- bool urgent; /* If the urgent-hint of the ws is set */
+ bool urgent; /* If the urgent hint of the ws is set */
rect rect; /* The rect of the ws (not used (yet)) */
struct i3_output *output; /* The current output of the ws */
void init_colors(const struct xcb_color_strings_t *colors);
/*
- * Cleanup the xcb-stuff.
+ * Cleanup the xcb stuff.
* Called once, before the program terminates.
*
*/
void clean_xcb(void);
/*
- * Get the earlier requested atoms and save them in the prepared data-structure
+ * Get the earlier requested atoms and save them in the prepared data structure
*
*/
void get_atoms(void);
void destroy_window(i3_output *output);
/*
- * Reallocate the statusline-buffer
+ * Reallocate the statusline buffer
*
*/
void realloc_sl_buffer(void);
/* Global variables for child_*() */
i3bar_child child;
-/* stdin- and sigchild-watchers */
+/* stdin- and SIGCHLD-watchers */
ev_io *stdin_io;
ev_child *child_sig;
}
/*
- * Stop and free() the stdin- and sigchild-watchers
+ * Stop and free() the stdin- and SIGCHLD-watchers
*
*/
void cleanup(void) {
}
/*
- * We received a sigchild, meaning, that the child-process terminated.
- * We simply free the respective data-structures and don't care for input
+ * We received a SIGCHLD, meaning, that the child process terminated.
+ * We simply free the respective data structures and don't care for input
* anymore
*
*/
}
/*
- * Start a child-process with the specified command and reroute stdin.
+ * Start a child process with the specified command and reroute stdin.
* We actually start a $SHELL to execute the command so we don't have to care
* about arguments and such.
*
}
/*
- * kill()s the child-process (if any). Called when exit()ing.
+ * kill()s the child process (if any). Called when exit()ing.
*
*/
void kill_child_at_exit(void) {
}
/*
- * kill()s the child-process (if existent) and closes and
- * free()s the stdin- and sigchild-watchers
+ * kill()s the child process (if existent) and closes and
+ * free()s the stdin- and SIGCHLD-watchers
*
*/
void kill_child(void) {
}
/*
- * Sends a SIGSTOP to the child-process (if existent)
+ * Sends a SIGSTOP to the child process (if existent)
*
*/
void stop_child(void) {
}
/*
- * Sends a SIGCONT to the child-process (if existent)
+ * Sends a SIGCONT to the child process (if existent)
*
*/
void cont_child(void) {
}
/*
- * Parse a null-value (current_workspace)
+ * Parse a null value (current_workspace)
*
*/
static int config_null_cb(void *params_) {
};
/*
- * Start parsing the received bar configuration json-string
+ * Start parsing the received bar configuration JSON string
*
*/
void parse_config_json(char *json) {
break;
case yajl_status_client_canceled:
case yajl_status_error:
- ELOG("Could not parse config-reply!\n");
+ ELOG("Could not parse config reply!\n");
exit(EXIT_FAILURE);
break;
}
*
*/
void got_command_reply(char *reply) {
- /* TODO: Error handling for command-replies */
+ /* TODO: Error handling for command replies */
}
/*
- * Called, when we get a reply with workspaces-data
+ * Called, when we get a reply with workspaces data
*
*/
void got_workspace_reply(char *reply) {
*/
void got_subscribe_reply(char *reply) {
DLOG("Got Subscribe Reply: %s\n", reply);
- /* TODO: Error handling for subscribe-commands */
+ /* TODO: Error handling for subscribe commands */
}
/*
- * Called, when we get a reply with outputs-data
+ * Called, when we get a reply with outputs data
*
*/
void got_output_reply(char *reply) {
*/
void got_bar_config(char *reply) {
DLOG("Received bar config \"%s\"\n", reply);
- /* We initiate the main-function by requesting infos about the outputs and
+ /* We initiate the main function by requesting infos about the outputs and
* workspaces. Everything else (creating the bars, showing the right workspace-
* buttons and more) is taken care of by the event-drivenness of the code */
i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_OUTPUTS, NULL);
FREE(config.command);
}
-/* Data-structure to easily call the reply-handlers later */
+/* Data-structure to easily call the reply handlers later */
handler_t reply_handlers[] = {
&got_command_reply,
&got_workspace_reply,
};
/*
- * Called, when a workspace-event arrives (i.e. the user changed the workspace)
+ * Called, when a workspace event arrives (i.e. the user changed the workspace)
*
*/
void got_workspace_event(char *event) {
}
/*
- * Called, when an output-event arrives (i.e. the screen-configuration changed)
+ * Called, when an output event arrives (i.e. the screen-configuration changed)
*
*/
void got_output_event(char *event) {
}
/*
- * Called, when a mode-event arrives (i3 changed binding mode).
+ * Called, when a mode event arrives (i3 changed binding mode).
*
*/
void got_mode_event(char *event) {
draw_bars(false);
}
-/* Data-structure to easily call the event-handlers later */
+/* Data-structure to easily call the event handlers later */
handler_t event_handlers[] = {
&got_workspace_event,
&got_output_event,
/*
* Initiate a connection to i3.
- * socket-path must be a valid path to the ipc_socket of i3
+ * socket_path must be a valid path to the ipc_socket of i3
*
*/
int init_connection(const char *socket_path) {
printf("\n");
printf("-b, --bar_id <bar_id>\tBar ID for which to get the configuration\n");
printf("-s, --socket <sock_path>\tConnect to i3 via <sock_path>\n");
- printf("-h, --help Display this help-message and exit\n");
+ printf("-h, --help Display this help message and exit\n");
printf("-v, --version Display version number and exit\n");
printf("\n");
printf(" PLEASE NOTE that i3bar will be automatically started by i3\n"
/*
* We watch various signals, that are there to make our application stop.
- * If we get one of those, we ev_unloop() and invoke the cleanup-routines
+ * If we get one of those, we ev_unloop() and invoke the cleanup routines
* in main() with that
*
*/
i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_BAR_CONFIG, config.bar_id);
}
- /* We listen to SIGTERM/QUIT/INT and try to exit cleanly, by stopping the main-loop.
+ /* 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
* some calls to free() */
ev_signal *sig_term = smalloc(sizeof(ev_signal));
ev_signal_start(main_loop, sig_hup);
/* From here on everything should run smooth for itself, just start listening for
- * events. We stop simply stop the event-loop, when we are finished */
+ * events. We stop simply stop the event loop, when we are finished */
ev_loop(main_loop, 0);
kill_child();
* i3bar - an xcb-based status- and ws-bar for i3
* © 2010-2012 Axel Wagner and contributors (see also: LICENSE)
*
- * mode.c: Handle mode-event and show current binding mode in the bar
+ * mode.c: Handle mode event and show current binding mode in the bar
*
*/
#include <string.h>
/*
* Parse a key.
*
- * Essentially we just save it in the parsing-state
+ * Essentially we just save it in the parsing state
*
*/
static int mode_map_key_cb(void *params_, const unsigned char *keyVal, size_t keyLen) {
};
/*
- * Start parsing the received json-string
+ * Start parsing the received JSON string
*
*/
void parse_mode_json(char *json) {
- /* FIXME: Fasciliate stream-processing, i.e. allow starting to interpret
+ /* FIXME: Fasciliate stream processing, i.e. allow starting to interpret
* JSON in chunks */
struct mode_json_params params;
break;
case yajl_status_client_canceled:
case yajl_status_error:
- ELOG("Could not parse mode-event!\n");
+ ELOG("Could not parse mode event!\n");
exit(EXIT_FAILURE);
break;
}
* i3bar - an xcb-based status- and ws-bar for i3
* © 2010-2012 Axel Wagner and contributors (see also: LICENSE)
*
- * outputs.c: Maintaining the output-list
+ * outputs.c: Maintaining the outputs list
*
*/
#include <string.h>
};
/*
- * Parse a null-value (current_workspace)
+ * Parse a null value (current_workspace)
*
*/
static int outputs_null_cb(void *params_) {
}
/*
- * We hit the start of a json-map (rect or a new output)
+ * We hit the start of a JSON map (rect or a new output)
*
*/
static int outputs_start_map_cb(void *params_) {
/*
* Parse a key.
*
- * Essentially we just save it in the parsing-state
+ * Essentially we just save it in the parsing state
*
*/
static int outputs_map_key_cb(void *params_, const unsigned char *keyVal, size_t keyLen) {
};
/*
- * Initiate the output-list
+ * Initiate the outputs list
*
*/
void init_outputs(void) {
}
/*
- * Start parsing the received json-string
+ * Start parsing the received JSON string
*
*/
void parse_outputs_json(char *json) {
break;
case yajl_status_client_canceled:
case yajl_status_error:
- ELOG("Could not parse outputs-reply!\n");
+ ELOG("Could not parse outputs reply!\n");
exit(EXIT_FAILURE);
break;
}
* i3bar - an xcb-based status- and ws-bar for i3
* © 2010-2012 Axel Wagner and contributors (see also: LICENSE)
*
- * workspaces.c: Maintaining the workspace-lists
+ * workspaces.c: Maintaining the workspace lists
*
*/
#include <string.h>
}
/*
- * We hit the start of a json-map (rect or a new output)
+ * We hit the start of a JSON map (rect or a new output)
*
*/
static int workspaces_start_map_cb(void *params_) {
/*
* Parse a key.
*
- * Essentially we just save it in the parsing-state
+ * Essentially we just save it in the parsing state
*
*/
static int workspaces_map_key_cb(void *params_, const unsigned char *keyVal, size_t keyLen) {
};
/*
- * Start parsing the received json-string
+ * Start parsing the received JSON string
*
*/
void parse_workspaces_json(char *json) {
- /* FIXME: Fasciliate stream-processing, i.e. allow starting to interpret
+ /* FIXME: Fasciliate stream processing, i.e. allow starting to interpret
* JSON in chunks */
struct workspaces_json_params params;
}
/*
- * free() all workspace data-structures. Does not free() the heads of the tailqueues.
+ * free() all workspace data structures. Does not free() the heads of the tailqueues.
*
*/
void free_workspaces(void) {
/* Vertical offset between the bar and a separator */
const static int sep_voff_px = 4;
-/* We define xcb_request_failed as a macro to include the relevant line-number */
+/* We define xcb_request_failed as a macro to include the relevant line number */
#define xcb_request_failed(cookie, err_msg) _xcb_request_failed(cookie, err_msg, __LINE__)
int _xcb_request_failed(xcb_void_cookie_t cookie, char *err_msg, int line) {
xcb_generic_error_t *err;
}
/*
- * Handle a button-press-event (i.e. a mouse click on one of our bars).
- * We determine, whether the click occured on a ws-button or if the scroll-
+ * Handle a button press event (i.e. a mouse click on one of our bars).
+ * We determine, whether the click occured on a workspace button or if the scroll-
* wheel was used and change the workspace appropriately
*
*/
/*
* Handle visibility notifications: when none of the bars are visible, e.g.
- * if windows are in full-screen on each output, suspend the child process.
+ * if windows are in fullscreen on each output, suspend the child process.
*
*/
static void handle_visibility_notify(xcb_visibility_notify_event_t *event) {
DLOG("xembed version = %d\n", xembed[0]);
DLOG("xembed flags = %d\n", xembed[1]);
bool map_it = ((xembed[1] & XEMBED_MAPPED) == XEMBED_MAPPED);
- DLOG("map-state now %d\n", map_it);
+ DLOG("map state now %d\n", map_it);
if (trayclient->mapped && !map_it) {
/* need to unmap the window */
xcb_unmap_window(xcb_connection, trayclient->win);
redraw_bars();
break;
case XCB_BUTTON_PRESS:
- /* Button-press-events are mouse-buttons clicked on one of our bars */
+ /* Button press events are mouse-buttons clicked on one of our bars */
handle_button((xcb_button_press_event_t *)event);
break;
case XCB_CLIENT_MESSAGE:
char *path = root_atom_contents("I3_SOCKET_PATH", xcb_connection, screen);
- if (xcb_request_failed(sl_pm_cookie, "Could not allocate statusline-buffer") ||
- xcb_request_failed(clear_ctx_cookie, "Could not allocate statusline-buffer-clearcontext") ||
- xcb_request_failed(sl_ctx_cookie, "Could not allocate statusline-buffer-context")) {
+ if (xcb_request_failed(sl_pm_cookie, "Could not allocate statusline buffer") ||
+ xcb_request_failed(clear_ctx_cookie, "Could not allocate statusline buffer clearcontext") ||
+ xcb_request_failed(sl_ctx_cookie, "Could not allocate statusline buffer context")) {
exit(EXIT_FAILURE);
}
}
/*
- * Register for xkb keyevents. To grab modifiers without blocking other applications from receiving key-events
+ * Register for xkb keyevents. To grab modifiers without blocking other applications from receiving key events
* involving that modifier, we sadly have to use xkb which is not yet fully supported
* in xcb.
*
}
/*
- * Cleanup the xcb-stuff.
+ * Cleanup the xcb stuff.
* Called once, before the program terminates.
*
*/
}
/*
- * Reallocate the statusline-buffer
+ * Reallocate the statusline buffer
*
*/
void realloc_sl_buffer(void) {
- DLOG("Re-allocating statusline-buffer, statusline_width = %d, root_screen->width_in_pixels = %d\n",
+ DLOG("Re-allocating statusline buffer, statusline_width = %d, root_screen->width_in_pixels = %d\n",
statusline_width, root_screen->width_in_pixels);
xcb_free_pixmap(xcb_connection, statusline_pm);
statusline_pm = xcb_generate_id(xcb_connection);
mask,
vals);
- if (xcb_request_failed(sl_pm_cookie, "Could not allocate statusline-buffer") ||
- xcb_request_failed(clear_ctx_cookie, "Could not allocate statusline-buffer-clearcontext") ||
- xcb_request_failed(sl_ctx_cookie, "Could not allocate statusline-buffer-context")) {
+ if (xcb_request_failed(sl_pm_cookie, "Could not allocate statusline buffer") ||
+ xcb_request_failed(clear_ctx_cookie, "Could not allocate statusline buffer clearcontext") ||
+ xcb_request_failed(sl_ctx_cookie, "Could not allocate statusline buffer context")) {
exit(EXIT_FAILURE);
}
}
mask = XCB_CW_BACK_PIXEL | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK;
/* Black background */
values[0] = colors.bar_bg;
- /* If hide_on_modifier is set to hide or invisible mode, i3 is not supposed to manage our bar-windows */
+ /* If hide_on_modifier is set to hide or invisible mode, i3 is not supposed to manage our bar windows */
values[1] = (config.hide_on_modifier == M_DOCK ? 0 : 1);
/* We enable the following EventMask fields:
* EXPOSURE, to get expose events (we have to re-draw then)
name);
free(name);
- /* We want dock-windows (for now). When override_redirect is set, i3 is ignoring
+ /* We want dock windows (for now). When override_redirect is set, i3 is ignoring
* this one */
xcb_void_cookie_t dock_cookie = xcb_change_property(xcb_connection,
XCB_PROP_MODE_REPLACE,
12,
&strut_partial);
- /* We also want a graphics-context for the bars (it defines the properties
+ /* We also want a graphics context for the bars (it defines the properties
* with which we draw to them) */
walk->bargc = xcb_generate_id(xcb_connection);
xcb_void_cookie_t gc_cookie = xcb_create_gc_checked(xcb_connection,