]> Git repositories of Lucie Scarlet - dotfiles.git/commitdiff
Added formatting support for days
authorLucie Scarlet <lucie@scarlet.moe>
Fri, 12 Jul 2024 09:52:14 +0000 (11:52 +0200)
committerLucie Scarlet <lucie@scarlet.moe>
Fri, 12 Jul 2024 09:52:14 +0000 (11:52 +0200)
Also separated out the formatting to make them easier to edit

i3/uptime.py

index d26303051a2ab8e1577e859d10df765a57ffd139..c00aaad9d2843da7acf8d8c2e426b749f4e13d81 100644 (file)
@@ -9,9 +9,15 @@ def main() -> int:
     raw_formatted = timedelta(seconds=(float(text_uptime)))
     well_formatted: str = str(raw_formatted).split(".")[0][:-3]
     fmt = well_formatted.split(".")[0]
-    hours = fmt.split(":")[0]
-    mins = fmt.split(":")[1]
-    print(f"Uptime: {hours}h {mins}m")
+    f2 = fmt.split(' days, ')[1]
+    days = fmt.split(' days, ')[0]
+    hours = f2.split(":")[0]
+    mins = f2.split(":")[1]
+    output_d = f"{days}d" if days else ""
+    output_h = f"{hours}h"
+    output_m = f"{mins}m"
+    print(f"Uptime: {output_d} {output_h} {output_m}")
+    return 0
 
 
 if __name__ == "__main__":