mirror of
https://github.com/lbonn/rofi
synced 2024-11-30 15:49:17 +00:00
parent
c06aa59a62
commit
5a638b1fa0
1 changed files with 19 additions and 9 deletions
|
@ -92,12 +92,12 @@ typedef struct
|
||||||
char *path;
|
char *path;
|
||||||
/* Executable */
|
/* Executable */
|
||||||
char *exec;
|
char *exec;
|
||||||
/* Path */
|
|
||||||
char *exec_path;
|
|
||||||
/* Name of the Entry */
|
/* Name of the Entry */
|
||||||
char *name;
|
char *name;
|
||||||
/* Generic Name */
|
/* Generic Name */
|
||||||
char *generic_name;
|
char *generic_name;
|
||||||
|
|
||||||
|
GKeyFile *key_file;
|
||||||
/* Application needs to be launched in terminal. */
|
/* Application needs to be launched in terminal. */
|
||||||
unsigned int terminal;
|
unsigned int terminal;
|
||||||
} DRunModeEntry;
|
} DRunModeEntry;
|
||||||
|
@ -193,13 +193,15 @@ static void exec_cmd_entry ( DRunModeEntry *e )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gchar *fp = rofi_expand_path ( g_strstrip ( str ) );
|
gchar *fp = rofi_expand_path ( g_strstrip ( str ) );
|
||||||
if ( execsh ( e->exec_path, fp, e->terminal ) ) {
|
gchar *exec_path = g_key_file_get_string ( e->key_file, "Desktop Entry", "Path", NULL );
|
||||||
|
if ( execsh ( exec_path, fp, e->terminal ) ) {
|
||||||
char *path = g_build_filename ( cache_dir, DRUN_CACHE_FILE, NULL );
|
char *path = g_build_filename ( cache_dir, DRUN_CACHE_FILE, NULL );
|
||||||
char *key = g_strdup_printf ( "%s:::%s", e->root, e->path );
|
char *key = g_strdup_printf ( "%s:::%s", e->root, e->path );
|
||||||
history_set ( path, key );
|
history_set ( path, key );
|
||||||
g_free ( key );
|
g_free ( key );
|
||||||
g_free ( path );
|
g_free ( path );
|
||||||
}
|
}
|
||||||
|
g_free ( exec_path );
|
||||||
g_free ( str );
|
g_free ( str );
|
||||||
g_free ( fp );
|
g_free ( fp );
|
||||||
}
|
}
|
||||||
|
@ -289,13 +291,11 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const
|
||||||
// Returns false if not found, if key not found, we don't want run in terminal.
|
// Returns false if not found, if key not found, we don't want run in terminal.
|
||||||
pd->entry_list[pd->cmd_list_length].terminal = g_key_file_get_boolean ( kf, "Desktop Entry", "Terminal", NULL );
|
pd->entry_list[pd->cmd_list_length].terminal = g_key_file_get_boolean ( kf, "Desktop Entry", "Terminal", NULL );
|
||||||
|
|
||||||
// Returns NULL if not found.
|
// Keep keyfile around.
|
||||||
pd->entry_list[pd->cmd_list_length].exec_path = g_key_file_get_string ( kf, "Desktop Entry", "Path", NULL );
|
pd->entry_list[pd->cmd_list_length].key_file = kf;
|
||||||
// We don't want to parse items with this id anymore.
|
// We don't want to parse items with this id anymore.
|
||||||
g_hash_table_add ( pd->disabled_entries, g_strdup ( id ) );
|
g_hash_table_add ( pd->disabled_entries, g_strdup ( id ) );
|
||||||
( pd->cmd_list_length )++;
|
( pd->cmd_list_length )++;
|
||||||
|
|
||||||
g_key_file_free ( kf );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -429,9 +429,9 @@ static void drun_entry_clear ( DRunModeEntry *e )
|
||||||
g_free ( e->root );
|
g_free ( e->root );
|
||||||
g_free ( e->path );
|
g_free ( e->path );
|
||||||
g_free ( e->exec );
|
g_free ( e->exec );
|
||||||
g_free ( e->exec_path );
|
|
||||||
g_free ( e->name );
|
g_free ( e->name );
|
||||||
g_free ( e->generic_name );
|
g_free ( e->generic_name );
|
||||||
|
g_key_file_free ( e->key_file );
|
||||||
}
|
}
|
||||||
|
|
||||||
static ModeMode drun_mode_result ( Mode *sw, int mretv, char **input, unsigned int selected_line )
|
static ModeMode drun_mode_result ( Mode *sw, int mretv, char **input, unsigned int selected_line )
|
||||||
|
@ -524,18 +524,28 @@ static int drun_token_match ( const Mode *data, GRegex **tokens, unsigned int in
|
||||||
for ( int j = 0; match && tokens != NULL && tokens[j] != NULL; j++ ) {
|
for ( int j = 0; match && tokens != NULL && tokens[j] != NULL; j++ ) {
|
||||||
int test = 0;
|
int test = 0;
|
||||||
GRegex *ftokens[2] = { tokens[j], NULL };
|
GRegex *ftokens[2] = { tokens[j], NULL };
|
||||||
|
// Match name
|
||||||
if ( !test && rmpd->entry_list[index].name &&
|
if ( !test && rmpd->entry_list[index].name &&
|
||||||
token_match ( ftokens, rmpd->entry_list[index].name ) ) {
|
token_match ( ftokens, rmpd->entry_list[index].name ) ) {
|
||||||
test = 1;
|
test = 1;
|
||||||
}
|
}
|
||||||
|
// Match generic name
|
||||||
if ( !test && rmpd->entry_list[index].generic_name &&
|
if ( !test && rmpd->entry_list[index].generic_name &&
|
||||||
token_match ( ftokens, rmpd->entry_list[index].generic_name ) ) {
|
token_match ( ftokens, rmpd->entry_list[index].generic_name ) ) {
|
||||||
test = 1;
|
test = 1;
|
||||||
}
|
}
|
||||||
|
// Match executable name.
|
||||||
if ( !test && token_match ( ftokens, rmpd->entry_list[index].exec ) ) {
|
if ( !test && token_match ( ftokens, rmpd->entry_list[index].exec ) ) {
|
||||||
test = 1;
|
test = 1;
|
||||||
}
|
}
|
||||||
|
// Match against category.
|
||||||
|
if ( !test ){
|
||||||
|
gchar **list = g_key_file_get_locale_string_list ( rmpd->entry_list[index].key_file, "Desktop Entry", "Categories" , NULL, NULL,NULL );
|
||||||
|
for ( int iter = 0; !test && list && list[iter]; iter++){
|
||||||
|
test = token_match ( ftokens, list[iter]);
|
||||||
|
}
|
||||||
|
g_strfreev(list);
|
||||||
|
}
|
||||||
if ( test == 0 ) {
|
if ( test == 0 ) {
|
||||||
match = 0;
|
match = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue