mirror of
https://github.com/davatorium/rofi.git
synced 2025-02-10 15:44:41 -05:00
filter out favorites from final result list.
This commit is contained in:
parent
7d34222234
commit
3c0a96680c
2 changed files with 15 additions and 3 deletions
2
Makefile
2
Makefile
|
@ -1,4 +1,4 @@
|
||||||
CFLAGS?=-Wall -Wextra -Os
|
CFLAGS?=-Wall -Wextra -O3
|
||||||
PREFIX?=$(DESTDIR)/usr
|
PREFIX?=$(DESTDIR)/usr
|
||||||
BINDIR?=$(PREFIX)/bin
|
BINDIR?=$(PREFIX)/bin
|
||||||
MANDIR?=$(PREFIX)/share/man/man1
|
MANDIR?=$(PREFIX)/share/man/man1
|
||||||
|
|
|
@ -238,6 +238,10 @@ static pid_t exec_cmd( char *cmd, int run_in_term )
|
||||||
|
|
||||||
if ( hd == NULL ) return pid;
|
if ( hd == NULL ) return pid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This happens in non-critical time (After launching app)
|
||||||
|
* It is allowed to be a bit slower.
|
||||||
|
*/
|
||||||
char *path = allocate( strlen( hd ) + strlen( "/.simpleswitcher.cache" )+2 );
|
char *path = allocate( strlen( hd ) + strlen( "/.simpleswitcher.cache" )+2 );
|
||||||
sprintf( path, "%s/%s", hd, ".simpleswitcher.cache" );
|
sprintf( path, "%s/%s", hd, ".simpleswitcher.cache" );
|
||||||
FILE *fd = fopen ( path, "r" );
|
FILE *fd = fopen ( path, "r" );
|
||||||
|
@ -259,7 +263,9 @@ static pid_t exec_cmd( char *cmd, int run_in_term )
|
||||||
|
|
||||||
fclose( fd );
|
fclose( fd );
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Write out the last 25 results again.
|
||||||
|
*/
|
||||||
fd = fopen ( path, "w" );
|
fd = fopen ( path, "w" );
|
||||||
|
|
||||||
if ( fd ) {
|
if ( fd ) {
|
||||||
|
@ -1151,7 +1157,13 @@ static char ** get_apps ( )
|
||||||
dent->d_type != DT_UNKNOWN ) {
|
dent->d_type != DT_UNKNOWN ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
int found = 0;
|
||||||
|
// This is a nice little penalty, but doable? time will tell.
|
||||||
|
// given num_favorites is max 25.
|
||||||
|
for(int j = 0; found == 0 && j < num_favorites; j++) {
|
||||||
|
if(strcasecmp(dent->d_name, retv[j]) == 0) found = 1;
|
||||||
|
}
|
||||||
|
if(found == 1) continue;
|
||||||
retv = realloc( retv, ( index+2 )*sizeof( char* ) );
|
retv = realloc( retv, ( index+2 )*sizeof( char* ) );
|
||||||
retv[index] = strdup( dent->d_name );
|
retv[index] = strdup( dent->d_name );
|
||||||
retv[index+1] = NULL;
|
retv[index+1] = NULL;
|
||||||
|
|
Loading…
Add table
Reference in a new issue