@@ -23,21 +23,6 @@ const { OK } = result;
23
23
const HOME_DIR : string = GLib . get_home_dir ( ) ;
24
24
const DATA_DIRS : string = GLib . get_system_data_dirs ( ) ;
25
25
26
- /// Search paths for finding applications
27
- const SEARCH_PATHS : Array < [ string , string ] > = [
28
- // System-wide
29
- [ "System" , "/usr/share/applications/" ] ,
30
- [ "System (Local)" , "/usr/local/share/applications/" ] ,
31
- // User-local
32
- [ "User" , HOME_DIR + "/.local/share/applications/" ] ,
33
- // System-wide flatpaks
34
- [ "Flatpak (System)" , "/var/lib/flatpak/exports/share/applications/" ] ,
35
- // User-local flatpaks
36
- [ "Flatpak (User)" , HOME_DIR + "/.local/share/flatpak/exports/share/applications/" ] ,
37
- // System-wide Snaps
38
- [ "Snap (System)" , "/var/lib/snapd/desktop/applications/" ]
39
- ] ;
40
-
41
26
export class Launcher extends search . Search {
42
27
options : Array < launch . SearchOption >
43
28
desktop_apps : Array < [ string , AppInfo ] >
@@ -110,7 +95,9 @@ export class Launcher extends search.Search {
110
95
for ( const [ where , app ] of this . desktop_apps ) {
111
96
const name = app . name ( )
112
97
const keywords = app . keywords ( )
113
- const app_items = keywords !== null ? name . split ( ) . concat ( keywords ) : [ name ]
98
+ const exec = app . exec ( )
99
+ const app_items = keywords !== null ?
100
+ name . split ( ) . concat ( keywords ) . concat ( exec ) : name . split ( ) . concat ( exec )
114
101
115
102
for ( const item of app_items ) {
116
103
const item_match = item . toLowerCase ( )
@@ -125,6 +112,7 @@ export class Launcher extends search.Search {
125
112
{ gicon : app . icon ( ) } ,
126
113
this . icon_size ( ) ,
127
114
{ app } ,
115
+ exec ,
128
116
keywords
129
117
)
130
118
@@ -139,9 +127,12 @@ export class Launcher extends search.Search {
139
127
const sorter = ( a : launch . SearchOption , b : launch . SearchOption ) => {
140
128
const a_name = a . title . toLowerCase ( )
141
129
const b_name = b . title . toLowerCase ( )
130
+ const a_exec = a . exec ? a . exec . toLowerCase ( ) : ""
131
+ const b_exec = b . exec ? b . exec . toLowerCase ( ) : ""
142
132
143
133
let a_weight = 0 , b_weight = 0 ;
144
134
135
+ // Sort by metadata (name, description, keywords)
145
136
if ( ! a_name . startsWith ( pattern ) ) {
146
137
a_weight = 1
147
138
if ( ! a_name . includes ( pattern ) {
@@ -160,7 +151,17 @@ export class Launcher extends search.Search {
160
151
}
161
152
}
162
153
}
154
+ // Sort by command (exec)
155
+ if ( a_exec . includes ( pattern ) ) {
156
+ if ( a_exec . startsWith ( pattern ) {
157
+ a_weight = Math . min ( a_weight , 2 )
158
+ } else {
159
+ a_weight = Math . min ( a_weight , levenshtein . compare ( pattern , a_exec ) )
160
+ }
161
+ }
162
+
163
163
164
+ // Sort by metadata (name, description, keywords)
164
165
if ( ! b_name . startsWith ( pattern ) ) {
165
166
b_weight = 1
166
167
if ( ! b_name . includes ( pattern ) ) {
@@ -179,6 +180,14 @@ export class Launcher extends search.Search {
179
180
}
180
181
}
181
182
}
183
+ // Sort by command (exec)
184
+ if ( b_exec . includes ( pattern ) ) {
185
+ if ( b_exec . startsWith ( pattern ) {
186
+ b_weight = Math . min ( b_weight , 2 )
187
+ } else {
188
+ b_weight = Math . min ( b_weight , levenshtein . compare ( pattern , b_exec ) )
189
+ }
190
+ }
182
191
183
192
return a_weight === b_weight
184
193
? a_name . length > b_name . length ? 1 : 0
@@ -311,17 +320,6 @@ export class Launcher extends search.Search {
311
320
load_desktop_files ( ) {
312
321
lib . bench ( "load_desktop_files" , ( ) => {
313
322
this . desktop_apps . splice ( 0 ) ;
314
- for ( const [ where , path ] of SEARCH_PATHS ) {
315
- for ( const result of app_info . load_desktop_entries ( path ) ) {
316
- if ( result . kind == OK ) {
317
- const value = result . value ;
318
- this . desktop_apps . push ( [ where , value ] ) ;
319
- } else {
320
- const why = result . value ;
321
- log . warn ( why . context ( `failed to load desktop app` ) . format ( ) ) ;
322
- }
323
- }
324
- }
325
323
for ( const _path of DATA_DIRS ) {
326
324
const path = _path . replace ( / \/ $ / , '' ) + "/applications" ;
327
325
for ( const result of app_info . load_desktop_entries ( path ) ) {
0 commit comments