get-open-apps
Advanced tools
Comparing version 1.0.7 to 1.0.8
23
index.js
@@ -33,3 +33,3 @@ module.exports = async function(opt) { | ||
let appsOpen = []; | ||
let processes = await ps({ | ||
let appCmds = await ps({ | ||
command: '', | ||
@@ -39,5 +39,6 @@ arguments: '' | ||
if (opt.v) { | ||
log(processes); | ||
log(appCmds); | ||
} | ||
let regex; | ||
let elims; | ||
if (mac) { | ||
@@ -47,8 +48,18 @@ regex = /(?:\/Applications)(?:\/[^\/\.]*\/|\/)*(?:([^\.]+)\.app)/; | ||
regex = /(?:(?:\/(?:snap|usr\/bin)\/)([^\/]+)|(?:\/[^\/\.]*\/)*([^\/\.]+)\.AppImage)/; | ||
elims = /(dbus|gnome|pulseaudio|seahorse|ssh)/; | ||
} | ||
for (let i = 0; i < processes.length; i++) { | ||
let process = processes[i].command; | ||
let app = process.match(regex); | ||
for (let i = 0; i < appCmds.length; i++) { | ||
let appCmd = appCmds[i].command; | ||
let app = appCmd.match(regex); | ||
if (app && !appsOpen[app[1]]) { | ||
appsOpen[app[1]] = process; | ||
if (elims && elims.test(appCmd)) { | ||
continue; | ||
} | ||
if (linux && (/\/snap\//).test(appCmd)) { | ||
appCmd = appCmd.split('/'); | ||
appCmd = [appCmd[1], 'run', appCmd[2]]; | ||
} else { | ||
appCmd = [appCmd]; | ||
} | ||
appsOpen[app[1]] = appCmd; | ||
} | ||
@@ -55,0 +66,0 @@ } |
@@ -29,3 +29,3 @@ { | ||
}, | ||
"version": "1.0.7" | ||
"version": "1.0.8" | ||
} |
8440
168