From 0713879f9700a8a2e8d2bfd96deeae3330dc03ea Mon Sep 17 00:00:00 2001 From: gongdewei Date: Fri, 5 Sep 2025 18:46:03 +0800 Subject: [PATCH] feat: add get_volume function to system category --- src/categories/system.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/categories/system.ts b/src/categories/system.ts index 867e1de..3893af0 100644 --- a/src/categories/system.ts +++ b/src/categories/system.ts @@ -3,6 +3,7 @@ import { ScriptCategory } from "../types/index.js"; /** * System-related scripts. * * volume: Set system volume + * * get_volume: Get current system volume * * get_frontmost_app: Get the name of the frontmost application * * launch_app: Launch an application * * quit_app: Quit an application @@ -28,6 +29,19 @@ export const systemCategory: ScriptCategory = { }, script: (args) => `set volume ${Math.round((args.level / 100) * 7)}`, }, + { + name: "get_volume", + description: "Get current system volume level (0-100)", + script: ` + try + -- Get the current output volume from system settings (returns 0-100) + set currentVolume to output volume of (get volume settings) + return "Current volume level: " & currentVolume & "%" + on error errMsg + return "Failed to get volume: " & errMsg + end try + `, + }, { name: "get_frontmost_app", description: "Get the name of the frontmost application",