-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: turn off the alert volume instead of system volume (#539)
* fix: turn off the alert volume instead of system volume * perf: remove unused disableEmptyCopyBeep * perf: improve dismissing pop button * perf: change alert volume type from float to NSInteger
- Loading branch information
Showing
10 changed files
with
110 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
Easydict/Swift/Feature/GetSelectedText/AppleScriptUtils.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// AppleScriptUtils.swift | ||
// Easydict | ||
// | ||
// Created by tisfeng on 2024/5/5. | ||
// Copyright © 2024 izual. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
// MARK: - AppleScriptUtils | ||
|
||
@objcMembers | ||
class AppleScriptUtils: NSObject { | ||
static func getAlertVolume() -> Int32 { | ||
var error: NSDictionary? | ||
let script = """ | ||
set alertVolume to alert volume of (get volume settings) | ||
return alertVolume | ||
""" | ||
let appleScript = NSAppleScript(source: script) | ||
if let outputEvent = appleScript?.executeAndReturnError(&error) { | ||
return outputEvent.int32Value | ||
} else { | ||
if let error = error { | ||
logError(error.description) | ||
} | ||
return 0 | ||
} | ||
} | ||
|
||
static func setAlertVolume(_ volume: Int) { | ||
var error: NSDictionary? | ||
let script = """ | ||
tell application "System Events" | ||
set volume alert volume \(volume) | ||
end tell | ||
""" | ||
let appleScript = NSAppleScript(source: script) | ||
appleScript?.executeAndReturnError(&error) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.