Atoll/DynamicIsland/managers/SystemVolumeManager.swift
Hariharan Mudaliar 1a45d4e7f4 Working Indicators
2025-09-06 19:28:38 +05:30

35 lines
No EOL
1.1 KiB
Swift

//
// SystemVolumeManager.swift
// DynamicIsland
//
// Adapted from TheBoringWorker-HUD VolumeManager.swift
// Created by GitHub Copilot on 06/09/25.
//
import Foundation
class SystemVolumeManager {
private init() {}
static func isMuted() -> Bool {
do {
return try AppleScriptRunner.run(script: "return output muted of (get volume settings)") == "true"
} catch {
NSLog("Error while trying to retrieve muted properties of device: \(error). Returning default value false.")
return false
}
}
static func getOutputVolume() -> Float {
do {
if let volumeStr = Float(try AppleScriptRunner.run(script: "return output volume of (get volume settings)")) {
return volumeStr / 100
} else {
NSLog("Error while trying to parse volume string value. Returning default volume value 1.")
}
} catch {
NSLog("Error while trying to retrieve volume properties of device: \(error). Returning default volume value 1.")
}
return 0.01
}
}