Skip to content

Commit

Permalink
[DRun] new config option drun-url-launcher for opening links
Browse files Browse the repository at this point in the history
In previous commit, this was a hard-coded string.

part of davatorium#1166
  • Loading branch information
flavorjones committed Aug 26, 2020
1 parent 6bde1b2 commit 0e4149d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions config/config.c
Expand Up @@ -125,6 +125,8 @@ Settings config = {
.drun_show_actions = FALSE,
/** Desktop format display */
.drun_display_format = "{name} [<span weight='light' size='small'><i>({generic})</i></span>]",
/** Desktop Link launch command */
.drun_url_launcher = "xdg-open",

/** Window fields to match in window mode*/
.window_match_fields = "all",
Expand Down
2 changes: 2 additions & 0 deletions include/settings.h
Expand Up @@ -128,6 +128,8 @@ typedef struct
unsigned int drun_show_actions;
/** Desktop format display */
char * drun_display_format;
/** Desktop Link launch command */
char * drun_url_launcher;

/** Search case sensitivity */
unsigned int case_sensitive;
Expand Down
5 changes: 2 additions & 3 deletions source/dialogs/drun.c
Expand Up @@ -57,7 +57,6 @@

#define DRUN_CACHE_FILE "rofi3.druncache"
#define DRUN_DESKTOP_CACHE_FILE "rofi-drun-desktop.cache"
#define XDG_OPEN_COMMAND "xdg-open"

char *DRUN_GROUP_NAME = "Desktop Entry";

Expand Down Expand Up @@ -245,9 +244,9 @@ static void launch_link_entry ( DRunModeEntry *e )
return ;
}

gsize command_len = strlen( XDG_OPEN_COMMAND ) + strlen( url ) + 2; // space + terminator = 2
gsize command_len = strlen( config.drun_url_launcher ) + strlen( url ) + 2; // space + terminator = 2
gchar *command = g_newa ( gchar, command_len );
g_snprintf( command, command_len, "%s %s", XDG_OPEN_COMMAND, url );
g_snprintf( command, command_len, "%s %s", config.drun_url_launcher, url );
g_free ( url );

g_debug ( "Link launch command: |%s|", command );
Expand Down
2 changes: 2 additions & 0 deletions source/xrmoptions.c
Expand Up @@ -141,6 +141,8 @@ static XrmOption xrmOptions[] = {
"Desktop entry show actions.", CONFIG_DEFAULT },
{ xrm_String, "drun-display-format", { .str = &config.drun_display_format }, NULL,
"DRUN format string. (Supports: generic,name,comment,exec,categories)", CONFIG_DEFAULT },
{ xrm_String, "drun-url-launcher", { .str = &config.drun_url_launcher }, NULL,
"Command to open an Desktop Entry that is a Link.", CONFIG_DEFAULT },

{ xrm_Boolean, "disable-history", { .num = &config.disable_history }, NULL,
"Disable history in run/ssh", CONFIG_DEFAULT },
Expand Down

0 comments on commit 0e4149d

Please sign in to comment.