Giter Club home page Giter Club logo

macmini2ipad's Introduction

ipad + mac mini 自动随航

Feature

sidecar:

  • 通过 sidecar 脚本,实现 mac mini 自动随航连接到 ipad(镜像模式)
  • 通过 run_sidecar 脚本,实现判断当前是否已经连接到 ipad,实现 连接/断开 可配置,且断开后可以自动重连
  • 通过 run 脚本,实现对 run_sidecar 脚本的监控,实现脚本可重入

local_svr:

  • 启动web服务,实现在局域网内通过 web 页面上触发连接/断开
  • 通过 run 脚本,实现对 main 脚本的监控,实现脚本可重入

crontab : 最后用 crontab,保障 local_svr 是启动的

* * * * * sh /path/to/local_svr/run.sh 

效果

  • 在 ipad 上就可以触发连接或者断开连接,不需要事先连接到 mac mini
  • ipad 断开后,可以自动重连
  • mac mini 只需要确保电脑开启,即使电脑在锁屏登录界面,也可以自动连接

需要配置

ipad + mac mini + 蓝牙键盘(带触控板) ipad + mac mini + 妙控键盘 + 蓝牙鼠标

MacOS:

  • 使用sidecar脚本 sidecar.applescript 替换其中的 XXX‘s iPad 为自己的设备名称,注意 操作符
set targetIndex to (my findLastTargetIndex("XXX‘s iPad", menuItems))
  • ventura 13.6 (使用sidecar脚本 sidecar_13_6.applescript)
  • sonoma 14.4.1 (使用sidecar脚本 sidecar_14_4.applescript)

前提条件

mac mini 开启 + ipad & mac mini 在同一局域网

macmini2ipad's People

Stargazers

 avatar Bo Pang avatar  avatar  avatar  avatar

Watchers

Corey avatar

macmini2ipad's Issues

解决键盘低延迟问题

其实很简单,我亲测有效,那就是把第三方键盘通过蓝牙连接到ipad上,这样延迟和妙控键盘效果一样

通过设备名称去搜索ipad,替换固定索引方式14.4脚本

on findLastTargetIndex(targetItem, itemList)
	set lastIndex to 0
	repeat with i from (count of itemList) to 1 by -1
		if item i of itemList is targetItem then
			set lastIndex to i
			exit repeat
		end if
	end repeat
	return lastIndex
end findLastTargetIndex

beep 1
beep 1
tell application "System Settings"
	activate
	delay 1
	tell application "System Events"
		tell process "System Settings"
			click menu item "显示器" of menu "显示" of menu bar item "显示" of menu bar 1
			delay 0.3
			tell group 1 of group 2 of splitter group 1 of group 1 of window "显示器"
				try
					click pop up button "添加"
					delay 0.3
					-- 获取所有菜单项的名称
					set menuItems to name of menu items of menu "添加" of pop up button "添加"
					-- 通过名字查找要准确一些,这里去找最后一个名字的索引,因为如果ipadpro有妙控键盘,就会出现两个名字,我们需要最后一个名字,第一个名字是连接键鼠的
					set targetIndex to (my findLastTargetIndex("iPad", menuItems))
					
					-- 点击目标菜单项
					click menu item targetIndex of menu "添加" of pop up button "添加"
				on error
					delay 0.5
				end try
			end tell
		end tell
	end tell
end tell
delay 1
beep 1
tell application "System Settings" to quit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.