{
    "tailapp": 2,
    "manifest": {
        "format": 2,
        "app_id": "processes",
        "name": "Busy Processes",
        "version": 1,
        "schema": "tailapps/v0",
        "exported_at": 1796020352,
        "from": "gallery",
        "connections": [],
        "files": {
            "app.json": "192912092bcdc1df423177be9a29bf1eddbd300bb02c2a0587e876b4f82adce9"
        },
        "signature": "P3P/P3wHPe26QgdIwp/QyOv+Qt00a77mdbzj+fdP0J8gPAjlHGnCI3uTHxOsOzKcAMvaBnLo0pfqOwWlpOY3Bg==",
        "key_id": "gallery-1"
    },
    "app": {
        "schema": "tailapps/v0",
        "app": "processes",
        "name": "Busy Processes",
        "description": "The eight busiest processes on this Mac by CPU, with memory, updated every 10 seconds while the card is open. Quit one of yours in a click. Mac only.",
        "icon": "cpu",
        "version": 1,
        "permissions": [
            "script:procs.sh",
            "script:quit.sh"
        ],
        "sources": {
            "procs": {
                "script": "procs.sh",
                "every": 10,
                "on": "open"
            }
        },
        "actions": {
            "refresh": {
                "steps": [
                    {
                        "refresh": "procs"
                    }
                ]
            },
            "quit": {
                "args": {
                    "pid": "int:1-99999999",
                    "name": "text"
                },
                "confirm": "Quit {$args.name}? Unsaved work in it may be lost.",
                "steps": [
                    {
                        "script": "quit.sh",
                        "args": [
                            "$args.pid"
                        ]
                    },
                    {
                        "refresh": "procs"
                    },
                    {
                        "toast": "Asked {$args.name} to quit"
                    }
                ]
            }
        },
        "cards": [
            {
                "id": "main",
                "layout": {
                    "column": [
                        {
                            "column": [
                                {
                                    "list": "$procs",
                                    "empty": "Nothing busy right now",
                                    "item": {
                                        "cell": "$item.name",
                                        "subtitle": "CPU {$item.cpu | percent:0} \u00b7 {$item.memory | bytes}",
                                        "status": "$item.cpu | tone:{bad:'>=0.8', warn:'>=0.3', else:'neutral'}",
                                        "trailing": {
                                            "button": "Quit {$item.name}",
                                            "icon": "xmark.circle",
                                            "icon_only": true,
                                            "style": "plain",
                                            "on": "quit",
                                            "args": {
                                                "pid": "$item.pid",
                                                "name": "$item.name"
                                            },
                                            "when": "$item.mine",
                                            "disabled": "$running.quit"
                                        }
                                    }
                                }
                            ],
                            "style": "inset"
                        },
                        {
                            "text": "CPU 100% is one core. Quit asks politely (like \u2318Q), and only your own processes show the button.",
                            "size": "s",
                            "emphasis": "subtle"
                        }
                    ],
                    "gap": "m"
                },
                "footer": {
                    "row": [
                        {
                            "text": "{$procs | count} processes",
                            "size": "s",
                            "emphasis": "subtle",
                            "grow": true
                        },
                        {
                            "button": "Refresh",
                            "icon": "arrow.clockwise",
                            "icon_only": true,
                            "style": "plain",
                            "on": "refresh",
                            "disabled": "$running.refresh"
                        }
                    ],
                    "align": "center"
                }
            }
        ],
        "views": {
            "menubar": {
                "icon": "cpu",
                "label": "{$procs | pick:0 | pick:'name'}",
                "card": "main"
            },
            "floating": {
                "card": "main",
                "width": "default"
            }
        },
        "scripts": {
            "procs.sh": "#!/bin/sh\n# The busiest processes on this Mac by CPU, as JSON: [{ \"pid\", \"name\", \"cpu\" (1 = one core), \"memory\" (bytes), \"mine\" }].\n# TailApps' own process ($TAILAPPS_PID) is left out: apps can't stop TailApps.\nme=$(/usr/bin/id -u)\n/bin/ps -Aco pid=,uid=,pcpu=,rss=,comm= -r | awk -v self=\"$TAILAPPS_PID\" -v me=\"$me\" '\n  $1 != self && n < 8 {\n    pid = $1; uid = $2; cpu = $3; rss = $4\n    $1 = \"\"; $2 = \"\"; $3 = \"\"; $4 = \"\"\n    name = $0; sub(/^ +/, \"\", name); gsub(/[\"\\\\]/, \"\", name)\n    printf \"%s{\\\"pid\\\":%s,\\\"name\\\":\\\"%s\\\",\\\"cpu\\\":%s,\\\"memory\\\":%d,\\\"mine\\\":%s}\", (n++ ? \",\" : \"[\"), pid, name, cpu / 100, rss * 1024, (uid == me ? \"true\" : \"false\")\n  }\n  END { print (n ? \"]\" : \"[]\") }'\n",
            "quit.sh": "#!/bin/sh\n# Ask process $1 to quit (SIGTERM). Only your own processes; never TailApps itself.\ncase \"$1\" in ''|*[!0-9]*) echo \"Not a process id: $1\" >&2; exit 1 ;; esac\n[ \"$1\" = \"$TAILAPPS_PID\" ] && { echo \"TailApps can't be stopped from a card\" >&2; exit 1; }\nkill -TERM \"$1\"\n"
        },
        "style": {
            "accent": "#0891b2"
        }
    },
    "app_json": "{\n  \"schema\": \"tailapps/v0\",\n  \"app\": \"processes\",\n  \"name\": \"Busy Processes\",\n  \"description\": \"The eight busiest processes on this Mac by CPU, with memory, updated every 10 seconds while the card is open. Quit one of yours in a click. Mac only.\",\n  \"icon\": \"cpu\",\n  \"version\": 1,\n  \"permissions\": [\n    \"script:procs.sh\",\n    \"script:quit.sh\"\n  ],\n  \"sources\": {\n    \"procs\": {\n      \"script\": \"procs.sh\",\n      \"every\": 10,\n      \"on\": \"open\"\n    }\n  },\n  \"actions\": {\n    \"refresh\": {\n      \"steps\": [\n        {\n          \"refresh\": \"procs\"\n        }\n      ]\n    },\n    \"quit\": {\n      \"args\": {\n        \"pid\": \"int:1-99999999\",\n        \"name\": \"text\"\n      },\n      \"confirm\": \"Quit {$args.name}? Unsaved work in it may be lost.\",\n      \"steps\": [\n        {\n          \"script\": \"quit.sh\",\n          \"args\": [\n            \"$args.pid\"\n          ]\n        },\n        {\n          \"refresh\": \"procs\"\n        },\n        {\n          \"toast\": \"Asked {$args.name} to quit\"\n        }\n      ]\n    }\n  },\n  \"cards\": [\n    {\n      \"id\": \"main\",\n      \"layout\": {\n        \"column\": [\n          {\n            \"column\": [\n              {\n                \"list\": \"$procs\",\n                \"empty\": \"Nothing busy right now\",\n                \"item\": {\n                  \"cell\": \"$item.name\",\n                  \"subtitle\": \"CPU {$item.cpu | percent:0} \u00b7 {$item.memory | bytes}\",\n                  \"status\": \"$item.cpu | tone:{bad:'>=0.8', warn:'>=0.3', else:'neutral'}\",\n                  \"trailing\": {\n                    \"button\": \"Quit {$item.name}\",\n                    \"icon\": \"xmark.circle\",\n                    \"icon_only\": true,\n                    \"style\": \"plain\",\n                    \"on\": \"quit\",\n                    \"args\": {\n                      \"pid\": \"$item.pid\",\n                      \"name\": \"$item.name\"\n                    },\n                    \"when\": \"$item.mine\",\n                    \"disabled\": \"$running.quit\"\n                  }\n                }\n              }\n            ],\n            \"style\": \"inset\"\n          },\n          {\n            \"text\": \"CPU 100% is one core. Quit asks politely (like \u2318Q), and only your own processes show the button.\",\n            \"size\": \"s\",\n            \"emphasis\": \"subtle\"\n          }\n        ],\n        \"gap\": \"m\"\n      },\n      \"footer\": {\n        \"row\": [\n          {\n            \"text\": \"{$procs | count} processes\",\n            \"size\": \"s\",\n            \"emphasis\": \"subtle\",\n            \"grow\": true\n          },\n          {\n            \"button\": \"Refresh\",\n            \"icon\": \"arrow.clockwise\",\n            \"icon_only\": true,\n            \"style\": \"plain\",\n            \"on\": \"refresh\",\n            \"disabled\": \"$running.refresh\"\n          }\n        ],\n        \"align\": \"center\"\n      }\n    }\n  ],\n  \"views\": {\n    \"menubar\": {\n      \"icon\": \"cpu\",\n      \"label\": \"{$procs | pick:0 | pick:'name'}\",\n      \"card\": \"main\"\n    },\n    \"floating\": {\n      \"card\": \"main\",\n      \"width\": \"default\"\n    }\n  },\n  \"scripts\": {\n    \"procs.sh\": \"#!/bin/sh\\n# The busiest processes on this Mac by CPU, as JSON: [{ \\\"pid\\\", \\\"name\\\", \\\"cpu\\\" (1 = one core), \\\"memory\\\" (bytes), \\\"mine\\\" }].\\n# TailApps' own process ($TAILAPPS_PID) is left out: apps can't stop TailApps.\\nme=$(/usr/bin/id -u)\\n/bin/ps -Aco pid=,uid=,pcpu=,rss=,comm= -r | awk -v self=\\\"$TAILAPPS_PID\\\" -v me=\\\"$me\\\" '\\n  $1 != self && n < 8 {\\n    pid = $1; uid = $2; cpu = $3; rss = $4\\n    $1 = \\\"\\\"; $2 = \\\"\\\"; $3 = \\\"\\\"; $4 = \\\"\\\"\\n    name = $0; sub(/^ +/, \\\"\\\", name); gsub(/[\\\"\\\\\\\\]/, \\\"\\\", name)\\n    printf \\\"%s{\\\\\\\"pid\\\\\\\":%s,\\\\\\\"name\\\\\\\":\\\\\\\"%s\\\\\\\",\\\\\\\"cpu\\\\\\\":%s,\\\\\\\"memory\\\\\\\":%d,\\\\\\\"mine\\\\\\\":%s}\\\", (n++ ? \\\",\\\" : \\\"[\\\"), pid, name, cpu / 100, rss * 1024, (uid == me ? \\\"true\\\" : \\\"false\\\")\\n  }\\n  END { print (n ? \\\"]\\\" : \\\"[]\\\") }'\\n\",\n    \"quit.sh\": \"#!/bin/sh\\n# Ask process $1 to quit (SIGTERM). Only your own processes; never TailApps itself.\\ncase \\\"$1\\\" in ''|*[!0-9]*) echo \\\"Not a process id: $1\\\" >&2; exit 1 ;; esac\\n[ \\\"$1\\\" = \\\"$TAILAPPS_PID\\\" ] && { echo \\\"TailApps can't be stopped from a card\\\" >&2; exit 1; }\\nkill -TERM \\\"$1\\\"\\n\"\n  },\n  \"style\": {\n    \"accent\": \"#0891b2\"\n  }\n}\n",
    "files": []
}