0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

はじめに

Raycast(Spotlight検索ライクなアプリ)を使用し、好きなショートカットを作ります。

実行手順は以下です。

  1. applescriptファイルを作成
  2. shファイルからapplescriptを呼び出し実行
  3. ショートカット設定

1. applescriptファイルを作成

今回は、Raycastを使用しapplescriptファイルを作成します。

音量調整機能を作成します。

スクリーンショット 2024-07-14 12.57.04.png スクリーンショット 2024-07-14 12.58.46.png
1. Extentionsから+をクリック 2. Create Script Commandをクリック
スクリーンショット 2024-07-14 13.04.59.png スクリーンショット 2024-07-14 13.11.18.png
3. 以下を入力
TemplateApple 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を呼び出し実行

スクリーンショット 2024-07-14 12.57.04.png スクリーンショット 2024-07-14 12.58.46.png
1. Extentionsから+をクリック 2. Create Script Commandをクリック
スクリーンショット 2024-07-14 18.40.26.png スクリーンショット 2024-07-14 13.11.18.png
3. 以下を入力
TemplateBash
その他の入力は任意

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"
pathの取得方法

Finderから「パス名のコピー」で取得可能です。直接貼り付けてください
スクリーンショット 2024-07-14 18.48.26.png

3. ショートカット設定

スクリーンショット 2024-07-14 18.52.35.png

完成!

新しい機能を作成し、ショートカットを設定することができました。

追記

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を挟んでいます。

shosascript)を挟まずに設定できる方法をご存じの方は教えて下さい

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?