【applescript】coreaudiodの再起動
【スクリプトエディタで開く】 |
コアオーディオ再起動.scpt | ソース |
|---|
| 001 | #!/usr/bin/env osascript |
| 002 | #coding: utf-8 |
| 003 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7-- |
| 004 | (* |
| 005 | コアオーディオ再起動 |
| 006 | com.cocolog-nifty.quicktimer.icefloe *) |
| 007 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7-- |
| 008 | use AppleScript version "2.8" |
| 009 | use scripting additions |
| 010 | property refMe : a reference to current application |
| 011 | #OSのバージョン取得 |
| 012 | set recordSystemInfo to (system info) as record |
| 013 | set strOsVersion to (system version of recordSystemInfo) as text |
| 014 | #メジャーバージョンとマイナーバージョンを分離 |
| 015 | set strDelim to AppleScript's text item delimiters |
| 016 | set AppleScript's text item delimiters to (".") |
| 017 | set listVersion to every text item of strOsVersion |
| 018 | set AppleScript's text item delimiters to strDelim |
| 019 | #バージョンを数値で定義して |
| 020 | set numVerMaj to (first item of listVersion) as integer |
| 021 | set numVerMim to (second item of listVersion) as integer |
| 022 | #OSのバージョンで処理を分岐 |
| 023 | if numVerMaj < 14 then |
| 024 | set strCmd to ("/usr/bin/sudo /bin/launchctl kickstart -kp system/com.apple.audio.coreaudiod") as text |
| 025 | do shell script strCmd |
| 026 | |
| 027 | else if (numVerMaj = 14) and (numVerMim < 4) then |
| 028 | set strCmd to ("/usr/bin/sudo /bin/launchctl kickstart -kp system/com.apple.audio.coreaudiod") as text |
| 029 | do shell script strCmd |
| 030 | else if (numVerMaj = 14) and (numVerMim < 6) then |
| 031 | set strCmd to ("/usr/bin/sudo /usr/bin/killall coreaudiod") as text |
| 032 | do shell script strCmd |
| 033 | end if |
| 034 | #共通処理 |
| 035 | delay 5 |
| 036 | set strCmd to ("/usr/bin/sudo /usr/bin/killall coreaudiod") as text |
| 037 | do shell script strCmd |
| 038 | return |
| AppleScriptで生成しました |
|---|