import subprocess import time from theme import current_theme, default raw_seconds = time.clock_gettime(time.CLOCK_BOOTTIME) MINUTE = 60 HOUR = 60 * MINUTE DAY = 24 * HOUR days = int(raw_seconds / DAY) hours = int((raw_seconds % DAY) / HOUR) minutes = int((raw_seconds % HOUR / MINUTE)) data = "" if days > 0: data += f"{days}d " data += f"{hours:02}:" data += f"{minutes:02}" # Check for pending reboot color = f"^c{current_theme.cyan}^" time_color = f"^c{current_theme.teal}^" warn_color = f"^c{current_theme.orange}^" warn_time_color = f"^c{current_theme.red}^" prefix = "󰣇" if days > 10: color = warn_color time_color = warn_time_color try: reboot = subprocess.run( ["please", "longoverdue"], stdout=subprocess.PIPE, encoding="utf-8" ).stdout.split("\n") if len(reboot) > 1: color = warn_color time_color = warn_time_color prefix = "" except Exception: pass content = f"^v^{color}{prefix} {time_color}{data}^t^"