Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

212
Views
electronJS / Detectar si se está ejecutando una aplicación externa (MacOS) (Sandbox) (MAS)

¿Es posible detectar en electronJS si se están ejecutando aplicaciones específicas en MacOS ?

Quiero verificar, si Mail.app está abierta y es importante, que el código funciona en Mac Apple Store (MAS) en modo Sandbox .

En AppKit es posible con var runningApplications: [NSRunningApplication] { get } https://developer.apple.com/documentation/appkit/nsworkspace/1534059-runningapplications

Escribí un código que funciona, pero no en Sandbox, los comandos de terminal no son posibles:

 import { exec } from "child_process"; ... isRunning(query: string): Promise<unknown> { return new Promise((resolve, reject) => { const cmd = `ps aux | grep "${query}" | grep -v grep`; exec(cmd, (err, stdout, stderr) => { if (stderr) { reject(stderr); return false; } const lines = stdout.split("\n"); let active = null; let pid = null; for (let index = 0; index < lines.length; index++) { const line = lines[index]; if ( line.indexOf(query) !== -1 && line.indexOf(USERNAME) !== -1 ) { active = line; break; } } if (active) { const activeData = active.replace(/(\s+)/g, '\t').split('\t'); pid = activeData.length > 2 ? activeData[1] : null; } resolve(pid); }); }); } this.isRunning('Mail.app/Contents/MacOS/Mail').then(pid => { if (pid) { // kill the app? 😉 } else { resolve(null); } }, reject);

¿Alguien tiene una mejor solución para electronJS que funcione en MAS Sandbox?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Encontré una solución para ello:

 const script = ` if application "Mail" is running then copy "true" to stdout else copy "false" to stdout end if `; exec(`osascript -e '${script}'`, (err, stdout, stderr) => { if (stderr) {console.log("error", stderr); return;} console.log("stdout", stdout); });
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!