Skip to content

Commit f83d382

Browse files
committed
Send array to ExecUtil.exec now that it can wrapTokens itself.
1 parent 4b299a7 commit f83d382

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

package/contents/ui/NotificationManager.qml

+12-19
Original file line numberDiff line numberDiff line change
@@ -36,42 +36,35 @@ QtObject {
3636

3737
property var executable: ExecUtil { id: executable }
3838

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-
}
4939
function notify(args, callback) {
5040
logger.debugJSON('NotificationMananger.notify', args)
5141
args.sound = args.sound || args.soundFile
5242

53-
var cmd = 'python3' + ' ' + wrapToken(plasmoid.file("", "scripts/notification.py"))
43+
var cmd = [
44+
'python3',
45+
plasmoid.file("", "scripts/notification.py"),
46+
]
5447
if (args.appName) {
55-
cmd += formatArg('--app-name', args.appName)
48+
cmd.push('--app-name', args.appName)
5649
}
5750
if (args.appIcon) {
58-
cmd += formatArg('--icon', args.appIcon)
51+
cmd.push('--icon', args.appIcon)
5952
}
6053
if (args.sound) {
61-
cmd += formatArg('--sound', args.sound)
54+
cmd.push('--sound', args.sound)
6255
if (args.loop) {
63-
cmd += formatArg('--loop', args.loop)
56+
cmd.push('--loop', args.loop)
6457
}
6558
}
6659
if (args.actions) {
6760
for (var i = 0; i < args.actions.length; i++) {
6861
var action = args.actions[i]
69-
cmd += formatArg('--action', action)
62+
cmd.push('--action', action)
7063
}
7164
}
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)
7568
executable.exec(cmd, function(cmd, exitCode, exitStatus, stdout, stderr) {
7669
var actionId = stdout.replace('\n', ' ').trim()
7770
callback(actionId)

0 commit comments

Comments
 (0)