Add bar height option (Airblader/i3)

This commit is contained in:
Mikkel Oscar Lyderik 2015-12-15 14:05:42 +01:00
parent b76acbaf4f
commit 6834a33290
4 changed files with 22 additions and 3 deletions

View File

@ -92,7 +92,7 @@ struct bar_config {
list_t *bindings;
char *status_command;
char *font;
int bar_height;
int height; // -1 not defined
int tray_padding;
bool workspace_buttons;
bool strip_workspace_numbers;

View File

@ -69,6 +69,7 @@ static sway_cmd bar_cmd_bindsym;
static sway_cmd bar_cmd_colors;
static sway_cmd bar_cmd_mode;
static sway_cmd bar_cmd_modifier;
static sway_cmd bar_cmd_height;
static sway_cmd bar_cmd_hidden_state;
static sway_cmd bar_cmd_id;
static sway_cmd bar_cmd_position;
@ -1592,6 +1593,23 @@ static struct cmd_results *bar_cmd_colors(int argc, char **argv) {
return cmd_results_new(CMD_BLOCK_BAR_COLORS, NULL, NULL);
}
static struct cmd_results *bar_cmd_height(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "height", EXPECTED_EQUAL_TO, 1))) {
return error;
}
int height = atoi(argv[0]);
if (height < 0) {
return cmd_results_new(CMD_INVALID, "height",
"Invalid height value: %s", argv[0]);
}
config->current_bar->height = height;
sway_log(L_DEBUG, "Setting bar height to %d on bar: %s", height, config->current_bar->id);
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}
static struct cmd_results *bar_cmd_hidden_state(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "hidden_state", EXPECTED_EQUAL_TO, 1))) {
@ -1831,6 +1849,7 @@ static struct cmd_handler bar_handlers[] = {
{ "bindsym", bar_cmd_bindsym },
{ "colors", bar_cmd_colors },
{ "font", NULL },
{ "height", bar_cmd_height },
{ "hidden_state", bar_cmd_hidden_state },
{ "id", bar_cmd_id },
{ "mode", bar_cmd_mode },

View File

@ -562,7 +562,7 @@ struct bar_config *default_bar_config(void) {
bar->bindings = create_list();
bar->status_command = strdup("while :; do date +'%Y-%m-%d %l:%M:%S %p' && sleep 1; done");
bar->font = strdup("monospace 10");
bar->bar_height = -1;
bar->height = -1;
bar->workspace_buttons = true;
bar->strip_workspace_numbers = false;
bar->binding_mode_indicator = true;

View File

@ -419,7 +419,7 @@ void ipc_client_handle_command(struct ipc_client *client) {
}
json_object_object_add(json, "status_command", json_object_new_string(bar->status_command));
json_object_object_add(json, "font", json_object_new_string(bar->font));
json_object_object_add(json, "bar_height", json_object_new_int(bar->bar_height));
json_object_object_add(json, "bar_height", json_object_new_int(bar->height));
json_object_object_add(json, "workspace_buttons", json_object_new_boolean(bar->workspace_buttons));
json_object_object_add(json, "strip_workspace_numbers", json_object_new_boolean(bar->strip_workspace_numbers));
json_object_object_add(json, "binding_mode_indicator", json_object_new_boolean(bar->binding_mode_indicator));