~craftyguy/terminate

3032cfaeae16d9778cdcb70360b54e14af47bda8 — Clayton Craft 3 years ago 2bdb6ae
Add config option for setting browser command
4 files changed, 17 insertions(+), 4 deletions(-)

M config
M doc/terminate.5.scd
M terminate.c
M terminate.h.in
M config => config +1 -0
@@ 4,6 4,7 @@ font_size=9
font=Iosevka Term
bell_command=notify-send 'terminate' 'bell from %s!'
url_clickable=true
browser=firefox

[Colors]
color_fg=#fce8c3

M doc/terminate.5.scd => doc/terminate.5.scd +4 -1
@@ 23,7 23,10 @@ Terminate looks for its configuration file under *$XDG_CONFIG_HOME/terminate/con
		Command (with optional parameters) to run when a bell event is received. %s can be used to pass the app_id, for example: `notify-send 'terminate' 'bell from %s'`

	*url_clickable*
		Whether or not to make url's clickable in the terminal. This opens the url with *$BROWSER* (or not if that var is unset).
		Whether or not to make url's clickable in the terminal. This opens the url with the command set in either the *browser* config option or *$BROWSER* environment variable.

	*browser*
		Command to use when opening urls. This takes precedence over any value set in the *$BROWSER* environment variable.

# COLORS
These options take colors in the format of \#RRGGBB, as a string.

M terminate.c => terminate.c +11 -3
@@ 80,6 80,9 @@ int get_config(struct ConfigOptions *config){
	config->url_clickable = g_key_file_get_boolean(config_file, "Settings",
						       "url_clickable", NULL);

	config->browser = g_key_file_get_string(config_file, "Settings",
						"browser", NULL);

	g_key_file_free(config_file);
	return 0;
}


@@ 180,13 183,18 @@ gboolean button_press(VteTerminal *term, GdkEventButton *evt,
			g_debug ("Mouse click on url: %s", url);
			gchar **cmd = NULL;
			gchar **env = g_get_environ();
			g_autofree gchar *browser = g_strdup(g_environ_getenv(env,
									      "BROWSER"));
			g_autofree gchar *browser;

			if (!config->browser) {
				browser = g_strdup(g_environ_getenv(env, "BROWSER"));
			 } else {
				browser = g_strdup(config->browser);
			}
			g_autofree gchar *execute = g_strdup_printf("%s %s",
								    browser,
								    url);
			if (g_shell_parse_argv(execute, NULL, &cmd, NULL) == FALSE){
				g_error ("Failed to parse browser from $BROWSER");
				g_error ("Failed to open browser");
				g_strfreev(env);
				g_strfreev(cmd);
				return FALSE;

M terminate.h.in => terminate.h.in +1 -0
@@ 11,6 11,7 @@

struct ConfigOptions {
	char *bell_command;
	char *browser;
	char *font;
	gdouble font_size;
	int scrollback_buffer;