mirror of
https://github.com/swaywm/sway.git
synced 2026-04-25 06:46:24 -04:00
Add configuration option to disable window title
Signed-off-by: Felix Weilbach <felix.weilbach@t-online.de>
This commit is contained in:
parent
3d158264e2
commit
13835cf767
10 changed files with 62 additions and 16 deletions
|
|
@ -228,6 +228,7 @@ sway_cmd bar_cmd_unbindcode;
|
|||
sway_cmd bar_cmd_unbindsym;
|
||||
sway_cmd bar_cmd_wrap_scroll;
|
||||
sway_cmd bar_cmd_workspace_buttons;
|
||||
sway_cmd bar_cmd_window_title;
|
||||
sway_cmd bar_cmd_workspace_min_width;
|
||||
|
||||
sway_cmd bar_colors_cmd_active_workspace;
|
||||
|
|
|
|||
|
|
@ -327,6 +327,7 @@ struct bar_config {
|
|||
char *font;
|
||||
int height; // -1 not defined
|
||||
bool workspace_buttons;
|
||||
bool window_title;
|
||||
bool wrap_scroll;
|
||||
char *separator_symbol;
|
||||
bool strip_workspace_numbers;
|
||||
|
|
@ -361,8 +362,8 @@ struct bar_config {
|
|||
char *binding_mode_text;
|
||||
} colors;
|
||||
|
||||
#if HAVE_TRAY
|
||||
char *icon_theme;
|
||||
#if HAVE_TRAY
|
||||
struct wl_list tray_bindings; // struct tray_binding::link
|
||||
list_t *tray_outputs; // char *
|
||||
int tray_padding;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ struct swaybar_config {
|
|||
bool binding_mode_indicator;
|
||||
bool wrap_scroll;
|
||||
bool workspace_buttons;
|
||||
bool window_title;
|
||||
uint32_t workspace_min_width;
|
||||
list_t *bindings;
|
||||
struct wl_list outputs; // config_output::link
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ static const struct cmd_handler bar_handlers[] = {
|
|||
{ "tray_padding", bar_cmd_tray_padding },
|
||||
{ "unbindcode", bar_cmd_unbindcode },
|
||||
{ "unbindsym", bar_cmd_unbindsym },
|
||||
{ "window_title", bar_cmd_window_title },
|
||||
{ "workspace_buttons", bar_cmd_workspace_buttons },
|
||||
{ "workspace_min_width", bar_cmd_workspace_min_width },
|
||||
{ "wrap_scroll", bar_cmd_wrap_scroll },
|
||||
|
|
|
|||
24
sway/commands/bar/window_title.c
Normal file
24
sway/commands/bar/window_title.c
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include "sway/commands.h"
|
||||
#include "log.h"
|
||||
#include "util.h"
|
||||
|
||||
struct cmd_results *bar_cmd_window_title(int argc, char **argv) {
|
||||
struct cmd_results *error = NULL;
|
||||
if ((error = checkarg(argc, "window_title", EXPECTED_EQUAL_TO, 1))) {
|
||||
return error;
|
||||
}
|
||||
config->current_bar->window_title =
|
||||
parse_boolean(argv[0], config->current_bar->window_title);
|
||||
if (config->current_bar->window_title) {
|
||||
sway_log(SWAY_DEBUG,
|
||||
"Enabling window title on bar: %s",
|
||||
config->current_bar->id);
|
||||
} else {
|
||||
sway_log(SWAY_DEBUG,
|
||||
"Disabling window title on bar: %s",
|
||||
config->current_bar->id);
|
||||
}
|
||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||
}
|
||||
|
|
@ -96,6 +96,7 @@ struct bar_config *default_bar_config(void) {
|
|||
bar->font = NULL;
|
||||
bar->height = 0;
|
||||
bar->workspace_buttons = true;
|
||||
bar->window_title = false;
|
||||
bar->wrap_scroll = false;
|
||||
bar->separator_symbol = NULL;
|
||||
bar->strip_workspace_numbers = false;
|
||||
|
|
|
|||
|
|
@ -1104,6 +1104,8 @@ json_object *ipc_json_describe_bar_config(struct bar_config *bar) {
|
|||
json_object_new_boolean(bar->wrap_scroll));
|
||||
json_object_object_add(json, "workspace_buttons",
|
||||
json_object_new_boolean(bar->workspace_buttons));
|
||||
json_object_object_add(json, "window_title",
|
||||
json_object_new_boolean(bar->window_title));
|
||||
json_object_object_add(json, "strip_workspace_numbers",
|
||||
json_object_new_boolean(bar->strip_workspace_numbers));
|
||||
json_object_object_add(json, "strip_workspace_name",
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ sway_sources = files(
|
|||
'commands/bar/tray_output.c',
|
||||
'commands/bar/tray_padding.c',
|
||||
'commands/bar/workspace_buttons.c',
|
||||
'commands/bar/window_title.c',
|
||||
'commands/bar/workspace_min_width.c',
|
||||
'commands/bar/wrap_scroll.c',
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ struct swaybar_config *init_config(void) {
|
|||
config->binding_mode_indicator = true;
|
||||
config->wrap_scroll = false;
|
||||
config->workspace_buttons = true;
|
||||
config->window_title = false;
|
||||
config->workspace_min_width = 0;
|
||||
config->bindings = create_list();
|
||||
wl_list_init(&config->outputs);
|
||||
|
|
|
|||
|
|
@ -274,6 +274,12 @@ static bool ipc_parse_config(
|
|||
config->workspace_buttons = json_object_get_boolean(workspace_buttons);
|
||||
}
|
||||
|
||||
json_object *window_title =
|
||||
json_object_object_get(bar_config, "window_title");
|
||||
if (window_title) {
|
||||
config->window_title = json_object_get_boolean(window_title);
|
||||
}
|
||||
|
||||
json_object *workspace_min_width =
|
||||
json_object_object_get(bar_config, "workspace_min_width");
|
||||
if (workspace_min_width) {
|
||||
|
|
@ -430,10 +436,12 @@ bool ipc_initialize(struct swaybar *bar) {
|
|||
|
||||
struct swaybar_config *config = bar->config;
|
||||
char subscribe[128]; // suitably large buffer
|
||||
len = snprintf(subscribe, 128,
|
||||
"[ \"barconfig_update\" , \"bar_state_update\", \"window\" %s %s ]",
|
||||
len = snprintf(subscribe,
|
||||
128,
|
||||
"[ \"barconfig_update\" , \"bar_state_update\" %s %s %s ]",
|
||||
config->binding_mode_indicator ? ", \"mode\"" : "",
|
||||
config->workspace_buttons ? ", \"workspace\"" : "");
|
||||
config->workspace_buttons ? ", \"workspace\"" : "",
|
||||
config->window_title ? ", \"window\"" : "");
|
||||
free(ipc_single_command(bar->ipc_event_socketfd,
|
||||
IPC_SUBSCRIBE, subscribe, &len));
|
||||
return true;
|
||||
|
|
@ -634,16 +642,19 @@ bool ipc_set_focused_window(struct swaybar *bar) {
|
|||
return false;
|
||||
}
|
||||
|
||||
json_object *json_nodes;
|
||||
json_object_object_get_ex(results, "nodes", &json_nodes);
|
||||
assert(json_nodes);
|
||||
struct swaybar_window *window = get_focused_window_from_nodes(json_nodes);
|
||||
if (bar->focused_window) {
|
||||
free_window(bar->focused_window);
|
||||
bar->focused_window = NULL;
|
||||
}
|
||||
if (window) {
|
||||
bar->focused_window = window;
|
||||
if (bar->config->window_title) {
|
||||
json_object *json_nodes;
|
||||
json_object_object_get_ex(results, "nodes", &json_nodes);
|
||||
assert(json_nodes);
|
||||
struct swaybar_window *window =
|
||||
get_focused_window_from_nodes(json_nodes);
|
||||
if (bar->focused_window) {
|
||||
free_window(bar->focused_window);
|
||||
bar->focused_window = NULL;
|
||||
}
|
||||
if (window) {
|
||||
bar->focused_window = window;
|
||||
}
|
||||
}
|
||||
|
||||
bar->workspace_changed = false;
|
||||
|
|
@ -683,8 +694,10 @@ bool handle_ipc_readable(struct swaybar *bar) {
|
|||
case IPC_EVENT_WORKSPACE:
|
||||
bar->workspace_changed = true;
|
||||
bar_is_dirty = ipc_get_workspaces(bar);
|
||||
const bool focused_window_change = ipc_set_focused_window(bar);
|
||||
bar_is_dirty = bar_is_dirty ? true : focused_window_change;
|
||||
if (bar->config->window_title) {
|
||||
const bool focused_window_change = ipc_set_focused_window(bar);
|
||||
bar_is_dirty = bar_is_dirty ? true : focused_window_change;
|
||||
}
|
||||
break;
|
||||
case IPC_EVENT_MODE: {
|
||||
json_object *json_change, *json_pango_markup;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue