Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .github/screenshots/detailed-time-off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/screenshots/detailed-time-on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Once running, it will appear in your taskbar and as one or more tray icons in th
- Drag the left divider to move the taskbar widget
- Right-click the taskbar widget or tray icon for refresh, displayed models, update frequency, Start with Windows, reset position, language, updates, and exit
- Left-click the tray icon to toggle the taskbar widget on or off
- Enable `Show detailed remaining time` under right-click `Settings` to add minutes alongside hours (5h window) and hours alongside days (7d window)
- Enable `Start with Windows` from the right-click menu if you want it to launch automatically when you sign in

### Models
Expand Down
1 change: 1 addition & 0 deletions src/localization/dutch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub(super) const STRINGS: Strings = Strings {
update_available: "Update beschikbaar",
update_prompt_now: "Versie {version} is beschikbaar. Wil je nu bijwerken?",
exit: "Afsluiten",
show_detailed_remaining: "Gedetailleerde resterende tijd tonen",
show_widget: "Widget tonen",
session_window: "5u",
weekly_window: "7d",
Expand Down
1 change: 1 addition & 0 deletions src/localization/english.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub(super) const STRINGS: Strings = Strings {
update_available: "Update available",
update_prompt_now: "Version {version} is available. Do you want to update now?",
exit: "Exit",
show_detailed_remaining: "Show detailed remaining time",
show_widget: "Show Widget",
session_window: "5h",
weekly_window: "7d",
Expand Down
1 change: 1 addition & 0 deletions src/localization/french.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub(super) const STRINGS: Strings = Strings {
update_available: "Mise à jour disponible",
update_prompt_now: "La version {version} est disponible. Voulez-vous mettre à jour maintenant ?",
exit: "Quitter",
show_detailed_remaining: "Afficher le temps restant détaillé",
show_widget: "Afficher le widget",
session_window: "5h",
weekly_window: "7d",
Expand Down
1 change: 1 addition & 0 deletions src/localization/german.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub(super) const STRINGS: Strings = Strings {
update_available: "Update verfügbar",
update_prompt_now: "Version {version} ist verfügbar. Möchten Sie jetzt aktualisieren?",
exit: "Beenden",
show_detailed_remaining: "Detaillierte Restzeit anzeigen",
show_widget: "Widget anzeigen",
session_window: "5h",
weekly_window: "7d",
Expand Down
1 change: 1 addition & 0 deletions src/localization/japanese.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub(super) const STRINGS: Strings = Strings {
update_available: "更新が利用可能です",
update_prompt_now: "バージョン {version} が利用可能です。今すぐ更新しますか?",
exit: "終了",
show_detailed_remaining: "残り時間を詳細表示",
show_widget: "ウィジェットを表示",
session_window: "5h",
weekly_window: "7d",
Expand Down
1 change: 1 addition & 0 deletions src/localization/korean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub(super) const STRINGS: Strings = Strings {
update_available: "업데이트 사용 가능",
update_prompt_now: "버전 {version}을 사용할 수 있습니다. 지금 업데이트하시겠습니까?",
exit: "종료",
show_detailed_remaining: "남은 시간 상세 표시",
show_widget: "위젯 표시",
session_window: "5시간",
weekly_window: "7일",
Expand Down
1 change: 1 addition & 0 deletions src/localization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ pub struct Strings {
pub update_available: &'static str,
pub update_prompt_now: &'static str,
pub exit: &'static str,
pub show_detailed_remaining: &'static str,
pub show_widget: &'static str,
pub session_window: &'static str,
pub weekly_window: &'static str,
Expand Down
1 change: 1 addition & 0 deletions src/localization/portuguese_brazil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub(super) const STRINGS: Strings = Strings {
update_available: "Atualização disponível",
update_prompt_now: "Versão {version} está disponível. Deseja atualizar agora?",
exit: "Sair",
show_detailed_remaining: "Mostrar tempo restante detalhado",
show_widget: "Exibir Widget",
session_window: "5h",
weekly_window: "7d",
Expand Down
1 change: 1 addition & 0 deletions src/localization/russian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub(super) const STRINGS: Strings = Strings {
update_available: "Доступно обновление",
update_prompt_now: "Доступна версия {version}. Обновить сейчас?",
exit: "Выход",
show_detailed_remaining: "Показывать подробное оставшееся время",
show_widget: "Показать виджет",
session_window: "5ч",
weekly_window: "7д",
Expand Down
1 change: 1 addition & 0 deletions src/localization/spanish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub(super) const STRINGS: Strings = Strings {
update_available: "Actualización disponible",
update_prompt_now: "La versión {version} está disponible. ¿Quieres actualizar ahora?",
exit: "Salir",
show_detailed_remaining: "Mostrar tiempo restante detallado",
show_widget: "Mostrar widget",
session_window: "5h",
weekly_window: "7d",
Expand Down
1 change: 1 addition & 0 deletions src/localization/traditional_chinese.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub(super) const STRINGS: Strings = Strings {
update_available: "有可用更新",
update_prompt_now: "版本 {version} 已可用。是否立即更新?",
exit: "結束",
show_detailed_remaining: "顯示詳細剩餘時間",
show_widget: "顯示小工具",
session_window: "5h",
weekly_window: "7d",
Expand Down
50 changes: 46 additions & 4 deletions src/poller.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::path::PathBuf;
use std::process::Command;
use std::sync::atomic::{AtomicBool, Ordering};
use std::time::{Duration, SystemTime, UNIX_EPOCH};

use serde::Deserialize;
Expand Down Expand Up @@ -1020,6 +1021,21 @@ fn is_leap(y: u64) -> bool {
(y % 4 == 0 && y % 100 != 0) || y % 400 == 0
}

/// Detailed remaining-time flag, mirrored from window state. Read lock-free
/// here so the countdown formatters (which run while the window state lock is
/// held) never re-lock shared state. Kept at base signatures so other features
/// that call these formatters stay source-compatible.
static DETAILED_REMAINING: AtomicBool = AtomicBool::new(false);

/// Update the detailed remaining-time flag the formatters read.
pub fn set_detailed_remaining(enabled: bool) {
DETAILED_REMAINING.store(enabled, Ordering::Relaxed);
}

fn detailed_remaining_enabled() -> bool {
DETAILED_REMAINING.load(Ordering::Relaxed)
}

/// Format a usage section as "X% · Yh" style text
pub fn format_line(section: &UsageSection, strings: Strings) -> String {
let pct = format!("{:.0}%", section.percentage);
Expand Down Expand Up @@ -1053,14 +1069,31 @@ pub fn time_until_display_change(resets_at: Option<SystemTime>) -> Option<Durati
}

fn format_countdown_from_secs(total_secs: u64, strings: Strings) -> String {
let detailed = detailed_remaining_enabled();
let total_mins = total_secs / 60;
let total_hours = total_secs / 3600;
let total_days = total_secs / 86400;

if total_days >= 1 {
format!("{total_days}{}", strings.day_suffix)
if detailed {
let hours = total_hours % 24;
format!(
"{total_days}{} {hours}{}",
strings.day_suffix, strings.hour_suffix
)
} else {
format!("{total_days}{}", strings.day_suffix)
}
} else if total_hours >= 1 {
format!("{total_hours}{}", strings.hour_suffix)
if detailed {
let mins = total_mins % 60;
format!(
"{total_hours}{} {mins}{}",
strings.hour_suffix, strings.minute_suffix
)
} else {
format!("{total_hours}{}", strings.hour_suffix)
}
} else if total_mins >= 1 {
format!("{total_mins}{}", strings.minute_suffix)
} else {
Expand All @@ -1069,14 +1102,23 @@ fn format_countdown_from_secs(total_secs: u64, strings: Strings) -> String {
}

fn time_until_display_change_from_secs(total_secs: u64) -> Duration {
let detailed = detailed_remaining_enabled();
let total_mins = total_secs / 60;
let total_hours = total_secs / 3600;
let total_days = total_secs / 86400;

let current_bucket_start = if total_days >= 1 {
total_days * 86400
if detailed {
total_hours * 3600
} else {
total_days * 86400
}
} else if total_hours >= 1 {
total_hours * 3600
if detailed {
total_mins * 60
} else {
total_hours * 3600
}
} else if total_mins >= 1 {
total_mins * 60
} else {
Expand Down
Loading