-
Notifications
You must be signed in to change notification settings - Fork 341
Expand file tree
/
Copy pathSettings.swift
More file actions
109 lines (97 loc) · 3.08 KB
/
Copy pathSettings.swift
File metadata and controls
109 lines (97 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//
// Settings.swift
// ClaudeIsland
//
// App settings manager using UserDefaults
//
import Foundation
/// Available notification sounds
enum NotificationSound: String, CaseIterable {
case none = "None"
case pop = "Pop"
case ping = "Ping"
case tink = "Tink"
case glass = "Glass"
case blow = "Blow"
case bottle = "Bottle"
case frog = "Frog"
case funk = "Funk"
case hero = "Hero"
case morse = "Morse"
case purr = "Purr"
case sosumi = "Sosumi"
case submarine = "Submarine"
case basso = "Basso"
/// The system sound name to use with NSSound, or nil for no sound
var soundName: String? {
self == .none ? nil : rawValue
}
}
enum AppSettings {
private static let defaults = UserDefaults.standard
// MARK: - Keys
private enum Keys {
static let notificationSound = "notificationSound"
static let approveShortcut = "approveShortcut"
static let denyShortcut = "denyShortcut"
static let shortcutsEnabled = "shortcutsEnabled"
}
// MARK: - Notification Sound
/// The sound to play when Claude finishes and is ready for input
static var notificationSound: NotificationSound {
get {
guard let rawValue = defaults.string(forKey: Keys.notificationSound),
let sound = NotificationSound(rawValue: rawValue) else {
return .pop // Default to Pop
}
return sound
}
set {
defaults.set(newValue.rawValue, forKey: Keys.notificationSound)
}
}
// MARK: - Keyboard Shortcuts
/// Whether global keyboard shortcuts are enabled
static var shortcutsEnabled: Bool {
get {
// Default to true if never set
if defaults.object(forKey: Keys.shortcutsEnabled) == nil {
return true
}
return defaults.bool(forKey: Keys.shortcutsEnabled)
}
set {
defaults.set(newValue, forKey: Keys.shortcutsEnabled)
}
}
/// Keyboard shortcut for approving permissions (default: ⌘⇧Y)
static var approveShortcut: KeyCombo {
get {
guard let data = defaults.data(forKey: Keys.approveShortcut),
let combo = try? JSONDecoder().decode(KeyCombo.self, from: data) else {
return .defaultApprove
}
return combo
}
set {
if let data = try? JSONEncoder().encode(newValue) {
defaults.set(data, forKey: Keys.approveShortcut)
}
}
}
/// Keyboard shortcut for denying permissions (default: ⌘⇧N)
static var denyShortcut: KeyCombo {
get {
guard let data = defaults.data(forKey: Keys.denyShortcut),
let combo = try? JSONDecoder().decode(KeyCombo.self, from: data) else {
return .defaultDeny
}
return combo
}
set {
if let data = try? JSONEncoder().encode(newValue) {
defaults.set(data, forKey: Keys.denyShortcut)
}
}
}
}