7
7
import { app , NativeImage , nativeImage } from "electron" ;
8
8
import { join } from "path" ;
9
9
import { BADGE_DIR } from "shared/paths" ;
10
- import { exec } from "child_process" ;
10
+ import { execFile } from "child_process" ;
11
11
12
12
const imgCache = new Map < number , NativeImage > ( ) ;
13
13
function loadBadge ( index : number ) {
@@ -25,18 +25,31 @@ let lastIndex: null | number = -1;
25
25
export function setBadgeCount ( count : number ) {
26
26
switch ( process . platform ) {
27
27
case "linux" :
28
- if ( count === - 1 ) count = 0 ;
29
- // app.setBadgeCount(count);
28
+ if ( typeof count !== "number" ) { //sanitize
29
+ console . log ( "what the hel- *kaboom*" )
30
+ break ;
31
+ }
30
32
31
33
function emitDBusBadge ( count : number , visible : boolean ) {
32
- const badgeCountCommand = `gdbus emit --session --object-path / --signal com.canonical.Unity.LauncherEntry.Update "application://vesktop.desktop" "{'count': <int64 ${ count } >, 'count-visible': <${ visible } >}"` ;
33
- exec ( badgeCountCommand )
34
+ execFile ( "gdbus" , [
35
+ "emit" ,
36
+ "--session" ,
37
+ "--object-path" ,
38
+ "/" ,
39
+ "--signal" ,
40
+ "com.canonical.Unity.LauncherEntry.Update" ,
41
+ "application://vesktop.desktop" ,
42
+ `{\'count\': <int64 ${ count } >, \'count-visible\': <${ visible } >}`
43
+ ] ) ;
34
44
}
35
-
36
45
if ( count === 0 ) {
37
46
emitDBusBadge ( count , false ) ;
38
47
break ;
39
48
}
49
+ if ( count === - 1 ) {
50
+ emitDBusBadge ( 0 , true ) ;
51
+ break ;
52
+ }
40
53
emitDBusBadge ( count , true ) ;
41
54
break ;
42
55
case "darwin" :
0 commit comments