[update] support dump specified bundle id

This commit is contained in:
AloneMonkey
2018-01-30 14:01:59 +08:00
parent 33c4ac14c4
commit fd88a4818c
2 changed files with 180 additions and 30 deletions

25
app.js
View File

@@ -20,12 +20,33 @@ function getbundleid(name){
return ""
};
function getdisplayname(bundleid){
const workspace = LSApplicationWorkspace.defaultWorkspace();
const apps = workspace.allApplications();
var result;
for(var index = 0; index < apps.count(); index++){
var proxy = apps.objectAtIndex_(index);
if(proxy.bundleIdentifier() && proxy.bundleIdentifier().toString() == bundleid){
return proxy.localizedName().toString();
}
}
return ""
}
function handleMessage(message) {
const bundleid = getbundleid(message);
var bundleid;
var displayname;
if(message['name']){
displayname = message['name']
bundleid = getbundleid(displayname);
}else if(message['bundleid']){
bundleid = message['bundleid']
displayname = getdisplayname(bundleid);
}
if(bundleid.length > 0){
openApplication(bundleid);
}
send({opened: "ok"});
send({ opened: displayname });
}
recv(handleMessage);