From: Lucie Scarlet Date: Wed, 3 Jul 2024 22:45:32 +0000 (+0200) Subject: Accounted for uptime script X-Git-Url: https://git.chaotic.ninja/gitweb/lucie/?a=commitdiff_plain;h=9535123f8c66b8a473621f7aebfb5bb4295e43ca;p=dotfiles.git Accounted for uptime script Install now installs the uptime python3 script to /opt and adds the script to crontab --- diff --git a/i3/install.sh b/i3/install.sh index dbf4a81..7c6ea54 100755 --- a/i3/install.sh +++ b/i3/install.sh @@ -1,6 +1,20 @@ #!/bin/bash +echo "Installing i3 config" mkdir -p ~/.config/i3 cp ./i3config ~/.config/i3/config +echo "Installing i3status config" mkdir -p ~/.config/i3status cp ./i3status ~/.config/i3status/config + +echo "Installing uptime script" +sudo -s < /tmp/uptime" | tee -a $ct +echo "@reboot python3 /opt/uptime.py > /tmp/uptime" | tee -a $ct + +crontab $ct diff --git a/i3/uptime.py b/i3/uptime.py new file mode 100644 index 0000000..d263030 --- /dev/null +++ b/i3/uptime.py @@ -0,0 +1,18 @@ +from datetime import timedelta + + +def main() -> int: + raw_uptime: str = "" + with open("/proc/uptime", "r") as uptime: + raw_uptime = uptime.read() + text_uptime: str = raw_uptime.split()[0] + 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") + + +if __name__ == "__main__": + raise SystemExit(main())