Write a compact stats string to the terminal title bar.
(self)
| 100 | return line |
| 101 | |
| 102 | def set_title(self) -> None: |
| 103 | """Write a compact stats string to the terminal title bar.""" |
| 104 | if not sys.stdout.isatty(): |
| 105 | return |
| 106 | s = self.snapshot |
| 107 | cpu = s["cpu"] |
| 108 | ru = s["ram_used"] / 1024 ** 3 |
| 109 | rt = s["ram_total"] / 1024 ** 3 |
| 110 | temp = s["temp"] |
| 111 | parts = [f"CPU {cpu:.0f}%", f"RAM {ru:.1f}/{rt:.1f}G"] |
| 112 | if temp is not None: |
| 113 | parts.append(f"T {temp:.0f}°C") |
| 114 | bar = " · ".join(parts) |
| 115 | try: |
| 116 | sys.stdout.write(f"\033]0;Codey {bar}\007") |
| 117 | sys.stdout.flush() |
| 118 | except Exception: |
| 119 | pass |
| 120 | |
| 121 | # ── internals ───────────────────────────────────────────────────────────── |
| 122 |
no test coverage detected