diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-11-29 17:02:09 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-11-29 17:05:04 -0500 |
commit | 4f89735fc4d33cb19d97fba253708da8dfe14210 (patch) | |
tree | 799754ced938aec650f0a1bc488be58d0c890918 | |
parent | Merge pull request #278 from christophgysin/merge (diff) | |
download | sway-4f89735fc4d33cb19d97fba253708da8dfe14210.tar.gz sway-4f89735fc4d33cb19d97fba253708da8dfe14210.tar.zst sway-4f89735fc4d33cb19d97fba253708da8dfe14210.zip |
Add bar config struct and defaults
-rw-r--r-- | include/commands.h | 2 | ||||
-rw-r--r-- | include/config.h | 40 | ||||
-rw-r--r-- | sway/config.c | 15 |
3 files changed, 56 insertions, 1 deletions
diff --git a/include/commands.h b/include/commands.h index 9135c670..f291e7cb 100644 --- a/include/commands.h +++ b/include/commands.h | |||
@@ -16,6 +16,8 @@ enum cmd_status { | |||
16 | // Config Blocks | 16 | // Config Blocks |
17 | CMD_BLOCK_END, | 17 | CMD_BLOCK_END, |
18 | CMD_BLOCK_MODE, | 18 | CMD_BLOCK_MODE, |
19 | CMD_BLOCK_BAR, | ||
20 | CMD_BLOCK_BAR_COLORS | ||
19 | }; | 21 | }; |
20 | 22 | ||
21 | /** | 23 | /** |
diff --git a/include/config.h b/include/config.h index b9ef340b..81d4cd20 100644 --- a/include/config.h +++ b/include/config.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <stdint.h> | 4 | #include <stdint.h> |
5 | #include <wlc/wlc.h> | 5 | #include <wlc/wlc.h> |
6 | #include <xkbcommon/xkbcommon.h> | 6 | #include <xkbcommon/xkbcommon.h> |
7 | #include "wayland-desktop-shell-server-protocol.h" | ||
7 | #include "list.h" | 8 | #include "list.h" |
8 | #include "layout.h" | 9 | #include "layout.h" |
9 | #include "container.h" | 10 | #include "container.h" |
@@ -57,6 +58,44 @@ struct workspace_output { | |||
57 | char *workspace; | 58 | char *workspace; |
58 | }; | 59 | }; |
59 | 60 | ||
61 | struct bar_config { | ||
62 | /** | ||
63 | * One of "dock", "hide", "invisible" | ||
64 | * | ||
65 | * Always visible in dock mode. Visible only when modifier key is held in hide mode. | ||
66 | * Never visible in invisible mode. | ||
67 | */ | ||
68 | char *mode; | ||
69 | /** | ||
70 | * One of "show" or "hide". | ||
71 | * | ||
72 | * In "show" mode, it will always be shown on top of the active workspace. | ||
73 | */ | ||
74 | char *hidden_state; | ||
75 | uint32_t modifier; | ||
76 | enum desktop_shell_panel_position position; | ||
77 | char *status_command; | ||
78 | char *font; | ||
79 | int bar_height; | ||
80 | bool workspace_buttons; | ||
81 | bool strip_workspace_numbers; | ||
82 | bool binding_mode_indicator; | ||
83 | bool verbose; | ||
84 | struct { | ||
85 | char *background; | ||
86 | char *foreground; | ||
87 | char *focused_workspace_border; | ||
88 | char *focused_workspace_bg; | ||
89 | char *focused_workspace_text; | ||
90 | char *active_workspace_border; | ||
91 | char *active_workspace_bg; | ||
92 | char *active_workspace_text; | ||
93 | char *inactive_workspace_border; | ||
94 | char *inactive_workspace_bg; | ||
95 | char *inactive_workspace_text; | ||
96 | } colors; | ||
97 | }; | ||
98 | |||
60 | /** | 99 | /** |
61 | * The configuration struct. The result of loading a config file. | 100 | * The configuration struct. The result of loading a config file. |
62 | */ | 101 | */ |
@@ -68,6 +107,7 @@ struct sway_config { | |||
68 | list_t *output_configs; | 107 | list_t *output_configs; |
69 | list_t *criteria; | 108 | list_t *criteria; |
70 | struct sway_mode *current_mode; | 109 | struct sway_mode *current_mode; |
110 | struct bar_config bar; | ||
71 | uint32_t floating_mod; | 111 | uint32_t floating_mod; |
72 | enum swayc_layouts default_orientation; | 112 | enum swayc_layouts default_orientation; |
73 | enum swayc_layouts default_layout; | 113 | enum swayc_layouts default_layout; |
diff --git a/sway/config.c b/sway/config.c index aa4675ce..59e6e476 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <unistd.h> | 4 | #include <unistd.h> |
5 | #include <wordexp.h> | 5 | #include <wordexp.h> |
6 | #include "wayland-desktop-shell-server-protocol.h" | ||
6 | #include "readline.h" | 7 | #include "readline.h" |
7 | #include "stringop.h" | 8 | #include "stringop.h" |
8 | #include "list.h" | 9 | #include "list.h" |
@@ -115,6 +116,18 @@ static void config_defaults(struct sway_config *config) { | |||
115 | config->edge_gaps = true; | 116 | config->edge_gaps = true; |
116 | config->gaps_inner = 0; | 117 | config->gaps_inner = 0; |
117 | config->gaps_outer = 0; | 118 | config->gaps_outer = 0; |
119 | |||
120 | // Bar | ||
121 | config->bar.mode = "dock"; | ||
122 | config->bar.hidden_state = "hide"; | ||
123 | config->bar.modifier = 0; | ||
124 | config->bar.position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM; | ||
125 | config->bar.status_command = "while :; do date +'%Y-%m-%d %l:%M:%S %p' && sleep 1; done"; | ||
126 | config->bar.font = "monospace 10"; | ||
127 | config->bar.bar_height = -1; | ||
128 | config->bar.workspace_buttons = true; | ||
129 | config->bar.strip_workspace_numbers = false; | ||
130 | config->bar.binding_mode_indicator = true; | ||
118 | } | 131 | } |
119 | 132 | ||
120 | static char *get_config_path(void) { | 133 | static char *get_config_path(void) { |
@@ -190,7 +203,7 @@ bool load_config(const char *file) { | |||
190 | 203 | ||
191 | bool read_config(FILE *file, bool is_active) { | 204 | bool read_config(FILE *file, bool is_active) { |
192 | struct sway_config *old_config = config; | 205 | struct sway_config *old_config = config; |
193 | config = malloc(sizeof(struct sway_config)); | 206 | config = calloc(1, sizeof(struct sway_config)); |
194 | 207 | ||
195 | config_defaults(config); | 208 | config_defaults(config); |
196 | config->reading = true; | 209 | config->reading = true; |