2017-04-15 06:32:05 -04:00
|
|
|
/*
|
2015-11-03 02:31:38 -05:00
|
|
|
* rofi
|
|
|
|
*
|
|
|
|
* MIT/X11 License
|
2017-04-15 06:32:05 -04:00
|
|
|
* Copyright © 2013-2017 Qball Cow <qball@gmpclient.org>
|
2015-11-03 02:31:38 -05:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
2017-04-15 05:58:49 -04:00
|
|
|
|
2017-04-27 16:59:14 -04:00
|
|
|
#define G_LOG_DOMAIN "Dialogs.DRun"
|
2017-04-15 05:58:49 -04:00
|
|
|
|
2015-11-03 02:31:38 -05:00
|
|
|
#include <config.h>
|
2016-08-29 15:38:29 -04:00
|
|
|
#ifdef ENABLE_DRUN
|
2015-11-03 02:31:38 -05:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <sys/types.h>
|
2016-06-05 13:01:38 -04:00
|
|
|
#include <sys/stat.h>
|
2015-11-03 02:31:38 -05:00
|
|
|
#include <dirent.h>
|
|
|
|
#include <strings.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include "rofi.h"
|
2016-01-07 10:01:56 -05:00
|
|
|
#include "settings.h"
|
2015-11-03 02:31:38 -05:00
|
|
|
#include "helper.h"
|
2016-10-31 03:07:02 -04:00
|
|
|
#include "timings.h"
|
2016-10-08 12:57:59 -04:00
|
|
|
#include "widgets/textbox.h"
|
2016-02-16 04:40:21 -05:00
|
|
|
#include "history.h"
|
2015-11-03 02:31:38 -05:00
|
|
|
#include "dialogs/drun.h"
|
2017-04-12 12:08:57 -04:00
|
|
|
#include "nkutils-xdg-theme.h"
|
2017-05-31 18:12:03 -04:00
|
|
|
#include "xcb.h"
|
2015-11-03 02:31:38 -05:00
|
|
|
|
2016-08-28 16:43:42 -04:00
|
|
|
#define DRUN_CACHE_FILE "rofi2.druncache"
|
2015-11-03 02:31:38 -05:00
|
|
|
|
2017-03-14 12:34:41 -04:00
|
|
|
|
2015-11-07 05:20:25 -05:00
|
|
|
/**
|
|
|
|
* Store extra information about the entry.
|
|
|
|
* Currently the executable and if it should run in terminal.
|
|
|
|
*/
|
2016-03-24 17:15:10 -04:00
|
|
|
typedef struct
|
2015-11-03 11:34:02 -05:00
|
|
|
{
|
2016-08-28 16:43:42 -04:00
|
|
|
/* Root */
|
2017-04-12 12:08:57 -04:00
|
|
|
char *root;
|
2016-02-16 04:40:21 -05:00
|
|
|
/* Path to desktop file */
|
2017-04-12 12:08:57 -04:00
|
|
|
char *path;
|
|
|
|
/* Icon stuff */
|
2017-06-02 11:36:06 -04:00
|
|
|
int icon_size;
|
2017-04-12 12:08:57 -04:00
|
|
|
char *icon_name;
|
|
|
|
cairo_surface_t *icon;
|
2015-11-21 17:59:59 -05:00
|
|
|
/* Executable */
|
2017-04-12 12:08:57 -04:00
|
|
|
char *exec;
|
2015-11-21 17:59:59 -05:00
|
|
|
/* Name of the Entry */
|
2017-04-12 12:08:57 -04:00
|
|
|
char *name;
|
2015-11-21 17:59:59 -05:00
|
|
|
/* Generic Name */
|
2017-04-12 12:08:57 -04:00
|
|
|
char *generic_name;
|
|
|
|
char **categories;
|
2016-12-26 09:18:52 -05:00
|
|
|
|
2017-04-12 12:08:57 -04:00
|
|
|
GKeyFile *key_file;
|
2015-11-03 11:34:02 -05:00
|
|
|
} DRunModeEntry;
|
|
|
|
|
2016-03-24 17:15:10 -04:00
|
|
|
typedef struct
|
2015-11-03 11:34:02 -05:00
|
|
|
{
|
2017-04-12 12:08:57 -04:00
|
|
|
NkXdgThemeContext *xdg_context;
|
|
|
|
DRunModeEntry *entry_list;
|
|
|
|
unsigned int cmd_list_length;
|
|
|
|
unsigned int cmd_list_length_actual;
|
|
|
|
unsigned int history_length;
|
2016-08-30 15:49:46 -04:00
|
|
|
// List of disabled entries.
|
2017-05-31 14:21:58 -04:00
|
|
|
GHashTable *disabled_entries;
|
|
|
|
unsigned int disabled_entries_length;
|
|
|
|
GThread *thread;
|
2017-06-02 11:36:06 -04:00
|
|
|
GAsyncQueue *icon_fetch_queue;
|
2017-06-02 11:03:45 -04:00
|
|
|
|
|
|
|
unsigned int expected_line_height;
|
2017-06-02 11:36:06 -04:00
|
|
|
DRunModeEntry quit_entry;
|
2015-11-03 11:34:02 -05:00
|
|
|
} DRunModePrivateData;
|
|
|
|
|
2016-08-29 15:14:03 -04:00
|
|
|
struct RegexEvalArg
|
|
|
|
{
|
|
|
|
DRunModeEntry *e;
|
|
|
|
gboolean success;
|
|
|
|
};
|
|
|
|
static gboolean drun_helper_eval_cb ( const GMatchInfo *info, GString *res, gpointer data )
|
2015-11-03 11:34:02 -05:00
|
|
|
{
|
2016-08-29 15:14:03 -04:00
|
|
|
// TODO quoting is not right? Find description not very clear, need to check.
|
|
|
|
struct RegexEvalArg *e = (struct RegexEvalArg *) data;
|
|
|
|
|
|
|
|
gchar *match;
|
|
|
|
// Get the match
|
|
|
|
match = g_match_info_fetch ( info, 0 );
|
|
|
|
if ( match != NULL ) {
|
|
|
|
switch ( match[1] )
|
|
|
|
{
|
|
|
|
// Unsupported
|
|
|
|
case 'f':
|
|
|
|
case 'F':
|
|
|
|
case 'u':
|
|
|
|
case 'U':
|
|
|
|
case 'i':
|
|
|
|
// Deprecated
|
|
|
|
case 'd':
|
|
|
|
case 'D':
|
|
|
|
case 'n':
|
|
|
|
case 'N':
|
|
|
|
case 'v':
|
|
|
|
case 'm':
|
|
|
|
break;
|
|
|
|
case 'k':
|
|
|
|
if ( e->e->path ) {
|
|
|
|
char *esc = g_shell_quote ( e->e->path );
|
|
|
|
g_string_append ( res, esc );
|
|
|
|
g_free ( esc );
|
2015-11-03 11:34:02 -05:00
|
|
|
}
|
2016-08-29 15:14:03 -04:00
|
|
|
break;
|
|
|
|
case 'c':
|
|
|
|
if ( e->e->name ) {
|
|
|
|
char *esc = g_shell_quote ( e->e->name );
|
|
|
|
g_string_append ( res, esc );
|
|
|
|
g_free ( esc );
|
2015-11-23 11:11:12 -05:00
|
|
|
}
|
2016-08-29 15:14:03 -04:00
|
|
|
break;
|
|
|
|
// Invalid, this entry should not be processed -> throw error.
|
|
|
|
default:
|
|
|
|
e->success = FALSE;
|
|
|
|
g_free ( match );
|
|
|
|
return TRUE;
|
2015-11-03 11:34:02 -05:00
|
|
|
}
|
2016-08-29 15:14:03 -04:00
|
|
|
g_free ( match );
|
|
|
|
}
|
|
|
|
// Continue replacement.
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
static void exec_cmd_entry ( DRunModeEntry *e )
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
GRegex *reg = g_regex_new ( "%[a-zA-Z]", 0, 0, &error );
|
|
|
|
if ( error != NULL ) {
|
2017-04-15 05:58:49 -04:00
|
|
|
g_warning ( "Internal error, failed to create regex: %s.", error->message );
|
2016-08-29 15:14:03 -04:00
|
|
|
g_error_free ( error );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
struct RegexEvalArg earg = { .e = e, .success = TRUE };
|
|
|
|
char *str = g_regex_replace_eval ( reg, e->exec, -1, 0, 0, drun_helper_eval_cb, &earg, &error );
|
|
|
|
if ( error != NULL ) {
|
2017-04-15 05:58:49 -04:00
|
|
|
g_warning ( "Internal error, failed replace field codes: %s.", error->message );
|
2016-08-29 15:14:03 -04:00
|
|
|
g_error_free ( error );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
g_regex_unref ( reg );
|
|
|
|
if ( earg.success == FALSE ) {
|
2017-04-15 05:58:49 -04:00
|
|
|
g_warning ( "Invalid field code in Exec line: %s.", e->exec );;
|
2016-08-29 15:14:03 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( str == NULL ) {
|
2017-04-15 05:58:49 -04:00
|
|
|
g_warning ( "Nothing to execute after processing: %s.", e->exec );;
|
2016-08-29 15:14:03 -04:00
|
|
|
return;
|
2015-11-03 11:34:02 -05:00
|
|
|
}
|
2017-01-08 15:36:06 -05:00
|
|
|
gchar *fp = rofi_expand_path ( g_strstrip ( str ) );
|
2016-12-26 09:18:52 -05:00
|
|
|
gchar *exec_path = g_key_file_get_string ( e->key_file, "Desktop Entry", "Path", NULL );
|
2017-01-21 06:58:52 -05:00
|
|
|
if ( exec_path != NULL && strlen ( exec_path ) == 0 ) {
|
2017-01-17 14:00:00 -05:00
|
|
|
// If it is empty, ignore this property. (#529)
|
2017-01-21 06:58:52 -05:00
|
|
|
g_free ( exec_path );
|
2017-01-17 14:00:00 -05:00
|
|
|
exec_path = NULL;
|
|
|
|
}
|
|
|
|
|
2017-02-02 02:35:33 -05:00
|
|
|
// Returns false if not found, if key not found, we don't want run in terminal.
|
|
|
|
gboolean terminal = g_key_file_get_boolean ( e->key_file, "Desktop Entry", "Terminal", NULL );
|
2017-02-17 08:06:31 -05:00
|
|
|
if ( helper_execute_command ( exec_path, fp, terminal ) ) {
|
2016-02-16 04:40:21 -05:00
|
|
|
char *path = g_build_filename ( cache_dir, DRUN_CACHE_FILE, NULL );
|
2016-08-28 16:43:42 -04:00
|
|
|
char *key = g_strdup_printf ( "%s:::%s", e->root, e->path );
|
|
|
|
history_set ( path, key );
|
|
|
|
g_free ( key );
|
2016-02-16 04:40:21 -05:00
|
|
|
g_free ( path );
|
|
|
|
}
|
2016-12-26 09:18:52 -05:00
|
|
|
g_free ( exec_path );
|
2015-11-03 11:34:02 -05:00
|
|
|
g_free ( str );
|
2016-01-14 11:42:07 -05:00
|
|
|
g_free ( fp );
|
2015-11-03 11:34:02 -05:00
|
|
|
}
|
2016-02-16 04:40:21 -05:00
|
|
|
/**
|
|
|
|
* This function absorbs/freeś path, so this is no longer available afterwards.
|
|
|
|
*/
|
2017-03-21 12:19:05 -04:00
|
|
|
static gboolean read_desktop_file ( DRunModePrivateData *pd, const char *root, const char *path )
|
2016-02-16 04:40:21 -05:00
|
|
|
{
|
2016-08-30 02:52:02 -04:00
|
|
|
// Create ID on stack.
|
|
|
|
// We know strlen (path ) > strlen(root)+1
|
2016-08-31 04:06:42 -04:00
|
|
|
const ssize_t id_len = strlen ( path ) - strlen ( root );
|
2016-08-30 11:41:30 -04:00
|
|
|
char id[id_len];
|
|
|
|
g_strlcpy ( id, &( path[strlen ( root ) + 1] ), id_len );
|
2016-08-28 16:43:42 -04:00
|
|
|
for ( int index = 0; index < id_len; index++ ) {
|
|
|
|
if ( id[index] == '/' ) {
|
|
|
|
id[index] = '-';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-30 15:49:46 -04:00
|
|
|
// Check if item is on disabled list.
|
2016-10-31 03:44:04 -04:00
|
|
|
if ( g_hash_table_contains ( pd->disabled_entries, id ) ) {
|
2017-04-15 05:37:50 -04:00
|
|
|
g_debug ( "Skipping: %s, was previously seen.", id );
|
2017-03-21 12:19:05 -04:00
|
|
|
return TRUE;
|
2016-02-16 04:40:21 -05:00
|
|
|
}
|
|
|
|
GKeyFile *kf = g_key_file_new ();
|
|
|
|
GError *error = NULL;
|
|
|
|
g_key_file_load_from_file ( kf, path, 0, &error );
|
|
|
|
// If error, skip to next entry
|
|
|
|
if ( error != NULL ) {
|
2017-04-15 05:37:50 -04:00
|
|
|
g_debug ( "Failed to parse desktop file: %s because: %s", path, error->message );
|
2016-02-16 04:40:21 -05:00
|
|
|
g_error_free ( error );
|
|
|
|
g_key_file_free ( kf );
|
2017-03-21 12:19:05 -04:00
|
|
|
return FALSE;
|
2016-02-16 04:40:21 -05:00
|
|
|
}
|
2016-08-29 02:55:28 -04:00
|
|
|
// Skip non Application entries.
|
2016-08-30 02:52:02 -04:00
|
|
|
gchar *key = g_key_file_get_string ( kf, "Desktop Entry", "Type", NULL );
|
2016-08-30 11:41:30 -04:00
|
|
|
if ( key == NULL ) {
|
2016-08-29 15:14:03 -04:00
|
|
|
// No type? ignore.
|
2017-04-15 05:37:50 -04:00
|
|
|
g_debug ( "Skipping desktop file: %s because: No type indicated", path );
|
2016-08-29 15:14:03 -04:00
|
|
|
g_key_file_free ( kf );
|
2017-03-21 12:19:05 -04:00
|
|
|
return FALSE;
|
2016-08-29 15:14:03 -04:00
|
|
|
}
|
2016-08-30 02:52:02 -04:00
|
|
|
if ( g_strcmp0 ( key, "Application" ) ) {
|
2017-04-15 05:37:50 -04:00
|
|
|
g_debug ( "Skipping desktop file: %s because: Not of type application (%s)", path, key );
|
2016-08-30 02:52:02 -04:00
|
|
|
g_free ( key );
|
|
|
|
g_key_file_free ( kf );
|
2017-03-21 12:19:05 -04:00
|
|
|
return FALSE;
|
2016-08-30 11:41:30 -04:00
|
|
|
}
|
|
|
|
g_free ( key );
|
2016-08-31 03:39:00 -04:00
|
|
|
|
|
|
|
// Name key is required.
|
|
|
|
if ( !g_key_file_has_key ( kf, "Desktop Entry", "Name", NULL ) ) {
|
2017-04-15 05:58:49 -04:00
|
|
|
g_debug ( "Invalid DesktopFile: '%s', no 'Name' key present.", path );
|
2016-08-31 03:39:00 -04:00
|
|
|
g_key_file_free ( kf );
|
2017-03-21 12:19:05 -04:00
|
|
|
return FALSE;
|
2016-08-31 03:39:00 -04:00
|
|
|
}
|
|
|
|
|
2016-02-16 04:40:21 -05:00
|
|
|
// Skip hidden entries.
|
2016-08-30 02:52:02 -04:00
|
|
|
if ( g_key_file_get_boolean ( kf, "Desktop Entry", "Hidden", NULL ) ) {
|
2017-04-15 05:37:50 -04:00
|
|
|
g_debug ( "Adding desktop file: %s to disabled list because: Hdden", path );
|
2016-08-30 02:52:02 -04:00
|
|
|
g_key_file_free ( kf );
|
2016-10-31 03:44:04 -04:00
|
|
|
g_hash_table_add ( pd->disabled_entries, g_strdup ( id ) );
|
2017-03-21 12:19:05 -04:00
|
|
|
return FALSE;
|
2016-02-16 04:40:21 -05:00
|
|
|
}
|
|
|
|
// Skip entries that have NoDisplay set.
|
2016-08-30 02:52:02 -04:00
|
|
|
if ( g_key_file_get_boolean ( kf, "Desktop Entry", "NoDisplay", NULL ) ) {
|
2017-04-15 05:37:50 -04:00
|
|
|
g_debug ( "Adding desktop file: %s to disabled list because: NoDisplay", path );
|
2016-08-30 02:52:02 -04:00
|
|
|
g_key_file_free ( kf );
|
2016-10-31 03:44:04 -04:00
|
|
|
g_hash_table_add ( pd->disabled_entries, g_strdup ( id ) );
|
2017-03-21 12:19:05 -04:00
|
|
|
return FALSE;
|
2016-02-16 04:40:21 -05:00
|
|
|
}
|
2016-08-29 02:55:28 -04:00
|
|
|
// We need Exec, don't support DBusActivatable
|
|
|
|
if ( !g_key_file_has_key ( kf, "Desktop Entry", "Exec", NULL ) ) {
|
2017-04-15 05:58:49 -04:00
|
|
|
g_debug ( "Unsupported DesktopFile: '%s', no 'Exec' key present.", path );
|
2016-08-29 02:55:28 -04:00
|
|
|
g_key_file_free ( kf );
|
2017-03-21 12:19:05 -04:00
|
|
|
return FALSE;
|
2016-08-29 02:55:28 -04:00
|
|
|
}
|
2016-10-31 10:51:47 -04:00
|
|
|
size_t nl = ( ( pd->cmd_list_length ) + 1 );
|
2017-02-02 02:35:33 -05:00
|
|
|
if ( nl >= pd->cmd_list_length_actual ) {
|
2017-02-03 14:49:16 -05:00
|
|
|
pd->cmd_list_length_actual += 256;
|
|
|
|
pd->entry_list = g_realloc ( pd->entry_list, pd->cmd_list_length_actual * sizeof ( *( pd->entry_list ) ) );
|
2017-02-02 02:35:33 -05:00
|
|
|
}
|
2016-11-01 03:04:39 -04:00
|
|
|
pd->entry_list[pd->cmd_list_length].root = g_strdup ( root );
|
|
|
|
pd->entry_list[pd->cmd_list_length].path = g_strdup ( path );
|
2016-10-31 10:51:47 -04:00
|
|
|
gchar *n = g_key_file_get_locale_string ( kf, "Desktop Entry", "Name", NULL, NULL );
|
|
|
|
pd->entry_list[pd->cmd_list_length].name = n;
|
|
|
|
gchar *gn = g_key_file_get_locale_string ( kf, "Desktop Entry", "GenericName", NULL, NULL );
|
|
|
|
pd->entry_list[pd->cmd_list_length].generic_name = gn;
|
2017-03-17 09:07:11 -04:00
|
|
|
pd->entry_list[pd->cmd_list_length].categories = g_key_file_get_locale_string_list ( kf, "Desktop Entry", "Categories", NULL, NULL, NULL );
|
|
|
|
pd->entry_list[pd->cmd_list_length].exec = g_key_file_get_string ( kf, "Desktop Entry", "Exec", NULL );
|
2016-10-15 14:00:26 -04:00
|
|
|
|
2017-05-30 13:07:33 -04:00
|
|
|
if ( config.show_icons ) {
|
|
|
|
pd->entry_list[pd->cmd_list_length].icon_name = g_key_file_get_locale_string ( kf, "Desktop Entry", "Icon", NULL, NULL );
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
pd->entry_list[pd->cmd_list_length].icon_name = NULL;
|
|
|
|
}
|
|
|
|
pd->entry_list[pd->cmd_list_length].icon = NULL;
|
2017-04-12 12:08:57 -04:00
|
|
|
|
2016-12-26 09:18:52 -05:00
|
|
|
// Keep keyfile around.
|
|
|
|
pd->entry_list[pd->cmd_list_length].key_file = kf;
|
2016-10-31 10:51:47 -04:00
|
|
|
// We don't want to parse items with this id anymore.
|
|
|
|
g_hash_table_add ( pd->disabled_entries, g_strdup ( id ) );
|
|
|
|
( pd->cmd_list_length )++;
|
2017-03-21 12:19:05 -04:00
|
|
|
return TRUE;
|
2016-02-16 04:40:21 -05:00
|
|
|
}
|
|
|
|
|
2015-11-03 02:31:38 -05:00
|
|
|
/**
|
|
|
|
* Internal spider used to get list of executables.
|
|
|
|
*/
|
2016-08-28 16:43:42 -04:00
|
|
|
static void walk_dir ( DRunModePrivateData *pd, const char *root, const char *dirname )
|
2015-11-03 02:31:38 -05:00
|
|
|
{
|
2016-06-05 13:01:38 -04:00
|
|
|
DIR *dir;
|
2015-11-03 02:31:38 -05:00
|
|
|
|
2017-06-02 12:13:11 -04:00
|
|
|
g_debug ( "Checking directory %s for desktop files.", dirname );
|
2016-06-05 13:01:38 -04:00
|
|
|
dir = opendir ( dirname );
|
|
|
|
if ( dir == NULL ) {
|
|
|
|
return;
|
|
|
|
}
|
2015-11-03 02:31:38 -05:00
|
|
|
|
2016-06-05 13:01:38 -04:00
|
|
|
struct dirent *file;
|
|
|
|
gchar *filename = NULL;
|
|
|
|
struct stat st;
|
|
|
|
while ( ( file = readdir ( dir ) ) != NULL ) {
|
|
|
|
if ( file->d_name[0] == '.' ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
switch ( file->d_type )
|
|
|
|
{
|
|
|
|
case DT_LNK:
|
|
|
|
case DT_REG:
|
|
|
|
case DT_DIR:
|
|
|
|
case DT_UNKNOWN:
|
|
|
|
filename = g_build_filename ( dirname, file->d_name, NULL );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// On a link, or if FS does not support providing this information
|
|
|
|
// Fallback to stat method.
|
|
|
|
if ( file->d_type == DT_LNK || file->d_type == DT_UNKNOWN ) {
|
|
|
|
file->d_type = DT_UNKNOWN;
|
|
|
|
if ( stat ( filename, &st ) == 0 ) {
|
|
|
|
if ( S_ISDIR ( st.st_mode ) ) {
|
|
|
|
file->d_type = DT_DIR;
|
|
|
|
}
|
|
|
|
else if ( S_ISREG ( st.st_mode ) ) {
|
|
|
|
file->d_type = DT_REG;
|
|
|
|
}
|
2015-11-03 11:34:02 -05:00
|
|
|
}
|
2015-11-03 02:31:38 -05:00
|
|
|
}
|
|
|
|
|
2016-06-05 13:01:38 -04:00
|
|
|
switch ( file->d_type )
|
|
|
|
{
|
|
|
|
case DT_REG:
|
2016-10-31 03:44:04 -04:00
|
|
|
// Skip files not ending on .desktop.
|
|
|
|
if ( g_str_has_suffix ( file->d_name, ".desktop" ) ) {
|
|
|
|
read_desktop_file ( pd, root, filename );
|
|
|
|
}
|
2016-06-05 13:01:38 -04:00
|
|
|
break;
|
|
|
|
case DT_DIR:
|
2016-08-28 16:43:42 -04:00
|
|
|
walk_dir ( pd, root, filename );
|
2016-06-05 13:01:38 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
g_free ( filename );
|
2015-11-03 02:31:38 -05:00
|
|
|
}
|
2016-06-05 13:01:38 -04:00
|
|
|
closedir ( dir );
|
2015-11-03 02:31:38 -05:00
|
|
|
}
|
2016-02-16 04:40:21 -05:00
|
|
|
/**
|
2016-06-01 01:34:41 -04:00
|
|
|
* @param entry The command entry to remove from history
|
2016-02-16 04:40:21 -05:00
|
|
|
*
|
|
|
|
* Remove command from history.
|
|
|
|
*/
|
|
|
|
static void delete_entry_history ( const DRunModeEntry *entry )
|
|
|
|
{
|
|
|
|
char *path = g_build_filename ( cache_dir, DRUN_CACHE_FILE, NULL );
|
2017-03-20 07:37:52 -04:00
|
|
|
char *key = g_strdup_printf ( "%s:::%s", entry->root, entry->path );
|
|
|
|
history_remove ( path, key );
|
|
|
|
g_free ( key );
|
2016-02-16 04:40:21 -05:00
|
|
|
g_free ( path );
|
|
|
|
}
|
2016-06-05 13:01:38 -04:00
|
|
|
|
2016-02-16 04:40:21 -05:00
|
|
|
static void get_apps_history ( DRunModePrivateData *pd )
|
|
|
|
{
|
|
|
|
unsigned int length = 0;
|
|
|
|
gchar *path = g_build_filename ( cache_dir, DRUN_CACHE_FILE, NULL );
|
|
|
|
gchar **retv = history_get_list ( path, &length );
|
|
|
|
for ( unsigned int index = 0; index < length; index++ ) {
|
2016-08-28 16:43:42 -04:00
|
|
|
char **st = g_strsplit ( retv[index], ":::", 2 );
|
|
|
|
if ( st && st[0] && st[1] ) {
|
2017-03-25 09:23:31 -04:00
|
|
|
if ( !read_desktop_file ( pd, st[0], st[1] ) ) {
|
|
|
|
history_remove ( path, retv[index] );
|
2017-03-21 12:19:05 -04:00
|
|
|
}
|
2016-08-28 16:43:42 -04:00
|
|
|
}
|
|
|
|
g_strfreev ( st );
|
2016-02-16 04:40:21 -05:00
|
|
|
}
|
2016-10-31 12:02:10 -04:00
|
|
|
g_strfreev ( retv );
|
2017-03-21 12:19:05 -04:00
|
|
|
g_free ( path );
|
2016-02-16 04:40:21 -05:00
|
|
|
pd->history_length = pd->cmd_list_length;
|
|
|
|
}
|
2016-06-05 13:01:38 -04:00
|
|
|
|
2015-11-03 11:34:02 -05:00
|
|
|
static void get_apps ( DRunModePrivateData *pd )
|
2015-11-03 02:31:38 -05:00
|
|
|
{
|
2016-10-31 03:44:04 -04:00
|
|
|
TICK_N ( "Get Desktop apps (start)" );
|
2016-02-16 04:40:21 -05:00
|
|
|
get_apps_history ( pd );
|
2015-11-03 11:34:02 -05:00
|
|
|
|
2016-08-28 16:43:42 -04:00
|
|
|
gchar *dir;
|
|
|
|
// First read the user directory.
|
|
|
|
dir = g_build_filename ( g_get_user_data_dir (), "applications", NULL );
|
|
|
|
walk_dir ( pd, dir, dir );
|
|
|
|
g_free ( dir );
|
2016-10-31 03:44:04 -04:00
|
|
|
TICK_N ( "Get Desktop apps (user dir)" );
|
2016-08-28 16:43:42 -04:00
|
|
|
// Then read thee system data dirs.
|
2016-06-05 13:01:38 -04:00
|
|
|
const gchar * const * sys = g_get_system_data_dirs ();
|
2017-06-02 12:13:11 -04:00
|
|
|
for (const gchar * const *iter = sys ; *iter != NULL; ++iter ) {
|
|
|
|
gboolean unique = TRUE;
|
|
|
|
// Stupid duplicate detection, better then walking dir.
|
|
|
|
for ( const gchar *const *iterd = sys ; iterd != iter; ++iterd ){
|
|
|
|
if ( g_strcmp0 ( *iter, *iterd ) == 0 ) {
|
|
|
|
unique = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Check, we seem to be getting empty string...
|
|
|
|
if ( unique && (**iter) != '\0') {
|
|
|
|
dir = g_build_filename ( *iter, "applications", NULL );
|
|
|
|
walk_dir ( pd, dir, dir );
|
|
|
|
g_free ( dir );
|
|
|
|
}
|
2015-11-03 11:34:02 -05:00
|
|
|
}
|
2016-10-31 03:44:04 -04:00
|
|
|
TICK_N ( "Get Desktop apps (system dirs)" );
|
2015-11-03 11:34:02 -05:00
|
|
|
}
|
2015-11-03 02:31:38 -05:00
|
|
|
|
2017-06-02 11:36:06 -04:00
|
|
|
static gpointer drun_icon_fetch ( gpointer data )
|
2017-05-31 05:05:45 -04:00
|
|
|
{
|
|
|
|
// as long as dr->icon is updated atomicly.. (is a pointer write atomic?)
|
|
|
|
// this should be fine running in another thread.
|
2017-05-31 14:21:58 -04:00
|
|
|
DRunModePrivateData *pd = (DRunModePrivateData *) data;
|
2017-06-02 11:36:06 -04:00
|
|
|
DRunModeEntry *dr;
|
|
|
|
while ( ( dr = g_async_queue_pop ( pd->icon_fetch_queue )) != &(pd->quit_entry) )
|
|
|
|
{
|
2017-05-31 14:21:58 -04:00
|
|
|
if ( dr->icon_name == NULL ) {
|
|
|
|
continue;
|
|
|
|
}
|
2017-06-02 11:36:06 -04:00
|
|
|
gchar *icon_path = nk_xdg_theme_get_icon ( pd->xdg_context, NULL, "Applications", dr->icon_name, dr->icon_size, 1, TRUE );
|
2017-05-31 14:21:58 -04:00
|
|
|
if ( icon_path == NULL ) {
|
|
|
|
g_free ( dr->icon_name );
|
|
|
|
dr->icon_name = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else{
|
2017-06-02 11:36:06 -04:00
|
|
|
g_log ( G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Found Icon %s(%d): %s", dr->icon_name, dr->icon_size, icon_path );
|
2017-05-31 14:21:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( g_str_has_suffix ( icon_path, ".png" ) ) {
|
|
|
|
dr->icon = cairo_image_surface_create_from_png ( icon_path );
|
|
|
|
}
|
|
|
|
else if ( g_str_has_suffix ( icon_path, ".svg" ) ) {
|
2017-06-02 11:36:06 -04:00
|
|
|
dr->icon = cairo_image_surface_create_from_svg ( icon_path, dr->icon_size);
|
2017-05-31 14:21:58 -04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
g_log ( G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Icon type not yet supported: %s", icon_path );
|
|
|
|
char *r = dr->icon_name;
|
|
|
|
dr->icon_name = NULL;
|
|
|
|
g_free ( r );
|
|
|
|
}
|
|
|
|
g_free ( icon_path );
|
2017-06-02 11:03:45 -04:00
|
|
|
rofi_view_reload ();
|
2017-05-31 14:21:58 -04:00
|
|
|
}
|
2017-06-02 11:36:06 -04:00
|
|
|
return NULL;
|
2017-05-31 05:05:45 -04:00
|
|
|
}
|
|
|
|
|
2016-01-08 03:16:59 -05:00
|
|
|
static int drun_mode_init ( Mode *sw )
|
2015-11-03 02:31:38 -05:00
|
|
|
{
|
2016-01-07 15:27:20 -05:00
|
|
|
if ( mode_get_private_data ( sw ) == NULL ) {
|
2015-11-03 02:31:38 -05:00
|
|
|
DRunModePrivateData *pd = g_malloc0 ( sizeof ( *pd ) );
|
2016-10-31 03:44:04 -04:00
|
|
|
pd->disabled_entries = g_hash_table_new_full ( g_str_hash, g_str_equal, g_free, NULL );
|
2016-01-07 15:27:20 -05:00
|
|
|
mode_set_private_data ( sw, (void *) pd );
|
2017-04-12 12:08:57 -04:00
|
|
|
pd->xdg_context = nk_xdg_theme_context_new ();
|
2015-11-21 17:59:59 -05:00
|
|
|
get_apps ( pd );
|
2017-06-02 11:36:06 -04:00
|
|
|
pd->icon_fetch_queue = g_async_queue_new ( );
|
2015-11-03 02:31:38 -05:00
|
|
|
}
|
2016-01-08 03:16:59 -05:00
|
|
|
return TRUE;
|
2015-11-03 02:31:38 -05:00
|
|
|
}
|
2016-02-16 04:40:21 -05:00
|
|
|
static void drun_entry_clear ( DRunModeEntry *e )
|
|
|
|
{
|
2016-08-28 16:43:42 -04:00
|
|
|
g_free ( e->root );
|
2016-02-16 04:40:21 -05:00
|
|
|
g_free ( e->path );
|
2017-04-12 12:08:57 -04:00
|
|
|
if ( e->icon != NULL ) {
|
|
|
|
cairo_surface_destroy ( e->icon );
|
|
|
|
}
|
|
|
|
g_free ( e->icon_name );
|
2016-02-16 04:40:21 -05:00
|
|
|
g_free ( e->exec );
|
|
|
|
g_free ( e->name );
|
|
|
|
g_free ( e->generic_name );
|
2017-03-14 12:34:41 -04:00
|
|
|
g_strfreev ( e->categories );
|
2016-12-26 09:18:52 -05:00
|
|
|
g_key_file_free ( e->key_file );
|
2016-02-16 04:40:21 -05:00
|
|
|
}
|
2015-11-03 02:31:38 -05:00
|
|
|
|
2015-11-25 03:26:38 -05:00
|
|
|
static ModeMode drun_mode_result ( Mode *sw, int mretv, char **input, unsigned int selected_line )
|
2015-11-03 02:31:38 -05:00
|
|
|
{
|
2016-01-07 15:27:20 -05:00
|
|
|
DRunModePrivateData *rmpd = (DRunModePrivateData *) mode_get_private_data ( sw );
|
2015-11-25 03:26:38 -05:00
|
|
|
ModeMode retv = MODE_EXIT;
|
2015-11-03 02:31:38 -05:00
|
|
|
|
2016-03-17 08:14:30 -04:00
|
|
|
gboolean run_in_term = ( ( mretv & MENU_CUSTOM_ACTION ) == MENU_CUSTOM_ACTION );
|
2015-11-03 02:31:38 -05:00
|
|
|
|
|
|
|
if ( mretv & MENU_NEXT ) {
|
|
|
|
retv = NEXT_DIALOG;
|
|
|
|
}
|
|
|
|
else if ( mretv & MENU_PREVIOUS ) {
|
|
|
|
retv = PREVIOUS_DIALOG;
|
|
|
|
}
|
|
|
|
else if ( mretv & MENU_QUICK_SWITCH ) {
|
|
|
|
retv = ( mretv & MENU_LOWER_MASK );
|
|
|
|
}
|
2015-11-21 17:59:59 -05:00
|
|
|
else if ( ( mretv & MENU_OK ) ) {
|
2015-11-03 11:34:02 -05:00
|
|
|
exec_cmd_entry ( &( rmpd->entry_list[selected_line] ) );
|
2015-11-03 02:31:38 -05:00
|
|
|
}
|
|
|
|
else if ( ( mretv & MENU_CUSTOM_INPUT ) && *input != NULL && *input[0] != '\0' ) {
|
2017-02-17 08:06:31 -05:00
|
|
|
helper_execute_command ( NULL, *input, run_in_term );
|
2015-11-03 02:31:38 -05:00
|
|
|
}
|
2016-02-16 04:40:21 -05:00
|
|
|
else if ( ( mretv & MENU_ENTRY_DELETE ) && selected_line < rmpd->cmd_list_length ) {
|
|
|
|
if ( selected_line < rmpd->history_length ) {
|
2017-05-31 05:05:45 -04:00
|
|
|
if ( rmpd->thread ) {
|
2017-06-02 11:36:06 -04:00
|
|
|
g_async_queue_lock ( rmpd->icon_fetch_queue );
|
|
|
|
DRunModeEntry *dr;
|
|
|
|
while ( (dr = g_async_queue_try_pop_unlocked ( rmpd->icon_fetch_queue )) != NULL ){
|
|
|
|
// Reset for possible re-fetch.
|
|
|
|
dr->icon_size = 0;
|
|
|
|
}
|
|
|
|
g_async_queue_unlock ( rmpd->icon_fetch_queue );
|
2017-05-31 05:05:45 -04:00
|
|
|
}
|
2016-02-16 04:40:21 -05:00
|
|
|
delete_entry_history ( &( rmpd->entry_list[selected_line] ) );
|
|
|
|
drun_entry_clear ( &( rmpd->entry_list[selected_line] ) );
|
|
|
|
memmove ( &( rmpd->entry_list[selected_line] ), &rmpd->entry_list[selected_line + 1],
|
|
|
|
sizeof ( DRunModeEntry ) * ( rmpd->cmd_list_length - selected_line - 1 ) );
|
|
|
|
rmpd->cmd_list_length--;
|
|
|
|
}
|
|
|
|
retv = RELOAD_DIALOG;
|
|
|
|
}
|
2015-11-03 02:31:38 -05:00
|
|
|
return retv;
|
|
|
|
}
|
2015-11-25 03:26:38 -05:00
|
|
|
static void drun_mode_destroy ( Mode *sw )
|
2015-11-03 02:31:38 -05:00
|
|
|
{
|
2016-01-07 15:27:20 -05:00
|
|
|
DRunModePrivateData *rmpd = (DRunModePrivateData *) mode_get_private_data ( sw );
|
2015-11-03 02:31:38 -05:00
|
|
|
if ( rmpd != NULL ) {
|
2017-05-31 14:21:58 -04:00
|
|
|
if ( rmpd->thread ) {
|
2017-06-02 11:36:06 -04:00
|
|
|
g_async_queue_lock ( rmpd->icon_fetch_queue );
|
|
|
|
while ( g_async_queue_try_pop_unlocked ( rmpd->icon_fetch_queue ) );
|
|
|
|
// Make the thread quit.
|
|
|
|
g_async_queue_push_front_unlocked ( rmpd->icon_fetch_queue, (gpointer) &(rmpd->quit_entry));
|
|
|
|
g_async_queue_unlock ( rmpd->icon_fetch_queue );
|
2017-05-31 05:05:45 -04:00
|
|
|
g_thread_join ( rmpd->thread );
|
|
|
|
rmpd->thread = NULL;
|
|
|
|
}
|
2017-06-02 11:36:06 -04:00
|
|
|
if ( rmpd->icon_fetch_queue ) {
|
|
|
|
g_async_queue_unref ( rmpd->icon_fetch_queue );
|
|
|
|
rmpd->icon_fetch_queue = NULL;
|
|
|
|
}
|
2015-11-03 11:34:02 -05:00
|
|
|
for ( size_t i = 0; i < rmpd->cmd_list_length; i++ ) {
|
2016-02-16 04:40:21 -05:00
|
|
|
drun_entry_clear ( &( rmpd->entry_list[i] ) );
|
2015-11-03 11:34:02 -05:00
|
|
|
}
|
2016-10-31 03:44:04 -04:00
|
|
|
g_hash_table_destroy ( rmpd->disabled_entries );
|
2015-11-03 11:34:02 -05:00
|
|
|
g_free ( rmpd->entry_list );
|
2017-04-12 12:08:57 -04:00
|
|
|
nk_xdg_theme_context_free ( rmpd->xdg_context );
|
2015-11-03 02:31:38 -05:00
|
|
|
g_free ( rmpd );
|
2016-01-07 15:27:20 -05:00
|
|
|
mode_set_private_data ( sw, NULL );
|
2015-11-03 02:31:38 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-10 17:39:29 -05:00
|
|
|
static char *_get_display_value ( const Mode *sw, unsigned int selected_line, int *state, G_GNUC_UNUSED GList **list, int get_entry )
|
2015-11-03 02:31:38 -05:00
|
|
|
{
|
2016-01-07 15:27:20 -05:00
|
|
|
DRunModePrivateData *pd = (DRunModePrivateData *) mode_get_private_data ( sw );
|
2015-11-03 11:34:02 -05:00
|
|
|
*state |= MARKUP;
|
2015-11-21 17:59:59 -05:00
|
|
|
if ( !get_entry ) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if ( pd->entry_list == NULL ) {
|
|
|
|
// Should never get here.
|
|
|
|
return g_strdup ( "Failed" );
|
|
|
|
}
|
|
|
|
/* Free temp storage. */
|
|
|
|
DRunModeEntry *dr = &( pd->entry_list[selected_line] );
|
|
|
|
if ( dr->generic_name == NULL ) {
|
2017-05-31 05:05:45 -04:00
|
|
|
return g_markup_printf_escaped ( "%s", dr->name );
|
2015-11-21 17:59:59 -05:00
|
|
|
}
|
|
|
|
else {
|
2017-05-31 05:05:45 -04:00
|
|
|
return g_markup_printf_escaped ( "%s <span weight='light' size='small'><i>(%s)</i></span>", dr->name,
|
|
|
|
dr->generic_name );
|
2015-11-21 17:59:59 -05:00
|
|
|
}
|
|
|
|
}
|
2017-04-12 12:08:57 -04:00
|
|
|
|
|
|
|
static cairo_surface_t *_get_icon ( const Mode *sw, unsigned int selected_line, int height )
|
|
|
|
{
|
|
|
|
DRunModePrivateData *pd = (DRunModePrivateData *) mode_get_private_data ( sw );
|
|
|
|
g_return_val_if_fail ( pd->entry_list != NULL, NULL );
|
2017-05-31 14:21:58 -04:00
|
|
|
DRunModeEntry *dr = &( pd->entry_list[selected_line] );
|
2017-06-02 11:36:06 -04:00
|
|
|
if ( pd->thread == NULL ) {
|
|
|
|
pd->thread = g_thread_new ( "icon-fetch-drun", drun_icon_fetch, pd );
|
|
|
|
}
|
|
|
|
if ( dr->icon_size == 0 && dr->icon_name ) {
|
|
|
|
dr->icon_size = height;
|
|
|
|
g_async_queue_push ( pd->icon_fetch_queue, dr );
|
|
|
|
}
|
2017-04-12 12:08:57 -04:00
|
|
|
return dr->icon;
|
|
|
|
}
|
|
|
|
|
2015-11-25 03:26:38 -05:00
|
|
|
static char *drun_get_completion ( const Mode *sw, unsigned int index )
|
2015-11-24 07:59:35 -05:00
|
|
|
{
|
2016-01-07 15:27:20 -05:00
|
|
|
DRunModePrivateData *pd = (DRunModePrivateData *) mode_get_private_data ( sw );
|
2015-11-24 07:59:35 -05:00
|
|
|
/* Free temp storage. */
|
|
|
|
DRunModeEntry *dr = &( pd->entry_list[index] );
|
|
|
|
if ( dr->generic_name == NULL ) {
|
|
|
|
return g_strdup ( dr->name );
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return g_strdup_printf ( "%s", dr->name );
|
|
|
|
}
|
|
|
|
}
|
2015-11-21 17:59:59 -05:00
|
|
|
|
2016-05-26 02:39:33 -04:00
|
|
|
static int drun_token_match ( const Mode *data, GRegex **tokens, unsigned int index )
|
2015-11-21 17:59:59 -05:00
|
|
|
{
|
2016-01-07 15:27:20 -05:00
|
|
|
DRunModePrivateData *rmpd = (DRunModePrivateData *) mode_get_private_data ( data );
|
2015-12-14 14:28:25 -05:00
|
|
|
int match = 1;
|
|
|
|
if ( tokens ) {
|
2015-12-14 14:25:36 -05:00
|
|
|
for ( int j = 0; match && tokens != NULL && tokens[j] != NULL; j++ ) {
|
2016-05-26 02:39:33 -04:00
|
|
|
int test = 0;
|
2016-05-22 11:47:34 -04:00
|
|
|
GRegex *ftokens[2] = { tokens[j], NULL };
|
2016-12-26 09:18:52 -05:00
|
|
|
// Match name
|
2017-03-17 08:33:47 -04:00
|
|
|
if ( rmpd->entry_list[index].name &&
|
2017-02-17 03:58:47 -05:00
|
|
|
helper_token_match ( ftokens, rmpd->entry_list[index].name ) ) {
|
2015-12-14 14:28:25 -05:00
|
|
|
test = 1;
|
2015-12-14 14:25:36 -05:00
|
|
|
}
|
2016-12-26 09:18:52 -05:00
|
|
|
// Match generic name
|
2015-12-14 14:25:36 -05:00
|
|
|
if ( !test && rmpd->entry_list[index].generic_name &&
|
2017-02-17 03:58:47 -05:00
|
|
|
helper_token_match ( ftokens, rmpd->entry_list[index].generic_name ) ) {
|
2015-12-14 14:28:25 -05:00
|
|
|
test = 1;
|
2015-12-14 14:25:36 -05:00
|
|
|
}
|
2016-12-26 09:18:52 -05:00
|
|
|
// Match executable name.
|
2017-02-17 03:58:47 -05:00
|
|
|
if ( !test && helper_token_match ( ftokens, rmpd->entry_list[index].exec ) ) {
|
2015-12-14 14:25:36 -05:00
|
|
|
test = 1;
|
|
|
|
}
|
2016-12-26 09:18:52 -05:00
|
|
|
// Match against category.
|
2017-01-08 15:36:06 -05:00
|
|
|
if ( !test ) {
|
2017-03-14 12:34:41 -04:00
|
|
|
gchar **list = rmpd->entry_list[index].categories;
|
|
|
|
for ( int iter = 0; !test && list && list[iter]; iter++ ) {
|
|
|
|
test = helper_token_match ( ftokens, list[iter] );
|
|
|
|
}
|
2016-12-26 09:18:52 -05:00
|
|
|
}
|
2015-12-14 14:25:36 -05:00
|
|
|
if ( test == 0 ) {
|
|
|
|
match = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return match;
|
2015-11-21 17:59:59 -05:00
|
|
|
}
|
|
|
|
|
2015-11-25 03:26:38 -05:00
|
|
|
static unsigned int drun_mode_get_num_entries ( const Mode *sw )
|
2015-11-21 17:59:59 -05:00
|
|
|
{
|
2016-01-07 15:27:20 -05:00
|
|
|
const DRunModePrivateData *pd = (const DRunModePrivateData *) mode_get_private_data ( sw );
|
2015-11-21 17:59:59 -05:00
|
|
|
return pd->cmd_list_length;
|
|
|
|
}
|
2016-01-07 15:27:20 -05:00
|
|
|
#include "mode-private.h"
|
2015-11-25 03:26:38 -05:00
|
|
|
Mode drun_mode =
|
2015-11-03 02:31:38 -05:00
|
|
|
{
|
2016-01-07 15:27:20 -05:00
|
|
|
.name = "drun",
|
2016-01-12 16:17:53 -05:00
|
|
|
.cfg_name_key = "display-drun",
|
2016-01-07 15:27:20 -05:00
|
|
|
._init = drun_mode_init,
|
|
|
|
._get_num_entries = drun_mode_get_num_entries,
|
|
|
|
._result = drun_mode_result,
|
|
|
|
._destroy = drun_mode_destroy,
|
|
|
|
._token_match = drun_token_match,
|
|
|
|
._get_completion = drun_get_completion,
|
|
|
|
._get_display_value = _get_display_value,
|
2017-04-12 12:08:57 -04:00
|
|
|
._get_icon = _get_icon,
|
2016-05-26 02:39:33 -04:00
|
|
|
._preprocess_input = NULL,
|
2016-01-07 15:27:20 -05:00
|
|
|
.private_data = NULL,
|
|
|
|
.free = NULL
|
2015-11-03 02:31:38 -05:00
|
|
|
};
|
2016-08-29 15:38:29 -04:00
|
|
|
|
|
|
|
#endif // ENABLE_DRUN
|