跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

register-macos-clipboard.sh

36 行 · 1.7 KB历史下载
1#!/bin/bash
2# Register only the intended guest user's private socket-activated GUI agent.
3set -euo pipefail
4export PATH=/usr/bin:/bin:/usr/sbin:/sbin
5[[ $(sysctl -n hw.model) =~ ^VirtualMac[0-9]+,[0-9]+$ && $(cat /var/db/cage-guest-os) == macos ]] || exit 2
6[[ $# == 0 || ( $# == 1 && $1 == --prepare ) ]] || exit 2
7uid=$(id -u)
8[[ $uid -ge 500 && ( ${1:-} == --prepare || $(stat -f %u /dev/console) == "$uid" ) ]] || { echo 'Log into the guest as the intended desktop user.' >&2; exit 4; }
9app='/Applications/Cage Guest Clipboard.app'
10codesign --verify --deep --strict -R '=identifier "dev.cage.GuestClipboard"' "$app"
11label=dev.cage.GuestClipboard
12cache="$HOME/Library/Caches/$label"
13agent="$HOME/Library/LaunchAgents/$label.plist"
14umask 077
15mkdir -p "$HOME/Library/LaunchAgents" "$cache"
16[[ ! -L $cache && $(stat -f %u "$cache") == "$uid" ]] || exit 2
17chmod 700 "$cache"
18temp=$(mktemp "$cache/plist.XXXXXXXX")
19trap 'rm -f "$temp"' EXIT
20plutil -create xml1 "$temp"
21plutil -insert Label -string "$label" "$temp"
22plutil -insert ProgramArguments -xml '<array/>' "$temp"
23plutil -insert ProgramArguments.0 -string "$app/Contents/MacOS/CageGuestClipboard" "$temp"
24plutil -insert LimitLoadToSessionType -string Aqua "$temp"
25plutil -insert Sockets -xml '<dict><key>Clipboard</key><dict/></dict>' "$temp"
26plutil -insert Sockets.Clipboard.SockPathName -string "$cache/clipboard.sock" "$temp"
27plutil -insert Sockets.Clipboard.SockPathMode -integer 384 "$temp"
28if [[ -f $agent ]] && ! cmp -s "$agent" "$temp"; then
29 echo 'An existing clipboard LaunchAgent has different settings.' >&2
30 exit 2
31fi
32mv -f "$temp" "$agent"
33[[ ${1:-} == --prepare ]] && exit 0
34if ! launchctl print "gui/$uid/$label" >/dev/null 2>&1; then
35 launchctl bootstrap "gui/$uid" "$agent"
36fi