-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path01-regolith-trawl.patch
More file actions
152 lines (146 loc) · 5.24 KB
/
01-regolith-trawl.patch
File metadata and controls
152 lines (146 loc) · 5.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
Index: sway-regolith/meson.build
===================================================================
--- sway-regolith.orig/meson.build
+++ sway-regolith/meson.build
@@ -1,5 +1,5 @@
project(
- 'sway',
+ 'sway-regolith',
'c',
version: '1.10.1',
license: 'MIT',
@@ -80,6 +80,7 @@ math = cc.find_library('m')
rt = cc.find_library('rt')
xcb_icccm = wlroots_features['xwayland'] ? dependency('xcb-icccm') : null_dep
threads = dependency('threads') # for pthread_setschedparam
+trawldb = dependency('trawldb-0')
if get_option('sd-bus-provider') == 'auto'
if not get_option('tray').disabled()
Index: sway-regolith/sway/commands/set_from_resource.c
===================================================================
--- /dev/null
+++ sway-regolith/sway/commands/set_from_resource.c
@@ -0,0 +1,47 @@
+#define _POSIX_C_SOURCE 200809L
+#include "log.h"
+#include "stringop.h"
+#include "sway/commands.h"
+#include "sway/config.h"
+#include <trawldb/client_api.h>
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>
+
+struct cmd_results *cmd_set_from_resource(int argc, char **argv) {
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "set", EXPECTED_AT_LEAST, 2))) {
+ return error;
+ }
+ if (argv[0][0] != '$') {
+ return cmd_results_new(CMD_INVALID, "variable '%s' must start with $",
+ argv[0]);
+ }
+
+ conf_client proxy = NULL;
+ GError *err = NULL;
+ conf_client_init(&proxy, &err);
+
+ char *resource_value = NULL;
+ conf_client_get(proxy, argv[1], &resource_value, &err);
+
+ if (err || resource_value == NULL || strlen(resource_value) == 0) {
+ if (argc < 3) {
+ return cmd_results_new(CMD_FAILURE,
+ "failed to fetch value of resource '%s' and "
+ "fallback value not provided",
+ argv[1]);
+ }
+ resource_value = join_args(argv + 2, argc - 2);
+ }
+ char **argv_new = calloc(argc - 1, sizeof(char *));
+ argv_new[0] = strdup(argv[0]);
+ for (int i = 2; i < argc; i++) {
+ argv_new[i - 1] = argv[i];
+ }
+
+ argv_new[1] = strdup(resource_value);
+
+ free(resource_value);
+ return cmd_set(2, argv_new);
+}
Index: sway-regolith/include/sway/commands.h
===================================================================
--- sway-regolith.orig/include/sway/commands.h
+++ sway-regolith/include/sway/commands.h
@@ -173,6 +173,7 @@ sway_cmd cmd_resize;
sway_cmd cmd_scratchpad;
sway_cmd cmd_seamless_mouse;
sway_cmd cmd_set;
+sway_cmd cmd_set_from_resource;
sway_cmd cmd_shortcuts_inhibitor;
sway_cmd cmd_show_marks;
sway_cmd cmd_smart_borders;
Index: sway-regolith/sway/commands.c
===================================================================
--- sway-regolith.orig/sway/commands.c
+++ sway-regolith/sway/commands.c
@@ -83,6 +83,7 @@ static const struct cmd_handler handlers
{ "popup_during_fullscreen", cmd_popup_during_fullscreen },
{ "seat", cmd_seat },
{ "set", cmd_set },
+ { "set_from_resource", cmd_set_from_resource },
{ "show_marks", cmd_show_marks },
{ "smart_borders", cmd_smart_borders },
{ "smart_gaps", cmd_smart_gaps },
@@ -279,8 +280,8 @@ list_t *execute_command(char *_exec, str
goto cleanup;
}
- // Var replacement, for all but first argument of set
- for (int i = handler->handle == cmd_set ? 2 : 1; i < argc; ++i) {
+ // Var replacement, for all but first argument of set and xresource
+ for (int i = handler->handle == cmd_set || handler->handle == cmd_set_from_resource ? 2 : 1; i < argc; ++i) {
argv[i] = do_var_replacement(argv[i]);
}
@@ -392,7 +393,7 @@ struct cmd_results *config_command(char
}
// Do variable replacement
- if (handler->handle == cmd_set && argc > 1 && *argv[1] == '$') {
+ if ((handler->handle == cmd_set || handler->handle == cmd_set_from_resource )&& argc > 1 && *argv[1] == '$') {
// Escape the variable name so it does not get replaced by one shorter
char *temp = calloc(1, strlen(argv[1]) + 2);
temp[0] = '$';
@@ -407,7 +408,7 @@ struct cmd_results *config_command(char
free(command);
// Strip quotes and unescape the string
- for (int i = handler->handle == cmd_set ? 2 : 1; i < argc; ++i) {
+ for (int i = handler->handle == cmd_set || handler->handle == cmd_set_from_resource ? 2 : 1; i < argc; ++i) {
if (handler->handle != cmd_exec && handler->handle != cmd_exec_always
&& handler->handle != cmd_mode
&& handler->handle != cmd_bindsym
@@ -415,6 +416,7 @@ struct cmd_results *config_command(char
&& handler->handle != cmd_bindswitch
&& handler->handle != cmd_bindgesture
&& handler->handle != cmd_set
+ && handler->handle != cmd_set_from_resource
&& handler->handle != cmd_for_window
&& (*argv[i] == '\"' || *argv[i] == '\'')) {
strip_quotes(argv[i]);
Index: sway-regolith/sway/meson.build
===================================================================
--- sway-regolith.orig/sway/meson.build
+++ sway-regolith/sway/meson.build
@@ -103,6 +103,7 @@ sway_sources = files(
'commands/seat/shortcuts_inhibitor.c',
'commands/seat/xcursor_theme.c',
'commands/set.c',
+ 'commands/set_from_resource.c',
'commands/show_marks.c',
'commands/shortcuts_inhibitor.c',
'commands/smart_borders.c',
@@ -234,6 +235,7 @@ sway_deps = [
xkbcommon,
xcb,
xcb_icccm,
+ trawldb,
]
if wlroots_features['xwayland']