Add floating windows and btop system monitor
This commit is contained in:
1 parent
fd0b3b20a2
commit
201a1e0914
23 files changed
+1049
-36
No files matched your search
@@ -0,0 +1,26 @@
|
||||
export function randomWalk(value: number, step: number, minimum = 0, maximum = 100): number {
|
||||
const next = value + (Math.random() * 2 - 1) * step;
|
||||
return Math.min(maximum, Math.max(minimum, next));
|
||||
}
|
||||
|
||||
export function usageTone(percent: number): string {
|
||||
if (percent >= 80) return 'red';
|
||||
if (percent >= 50) return 'yellow';
|
||||
return 'green';
|
||||
}
|
||||
|
||||
export function relativeTime(isoDate: string): string {
|
||||
const elapsedMinutes = Math.floor((Date.now() - new Date(isoDate).getTime()) / 60000);
|
||||
if (elapsedMinutes < 60) return `${elapsedMinutes}m`;
|
||||
const elapsedHours = Math.floor(elapsedMinutes / 60);
|
||||
if (elapsedHours < 24) return `${elapsedHours}h`;
|
||||
const elapsedDays = Math.floor(elapsedHours / 24);
|
||||
if (elapsedDays < 60) return `${elapsedDays}d`;
|
||||
return `${Math.floor(elapsedDays / 30)}mo`;
|
||||
}
|
||||
|
||||
export function formatSize(sizeKb: number): string {
|
||||
if (sizeKb >= 1024 * 1024) return `${(sizeKb / 1024 / 1024).toFixed(1)}G`;
|
||||
if (sizeKb >= 1024) return `${(sizeKb / 1024).toFixed(1)}M`;
|
||||
return `${sizeKb}K`;
|
||||
}
|
||||
Reference in new issue
Block a user