Skip to content

Commit

Permalink
change icon when on/off (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementTsang authored Dec 18, 2024
1 parent 64ca6ba commit da1b211
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions Barista/baristaApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ struct BaristaApp: App {
@State var isCaffeinateEnabled = false

var body: some Scene {
MenuBarExtra {
BaristaMenu(isCaffeinateEnabled: isCaffeinateEnabled)
MenuBarExtra() {
BaristaMenu(isCaffeinateEnabled: $isCaffeinateEnabled)
} label: {
let image = NSImage(systemSymbolName: "cup.and.saucer.fill", accessibilityDescription: nil)
let icon = isCaffeinateEnabled ? "cup.and.saucer.fill" : "cup.and.saucer"
let image = NSImage(systemSymbolName: icon, accessibilityDescription: nil)
Image(nsImage: image!).bold()
}.menuBarExtraStyle(.window)
}
Expand Down Expand Up @@ -64,7 +65,7 @@ struct BaristaMenu: View {

@Environment(\.openURL) private var openURL

@State var isCaffeinateEnabled: Bool
@Binding var isCaffeinateEnabled: Bool
@State var caffeinateRunState = CaffeinateState.stopped

// Corresponds to -d
Expand All @@ -83,20 +84,23 @@ struct BaristaMenu: View {
@AppStorage("canSystemSleepOnAC")
var canSystemSleepOnAC = false

// Corresponds to -u
@AppStorage("preventSleep")
var preventSleep = false
// // Corresponds to -u
// @AppStorage("preventSleep")
// var preventSleep = false
//
// // Corresponds to -t
// @AppStorage("preventSleepSeconds")
// var preventSleepSeconds = 5

// Corresponds to -t
@AppStorage("preventSleepSeconds")
var preventSleepSeconds = 5
// // Corresponds to -w
// @AppStorage("waitForPids")
// var waitForPids = false
//
// @AppStorage("pids")
// var pids: Array<Int> = []

// Corresponds to -w
@AppStorage("waitForPids")
var waitForPids = false

@AppStorage("pids")
var pids: Array<Int> = []
// @AppStorage("disableWhenNotOnAC")
// var disableWhenNotOnAC = false

@State private var quitHovered = false
@State private var githubHovered = false
Expand All @@ -116,7 +120,8 @@ struct BaristaMenu: View {
Toggle("Prevent Idle Sleep", isOn: $canSystemIdleSleep).toggleStyle(MenuToggle())
Toggle("Prevent Disks from Idle Sleep", isOn: $canDiskIdleSleep).toggleStyle(MenuToggle())
Toggle("Keep System Awake on AC", isOn: $canSystemSleepOnAC).toggleStyle(MenuToggle())
// Toggle("Automatically Wake Computer", isOn: $preventSleep).toggleStyle(MenuToggle())
// Toggle("Automatically Wake Computer", isOn: $preventSleep).toggleStyle(MenuToggle())
// Toggle("Disable When Not on AC", isOn: $disableWhenNotOnAC).toggleStyle(MenuToggle())

Divider()

Expand Down

0 comments on commit da1b211

Please sign in to comment.