MCPcopy Create free account
hub / github.com/HELPMEEADICE/doge-code / listRunning

Function listRunning

src/utils/computerUse/platforms/linux.ts:270–319  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

268
269const apps: AppsPlatform = {
270 listRunning(): WindowHandle[] {
271 try {
272 if (commandExists('wmctrl')) {
273 const raw = run(['wmctrl', '-l', '-p'])
274 const handles: WindowHandle[] = []
275 for (const line of raw.split('\n').filter(Boolean)) {
276 const parts = line.split(/\s+/)
277 const windowId = parts[0]
278 const pid = Number(parts[2])
279 if (!pid) continue
280
281 // Title is everything after the 4th field (hostname)
282 const title = parts.slice(4).join(' ')
283
284 let exePath = ''
285 try { exePath = run(['readlink', '-f', `/proc/${pid}/exe`]) } catch {}
286
287 handles.push({
288 id: windowId ?? '',
289 pid,
290 title,
291 exePath: exePath || undefined,
292 })
293 }
294
295 // Deduplicate by id
296 const seen = new Set<string>()
297 return handles.filter(h => {
298 if (seen.has(h.id)) return false
299 seen.add(h.id)
300 return true
301 }).slice(0, 50)
302 }
303
304 // Fallback: xdotool search
305 const raw = run(['xdotool', 'search', '--name', ''])
306 const handles: WindowHandle[] = []
307 for (const windowId of raw.split('\n').filter(Boolean).slice(0, 50)) {
308 const title = run(['xdotool', 'getwindowname', windowId])
309 let pid = 0
310 try { pid = Number(run(['xdotool', 'getwindowpid', windowId])) } catch {}
311 if (title) {
312 handles.push({ id: windowId, pid, title })
313 }
314 }
315 return handles
316 } catch {
317 return []
318 }
319 },
320
321 async listInstalled(): Promise<InstalledApp[]> {
322 try {

Callers

nothing calls this directly

Calls 4

commandExistsFunction · 0.85
runFunction · 0.70
hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected