aboutsummaryrefslogtreecommitdiff
path: root/config.def.h
diff options
context:
space:
mode:
authorArslaan Pathan <[email protected]>2026-04-04 23:19:01 +1300
committerArslaan Pathan <[email protected]>2026-04-04 23:19:01 +1300
commit57db20f454b74aaaa90db69169656d23bb831e25 (patch)
tree4166d4ea26dc71e47b436913f99c099855fa27c3 /config.def.h
parent39bf7c8f1c18a6f83b4b073c9961fddfe847e69f (diff)
downloadcinnamon-browser-57db20f454b74aaaa90db69169656d23bb831e25.tar.xz
cinnamon-browser-57db20f454b74aaaa90db69169656d23bb831e25.zip
Make command bar work and add search stuff
Diffstat (limited to 'config.def.h')
-rw-r--r--config.def.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h
index 587e85b..3e2b792 100644
--- a/config.def.h
+++ b/config.def.h
@@ -18,6 +18,8 @@ extern void set_mode(Cinnamon* cinnamon, int new_mode);
/* default window width/height, can be resized after. */
#define WINDOW_WIDTH 1024
#define WINDOW_HEIGHT 768
+/* searchengine/homepage */
+#define SEARCH_ENGINE "https://duckduckgo.com/?q="
#define HOMEPAGE "https://start.duckduckgo.com"
/* if a keybind is unbound, still don't send when not in insert mode */
#define NO_SEND_UNBOUND_KEYBINDS
@@ -100,4 +102,36 @@ static const Keybind keybinds[] = {
{ "<A-0>", &_kbd_tabsel, (void*)(intptr_t)-1 },
};
+/* Command definitions */
+
+/* as mentioned above, prefixes like _cmd and _kbd are for good practice but in your modified configs you can do what you want. i don't care, i just make the software, do what you want with your config */
+static void _cmd_open(Cinnamon* cinnamon, const char* args) {
+ GtkWidget *webview = gtk_notebook_get_nth_page(GTK_NOTEBOOK(cinnamon->notebook), gtk_notebook_get_current_page(GTK_NOTEBOOK(cinnamon->notebook)));
+
+ char uri[2048];
+ if (strncmp(args, "http://", 7) == 0 || strncmp(args, "https://", 8) == 0) {
+ snprintf(uri, sizeof(uri), "%s", args);
+ } else if (strchr(args, '.') && !strchr(args, ' ')) {
+ /* has a dot and no spaces, probably a domain */
+ /* if it's not, oh well, too bad so sad */
+ snprintf(uri, sizeof(uri), "https://%s", args);
+ } else {
+ /* urlencode magic */
+ char encoded[1024];
+ int j = 0;
+ for (int i = 0; args[i] && j < (int)sizeof(encoded)-1; i++) {
+ if (args[i] == ' ') encoded[j++] = '+';
+ else encoded[j++] = args[i];
+ }
+ encoded[j] = '\0';
+ snprintf(uri, sizeof(uri), SEARCH_ENGINE "%s", encoded);
+ }
+
+ webkit_web_view_load_uri(WEBKIT_WEB_VIEW(webview), uri);
+}
+
+static const Command commands[] = {
+ { "open", &_cmd_open }
+};
+
#endif