본문 바로가기
# 애플 [Apple]/macOS

[🍎 macOS] 애플 스크립트를 통한 AirDrop 통제 (Controlling AirDrop through AppleScript)

by cy_mos 2023. 9. 25.
반응형

애플 스크립트 (AppleScript) 사용하여 AirDrop을 통제하는 방법은 아래와 같습니다.

 

#!/usr/bin/osascript

# Copyright (c) 2023 ChangYeop-Yang. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

on run parameters
	
	set type to item 1 of parameters
	
	if type is "SET" then
		# AirDrop을 활성화 또는 비활성화 합니다.
		set status to item 2 of parameters
		do shell script "/usr/bin/defaults write com.apple.NetworkBrowser DisableAirDrop -bool " & status
	else if type is "GET" then
		# 현재 AirDrop 상태 여부를 확인합니다.
		set result to do shell script "/usr/bin/defaults read com.apple.NetworkBrowser DisableAirDrop"
		return result
	end if
	
end run

🚀 REFERENCE

반응형

댓글