@@ -36,42 +36,35 @@ QtObject {
36
36
37
37
property var executable: ExecUtil { id: executable }
38
38
39
- function wrapToken (token ) {
40
- token = " " + token
41
- // ' => '"'"' to escape the single quotes
42
- token = token .replace (" \' " , " \'\"\'\"\' " )
43
- token = " \' " + token + " \' "
44
- return token
45
- }
46
- function formatArg (name , value ) {
47
- return ' ' + name + ' ' + wrapToken (value)
48
- }
49
39
function notify (args , callback ) {
50
40
logger .debugJSON (' NotificationMananger.notify' , args)
51
41
args .sound = args .sound || args .soundFile
52
42
53
- var cmd = ' python3' + ' ' + wrapToken (plasmoid .file (" " , " scripts/notification.py" ))
43
+ var cmd = [
44
+ ' python3' ,
45
+ plasmoid .file (" " , " scripts/notification.py" ),
46
+ ]
54
47
if (args .appName ) {
55
- cmd += formatArg (' --app-name' , args .appName )
48
+ cmd . push (' --app-name' , args .appName )
56
49
}
57
50
if (args .appIcon ) {
58
- cmd += formatArg (' --icon' , args .appIcon )
51
+ cmd . push (' --icon' , args .appIcon )
59
52
}
60
53
if (args .sound ) {
61
- cmd += formatArg (' --sound' , args .sound )
54
+ cmd . push (' --sound' , args .sound )
62
55
if (args .loop ) {
63
- cmd += formatArg (' --loop' , args .loop )
56
+ cmd . push (' --loop' , args .loop )
64
57
}
65
58
}
66
59
if (args .actions ) {
67
60
for (var i = 0 ; i < args .actions .length ; i++ ) {
68
61
var action = args .actions [i]
69
- cmd += formatArg (' --action' , action)
62
+ cmd . push (' --action' , action)
70
63
}
71
64
}
72
- cmd += formatArg (' --metadata' , " " + Date .now () + " $(notify-send escape1) \' ; notify-send escape2 " ) // Make sure cmd is unique.
73
- cmd += ' ' + wrapToken (args .summary )
74
- cmd += ' ' + wrapToken (args .body )
65
+ cmd . push (' --metadata' , ' ' + Date .now ())
66
+ cmd . push (args .summary )
67
+ cmd . push (args .body )
75
68
executable .exec (cmd, function (cmd , exitCode , exitStatus , stdout , stderr ) {
76
69
var actionId = stdout .replace (' \n ' , ' ' ).trim ()
77
70
callback (actionId)
0 commit comments