Add bar config struct and defaults

This commit is contained in:
Drew DeVault 2015-11-29 17:02:09 -05:00
parent 3f950b6e52
commit 4f89735fc4
3 changed files with 56 additions and 1 deletions

View File

@ -16,6 +16,8 @@ enum cmd_status {
// Config Blocks
CMD_BLOCK_END,
CMD_BLOCK_MODE,
CMD_BLOCK_BAR,
CMD_BLOCK_BAR_COLORS
};
/**

View File

@ -4,6 +4,7 @@
#include <stdint.h>
#include <wlc/wlc.h>
#include <xkbcommon/xkbcommon.h>
#include "wayland-desktop-shell-server-protocol.h"
#include "list.h"
#include "layout.h"
#include "container.h"
@ -57,6 +58,44 @@ struct workspace_output {
char *workspace;
};
struct bar_config {
/**
* One of "dock", "hide", "invisible"
*
* Always visible in dock mode. Visible only when modifier key is held in hide mode.
* Never visible in invisible mode.
*/
char *mode;
/**
* One of "show" or "hide".
*
* In "show" mode, it will always be shown on top of the active workspace.
*/
char *hidden_state;
uint32_t modifier;
enum desktop_shell_panel_position position;
char *status_command;
char *font;
int bar_height;
bool workspace_buttons;
bool strip_workspace_numbers;
bool binding_mode_indicator;
bool verbose;
struct {
char *background;
char *foreground;
char *focused_workspace_border;
char *focused_workspace_bg;
char *focused_workspace_text;
char *active_workspace_border;
char *active_workspace_bg;
char *active_workspace_text;
char *inactive_workspace_border;
char *inactive_workspace_bg;
char *inactive_workspace_text;
} colors;
};
/**
* The configuration struct. The result of loading a config file.
*/
@ -68,6 +107,7 @@ struct sway_config {
list_t *output_configs;
list_t *criteria;
struct sway_mode *current_mode;
struct bar_config bar;
uint32_t floating_mod;
enum swayc_layouts default_orientation;
enum swayc_layouts default_layout;

View File

@ -3,6 +3,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <wordexp.h>
#include "wayland-desktop-shell-server-protocol.h"
#include "readline.h"
#include "stringop.h"
#include "list.h"
@ -115,6 +116,18 @@ static void config_defaults(struct sway_config *config) {
config->edge_gaps = true;
config->gaps_inner = 0;
config->gaps_outer = 0;
// Bar
config->bar.mode = "dock";
config->bar.hidden_state = "hide";
config->bar.modifier = 0;
config->bar.position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM;
config->bar.status_command = "while :; do date +'%Y-%m-%d %l:%M:%S %p' && sleep 1; done";
config->bar.font = "monospace 10";
config->bar.bar_height = -1;
config->bar.workspace_buttons = true;
config->bar.strip_workspace_numbers = false;
config->bar.binding_mode_indicator = true;
}
static char *get_config_path(void) {
@ -190,7 +203,7 @@ bool load_config(const char *file) {
bool read_config(FILE *file, bool is_active) {
struct sway_config *old_config = config;
config = malloc(sizeof(struct sway_config));
config = calloc(1, sizeof(struct sway_config));
config_defaults(config);
config->reading = true;