taskbar-focus 0.5.0

A tiny Pomodoro/focus timer that lives in the Windows tray and toggles Do Not Disturb
//! Everything that talks to Windows lives under here, so the timer and config
//! layers stay portable and testable.

pub mod autostart;
pub mod dnd;
pub mod localtime;
pub mod lock;
pub mod registry;
pub mod sound;

/// How long Windows keeps a notification banner on screen: the user's
/// "Dismiss notifications after this amount of time" accessibility setting,
/// five seconds unless they changed it.
///
/// Capped at thirty seconds. Someone who chose a minute or more would
/// otherwise wait that long for notifications to be muted after every
/// notification this app shows.
pub fn notification_display_time() -> std::time::Duration {
    use windows::Win32::UI::WindowsAndMessaging::{SystemParametersInfoW, SPI_GETMESSAGEDURATION};
    let mut secs = 0u32;
    let read = unsafe {
        SystemParametersInfoW(
            SPI_GETMESSAGEDURATION,
            0,
            Some(std::ptr::from_mut(&mut secs).cast()),
            Default::default(),
        )
    };
    let secs = if read.is_ok() && secs > 0 { secs } else { 5 };
    std::time::Duration::from_secs(u64::from(secs.clamp(5, 30)))
}