mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
[FileBrowser] Allow command to be overwritten
This commit is contained in:
parent
b02a9d552b
commit
82b2ce9435
3 changed files with 18 additions and 2 deletions
|
@ -38,7 +38,7 @@ To show the \fB\fCdrun\fR dialog:
|
||||||
.RE
|
.RE
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
A very useful setup in minimalistic window managers is to combine \fB\fCdrun\fR, \fB\fCrun\fR
|
A useful setup in minimalistic window managers is to combine \fB\fCdrun\fR, \fB\fCrun\fR
|
||||||
with \fB\fCwindow\fR mode:
|
with \fB\fCwindow\fR mode:
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
|
@ -1157,6 +1157,8 @@ configuration {
|
||||||
show-hidden: false;
|
show-hidden: false;
|
||||||
/** return 1 on cancel. */
|
/** return 1 on cancel. */
|
||||||
cancel-returns-1: true;
|
cancel-returns-1: true;
|
||||||
|
/** command */
|
||||||
|
command: "xdg-open";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -712,6 +712,8 @@ configuration {
|
||||||
show-hidden: false;
|
show-hidden: false;
|
||||||
/** return 1 on cancel. */
|
/** return 1 on cancel. */
|
||||||
cancel-returns-1: true;
|
cancel-returns-1: true;
|
||||||
|
/** command */
|
||||||
|
command: "xdg-open";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
#include "rofi-icon-fetcher.h"
|
#include "rofi-icon-fetcher.h"
|
||||||
|
|
||||||
#define FILEBROWSER_CACHE_FILE "rofi3.filebrowsercache"
|
#define FILEBROWSER_CACHE_FILE "rofi3.filebrowsercache"
|
||||||
|
#define DEFAULT_OPEN "xdg-open"
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
#define st_atim st_atimespec
|
#define st_atim st_atimespec
|
||||||
|
@ -97,6 +98,7 @@ typedef struct {
|
||||||
} FBFile;
|
} FBFile;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
char *command;
|
||||||
GFile *current_dir;
|
GFile *current_dir;
|
||||||
FBFile *array;
|
FBFile *array;
|
||||||
unsigned int array_length;
|
unsigned int array_length;
|
||||||
|
@ -344,6 +346,7 @@ static void get_file_browser(Mode *sw) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void file_browser_mode_init_config(Mode *sw) {
|
static void file_browser_mode_init_config(Mode *sw) {
|
||||||
|
FileBrowserModePrivateData * pd = (FileBrowserModePrivateData*)mode_get_private_data(sw);
|
||||||
char *msg = NULL;
|
char *msg = NULL;
|
||||||
gboolean found_error = FALSE;
|
gboolean found_error = FALSE;
|
||||||
|
|
||||||
|
@ -380,6 +383,14 @@ static void file_browser_mode_init_config(Mode *sw) {
|
||||||
file_browser_config.show_hidden = p->value.b;
|
file_browser_config.show_hidden = p->value.b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p = rofi_theme_find_property(wid, P_STRING, "command", TRUE);
|
||||||
|
if ( p != NULL && p->type == P_STRING ) {
|
||||||
|
pd->command = g_strdup(p->value.s);
|
||||||
|
} else {
|
||||||
|
pd->command = g_strdup(DEFAULT_OPEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (found_error) {
|
if (found_error) {
|
||||||
rofi_view_error_dialog(msg, FALSE);
|
rofi_view_error_dialog(msg, FALSE);
|
||||||
|
|
||||||
|
@ -484,7 +495,7 @@ static ModeMode file_browser_mode_result(Mode *sw, int mretv, char **input,
|
||||||
(pd->array[selected_line].type == DIRECTORY &&
|
(pd->array[selected_line].type == DIRECTORY &&
|
||||||
special_command)) {
|
special_command)) {
|
||||||
char *d_esc = g_shell_quote(pd->array[selected_line].path);
|
char *d_esc = g_shell_quote(pd->array[selected_line].path);
|
||||||
char *cmd = g_strdup_printf("xdg-open %s", d_esc);
|
char *cmd = g_strdup_printf("%s %s",pd->command, d_esc);
|
||||||
g_free(d_esc);
|
g_free(d_esc);
|
||||||
char *cdir = g_file_get_path(pd->current_dir);
|
char *cdir = g_file_get_path(pd->current_dir);
|
||||||
helper_execute_command(cdir, cmd, FALSE, NULL);
|
helper_execute_command(cdir, cmd, FALSE, NULL);
|
||||||
|
@ -546,6 +557,7 @@ static void file_browser_mode_destroy(Mode *sw) {
|
||||||
(FileBrowserModePrivateData *)mode_get_private_data(sw);
|
(FileBrowserModePrivateData *)mode_get_private_data(sw);
|
||||||
if (pd != NULL) {
|
if (pd != NULL) {
|
||||||
g_object_unref(pd->current_dir);
|
g_object_unref(pd->current_dir);
|
||||||
|
g_free(pd->command);
|
||||||
free_list(pd);
|
free_list(pd);
|
||||||
g_free(pd);
|
g_free(pd);
|
||||||
mode_set_private_data(sw, NULL);
|
mode_set_private_data(sw, NULL);
|
||||||
|
|
Loading…
Reference in a new issue