Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timeToLive, fadeOutAnimationDuration, afterHideCallback don't seem to be working #10

Open
sidevesh opened this issue Oct 3, 2023 · 6 comments

Comments

@sidevesh
Copy link
Contributor

sidevesh commented Oct 3, 2023

Have a really simple program where I am trying to show an HUD, but I can't seem to be able to get timeToLive, fadeOutAnimationDuration and afterHideCallback options to work,
despite whatever value I set the HUD disappears with no animations, fadeInAnimationDuration seems to work though.
also timeToLive does not seem to have any effect and the HUD disappears after the same time no matter what value I set.
afterHideCallback does not seem to trigger either.

import AppKit
import BezelNotification

func after(_ delay: TimeInterval, perform block: @escaping ()->(), on queue: DispatchQueue = OperationQueue.current?.underlyingQueue ?? .main) { // So this `queue` preserves the current queue and defaulted to the `main`. Also the caller can pass in the desired queue explicitly
    queue.asyncAfter(deadline: .now() + delay, execute: block)
}

var showMuted: Bool = true

for argument in CommandLine.arguments {
    if (argument == "un-muted") {
        showMuted = false;
    }
}

let app = NSApplication.shared

class AppDelegate: NSObject, NSApplicationDelegate {
    func applicationDidFinishLaunching(_ notification: Notification) {
        var path: String?
        if (showMuted) {
            path = Bundle.module.path(forResource: "mic.slash.fill", ofType: "png")
        } else {
            path = Bundle.module.path(forResource: "mic.fill", ofType: "png")
        }
        let bezelIcon = NSImage(contentsOfFile: path!)
        BezelNotification.show(
            messageText: "",
            icon: bezelIcon,
            timeToLive: .exactly(seconds: 2),
            fadeInAnimationDuration: 0,
            fadeOutAnimationDuration: 0
        )
        after(2) {
            app.terminate(self)
        }
    }
}

let delegate = AppDelegate()
app.delegate = delegate
app.run()
@sidevesh
Copy link
Contributor Author

sidevesh commented Dec 2, 2023

@KyLeggiero do you have any pointers on this ?

@KyLeggiero
Copy link
Member

Yeah, this is weird. I'm trying to debug this. Seems to be new as of Sonoma maybe? Stay tuned.

Also currently working on a SwiftUI API so I wanna make sure this remains polished for that launch.

@KyLeggiero
Copy link
Member

timeToLive should at least be working right now. Can you try setting it to other values to see how long it stays on screen before disappearing? Your example sets it to 2, which is the default. Setting it to 0.5 should shorten how long it's on-screen, and 10 should make it stay on-screen longer. Please let me know if that's working this way

@sidevesh
Copy link
Contributor Author

sidevesh commented Feb 21, 2024

Any value less than 2 seems to work for timeToLive and I can see the toast disappear earlier,
anything above 2 seems to have no effect, it just seems to use 2 seconds.

@sidevesh
Copy link
Contributor Author

sidevesh commented Feb 21, 2024

You should be able to reproduce this issue with the above code,
the full code is at https://github.com/sidevesh/MuteMicrophonesOSD

@KyLeggiero
Copy link
Member

Thank you for the feedback! Will keep all this in-mind during the coming updates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants