diff --git a/config/config.c b/config/config.c index da2fd797..32d13228 100644 --- a/config/config.c +++ b/config/config.c @@ -117,7 +117,7 @@ Settings config = { .matching = "normal", .matching_method = MM_NORMAL, /** Desktop entry fields to match*/ - .drun_match_fields = "name,generic,exec,categories", + .drun_match_fields = "name,generic,exec,categories,keywords", .drun_categories = NULL, /** Desktop format display */ .drun_display_format = "{name} [({generic})]", diff --git a/doc/default_theme.rasi b/doc/default_theme.rasi index 41d3ea0b..2e8698ca 100644 --- a/doc/default_theme.rasi +++ b/doc/default_theme.rasi @@ -79,6 +79,7 @@ element-text { element-icon { background-color: rgba ( 0, 0, 0, 0 % ); text-color: inherit; + size: 1.2ch; } window { background-color: var(background); diff --git a/doc/help-output.txt b/doc/help-output.txt index f740c4fa..754db8aa 100644 --- a/doc/help-output.txt +++ b/doc/help-output.txt @@ -27,6 +27,7 @@ DMENU command line options: -u [list] List of row indexes to mark urgent -a [list] List of row indexes to mark active -l [integer] Number of rows to display + -window-title [string] Set the dmenu window title -i Set filter to be case insensitive -only-match Force selection or custom entry -no-custom Don't accept custom entry diff --git a/doc/test_xr.txt b/doc/test_xr.txt index 6adc7202..faadacc6 100644 --- a/doc/test_xr.txt +++ b/doc/test_xr.txt @@ -41,7 +41,7 @@ rofi.window-command: xkill -id {window} ! "Theme to use to look for icons" Set from: Default ! rofi.icon-theme: ! "Desktop entry fields to match in drun" Set from: Default -! rofi.drun-match-fields: name,generic,exec,categories +! rofi.drun-match-fields: name,generic,exec,categories,keywords ! "Only show Desktop entry from these categories" Set from: Default ! rofi.drun-categories: ! "Desktop entry show actions." Set from: Default diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c index 2bde5035..e2242782 100644 --- a/source/dialogs/drun.c +++ b/source/dialogs/drun.c @@ -94,6 +94,8 @@ typedef struct char *generic_name; /* Categories */ char **categories; + /* Keywords */ + char **keywords; /* Comments */ char *comment; @@ -116,6 +118,7 @@ typedef enum DRUN_MATCH_FIELD_GENERIC, DRUN_MATCH_FIELD_EXEC, DRUN_MATCH_FIELD_CATEGORIES, + DRUN_MATCH_FIELD_KEYWORDS, DRUN_MATCH_FIELD_COMMENT, DRUN_MATCH_NUM_FIELDS, } DRunMatchingFields; @@ -125,6 +128,7 @@ static DRunEntryField matching_entry_fields[DRUN_MATCH_NUM_FIELDS] = { { .entry_field_name = "generic", .enabled = TRUE, }, { .entry_field_name = "exec", .enabled = TRUE, }, { .entry_field_name = "categories", .enabled = TRUE, }, + { .entry_field_name = "keywords", .enabled = TRUE, }, { .entry_field_name = "comment", .enabled = FALSE, } }; @@ -455,6 +459,13 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const pd->entry_list[pd->cmd_list_length].action = DRUN_GROUP_NAME; gchar *gn = g_key_file_get_locale_string ( kf, DRUN_GROUP_NAME, "GenericName", NULL, NULL ); pd->entry_list[pd->cmd_list_length].generic_name = gn; + + if ( matching_entry_fields[DRUN_MATCH_FIELD_KEYWORDS].enabled ) { + pd->entry_list[pd->cmd_list_length].keywords = g_key_file_get_locale_string_list ( kf, DRUN_GROUP_NAME, "Keywords", NULL, NULL, NULL ); + } else { + pd->entry_list[pd->cmd_list_length].keywords = NULL; + } + if ( matching_entry_fields[DRUN_MATCH_FIELD_CATEGORIES].enabled ) { if ( categories ) { pd->entry_list[pd->cmd_list_length].categories = categories; @@ -727,6 +738,7 @@ static void drun_entry_clear ( DRunModeEntry *e ) g_free ( e->action ); } g_strfreev ( e->categories ); + g_strfreev ( e->keywords ); g_key_file_free ( e->key_file ); } @@ -801,6 +813,14 @@ static char *_get_display_value ( const Mode *sw, unsigned int selected_line, in g_free (tcats); } } + gchar *keywords= NULL; + if ( dr->keywords ){ + char *tkeyw= g_strjoinv(",", dr->keywords); + if ( tkeyw ) { + keywords = g_markup_escape_text ( tkeyw, -1 ); + g_free (tkeyw); + } + } // Needed for display. char *egn = NULL; char *en = NULL; @@ -822,6 +842,7 @@ static char *_get_display_value ( const Mode *sw, unsigned int selected_line, in "{comment}", ec, "{exec}", dr->exec, "{categories}", cats, + "{keywords}", keywords, NULL); g_free ( egn ); g_free ( en ); @@ -893,6 +914,15 @@ static int drun_token_match ( const Mode *data, rofi_int_matcher **tokens, unsig } } } + if ( matching_entry_fields[DRUN_MATCH_FIELD_KEYWORDS].enabled ) { + // Match against category. + if ( test == tokens[j]->invert ) { + gchar **list = rmpd->entry_list[index].keywords; + for ( int iter = 0; test == tokens[j]->invert && list && list[iter]; iter++ ) { + test = helper_token_match ( ftokens, list[iter] ); + } + } + } if ( matching_entry_fields[DRUN_MATCH_FIELD_COMMENT].enabled ) { // Match executable name. if ( test == tokens[j]->invert && rmpd->entry_list[index].comment ) { diff --git a/test/run_all_tests.sh b/test/run_all_tests.sh index af702441..94427e9f 100755 --- a/test/run_all_tests.sh +++ b/test/run_all_tests.sh @@ -13,7 +13,6 @@ tests=( run_dmenu_issue_292 run_screenshot_test xr_dump_test - run_drun_test run_combi_test run_regex_test run_glob_test