{
  "version": 2,
  "name": "Network",
  "description": "IP addresses, Wi-Fi, DNS and connectivity checks.",
  "categories": [
    {
      "id": "network",
      "name": "Network",
      "sortOrder": 0,
      "iconSymbolName": "network",
      "showAtTopLevel": false,
      "items": [
        {
          "id": "network-internal-ip",
          "title": "Show/Copy Internal IP",
          "isEnabled": true,
          "command": {
            "type": "Shell Command",
            "value": "ifconfig | grep 'inet ' | grep -v 127.0.0.1 | awk '{print $2}' | head -1",
            "runInBackground": true,
            "showNotification": true,
            "copyToClipboard": true,
            "openInTerminal": false
          },
          "confirmBeforeRunning": false,
          "isSeparator": false,
          "iconSymbolName": "house"
        },
        {
          "id": "network-external-ip",
          "title": "Show/Copy External IP",
          "isEnabled": true,
          "command": {
            "type": "Shell Command",
            "value": "curl --no-progress-meter --max-time 10 https://ipinfo.io/ip",
            "runInBackground": true,
            "showNotification": true,
            "copyToClipboard": true,
            "openInTerminal": false
          },
          "confirmBeforeRunning": false,
          "isSeparator": false,
          "iconSymbolName": "globe"
        },
        {
          "id": "network-wifi-name",
          "title": "Show/Copy Wi-Fi Network Name",
          "isEnabled": true,
          "command": {
            "type": "Shell Command",
            "value": "dev=$(networksetup -listallhardwareports | awk '/Wi-Fi/{getline; print $2}'); name=$(ipconfig getsummary $dev 2>/dev/null | awk -F' SSID : ' '/ SSID : /{print $2}'); [ -z \"$name\" ] && name=$(networksetup -getairportnetwork $dev | sed 's/^Current Wi-Fi Network: //'); echo \"$name\"",
            "runInBackground": true,
            "showNotification": true,
            "copyToClipboard": true,
            "openInTerminal": false
          },
          "confirmBeforeRunning": false,
          "isSeparator": false,
          "iconSymbolName": "wifi"
        },
        {
          "id": "network-dns-servers",
          "title": "Show DNS Servers",
          "isEnabled": true,
          "command": {
            "type": "Shell Command",
            "value": "scutil --dns | awk '/nameserver\\[[0-9]+\\]/{print $3}' | sort -u | tr '\\n' ' '",
            "runInBackground": true,
            "showNotification": true,
            "copyToClipboard": false,
            "openInTerminal": false
          },
          "confirmBeforeRunning": false,
          "isSeparator": false,
          "iconSymbolName": "server.rack"
        },
        {
          "id": "network-ping",
          "title": "Ping Test",
          "isEnabled": true,
          "command": {
            "type": "Shell Command",
            "value": "ping -c 3 -t 5 1.1.1.1 | tail -1 | awk -F'/' '{print \"Average \" $5 \" ms to 1.1.1.1\"}'",
            "runInBackground": true,
            "showNotification": true,
            "copyToClipboard": false,
            "openInTerminal": false
          },
          "confirmBeforeRunning": false,
          "isSeparator": false,
          "iconSymbolName": "waveform.path.ecg"
        },
        {
          "id": "network-listening-ports",
          "title": "Show Listening Ports",
          "isEnabled": true,
          "command": {
            "type": "Shell Command",
            "value": "lsof -nP -iTCP -sTCP:LISTEN | awk 'NR>1 {print $1, $9}' | sort -u",
            "runInBackground": true,
            "showNotification": false,
            "copyToClipboard": false,
            "openInTerminal": true
          },
          "confirmBeforeRunning": false,
          "isSeparator": false,
          "iconSymbolName": "list.bullet.rectangle"
        },
        {
          "id": "network-sep-1",
          "title": "",
          "isEnabled": true,
          "isSeparator": true,
          "command": {
            "type": "Shell Command",
            "value": "",
            "runInBackground": true,
            "showNotification": false,
            "copyToClipboard": false,
            "openInTerminal": false
          },
          "confirmBeforeRunning": false
        },
        {
          "id": "network-toggle-wifi",
          "title": "Toggle Wi-Fi",
          "isEnabled": true,
          "command": {
            "type": "Shell Command",
            "value": "dev=$(networksetup -listallhardwareports | awk '/Wi-Fi/{getline; print $2}'); if [ \"$(networksetup -getairportpower $dev | awk '{print $NF}')\" = \"On\" ]; then networksetup -setairportpower $dev off; else networksetup -setairportpower $dev on; fi",
            "runInBackground": true,
            "showNotification": false,
            "copyToClipboard": false,
            "openInTerminal": false
          },
          "confirmBeforeRunning": false,
          "isSeparator": false,
          "iconSymbolName": "wifi.slash"
        },
        {
          "id": "network-restart-wifi",
          "title": "Restart Wi-Fi",
          "isEnabled": true,
          "command": {
            "type": "Shell Command",
            "value": "dev=$(networksetup -listallhardwareports | awk '/Wi-Fi/{getline; print $2}'); networksetup -setairportpower $dev off; sleep 2; networksetup -setairportpower $dev on",
            "runInBackground": true,
            "showNotification": false,
            "copyToClipboard": false,
            "openInTerminal": false
          },
          "confirmBeforeRunning": false,
          "isSeparator": false,
          "iconSymbolName": "arrow.clockwise"
        },
        {
          "id": "network-flush-dns",
          "title": "Flush DNS Cache",
          "isEnabled": true,
          "command": {
            "type": "AppleScript",
            "value": "do shell script \"dscacheutil -flushcache; killall -HUP mDNSResponder\" with administrator privileges",
            "runInBackground": true,
            "showNotification": true,
            "copyToClipboard": false,
            "openInTerminal": false
          },
          "confirmBeforeRunning": false,
          "isSeparator": false,
          "iconSymbolName": "trash"
        }
      ]
    }
  ]
}
