はじめに
Raycast(Spotlight検索ライクなアプリ)を使用し、好きなショートカットを作ります。
実行手順は以下です。
-
applescript
ファイルを作成 -
sh
ファイルからapplescript
を呼び出し実行 - ショートカット設定
1. applescript
ファイルを作成
今回は、Raycastを使用しapplescript
ファイルを作成します。
音量調整機能を作成します。
1. Extentions から+ をクリック |
2. Create Script Command をクリック |
3. 以下を入力Template :Apple Script その他の入力は任意 Create Script をクリック→Save
|
4. 右クリック→Open
|
5. コードを下記に書き換え |
before
#!/usr/bin/osascript
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title decrease_volume_with_popup
# @raycast.mode compact
# Optional parameters:
# @raycast.icon 🤖
# @raycast.packageName Volume Control
log "Hello World!"
after
#!/usr/bin/osascript
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title increase_volume_with_popup
# @raycast.mode compact
# Optional parameters:
# @raycast.icon 🔉
# @raycast.packageName Volume Control
set currentVolume to output volume of (get volume settings)
if currentVolume > 0 then
set volume output volume (currentVolume - 5)
end if
set newVolume to output volume of (get volume settings)
display notification "Current volume: " & newVolume
2. sh
ファイルからapplescript
を呼び出し実行
1. Extentions から+ をクリック |
2. Create Script Command をクリック |
3. 以下を入力Template :Bash その他の入力は任意 Create Script をクリック→Save
|
4. 右クリック→Open
|
5. コードを下記に書き換え |
before
#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title decrease_volume_with_popup_exe
# @raycast.mode compact
# Optional parameters:
# @raycast.icon 🤖
# @raycast.packageName Volume Control
# Documentation:
# @raycast.description 実行ファイル
echo "Hello World!"
after
#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title decrease_volume_with_popup_exe
# @raycast.mode compact
# Optional parameters:
# @raycast.icon 🔉
# @raycast.packageName Volume Control
# Documentation:
# @raycast.description 実行ファイル
osascript "your/path"
3. ショートカット設定
完成!
新しい機能を作成し、ショートカットを設定することができました。
追記
increase_volume_with_popup
も同様に設定します。
コード
#!/usr/bin/osascript
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title increase_volume_with_popup
# @raycast.mode compact
# Optional parameters:
# @raycast.icon 🔊
# @raycast.packageName Volume Control
set currentVolume to output volume of (get volume settings)
if currentVolume < 100 then
set volume output volume (currentVolume + 5)
end if
set newVolume to output volume of (get volume settings)
display notification "Current volume: " & newVolume
補足
applescript
を直接実行できなかった(エラーが発生した)ため、sh
を挟んでいます。
sh
(osascript
)を挟まずに設定できる方法をご存じの方は教えて下さい