#!/usr/bin/env python3 """ nvim '+PlugUpdate' sudo pacman -Syu aur sync -unr nix-channel --update && nix-env -u """ import sys, os import subprocess from time import localtime, strftime def log(message: str): print(f'[{strftime("%H:%M:%S", localtime())}] {message}') lock_file = 'update.lock' if os.path.exists(lock_file): log('Update already running') sys.exit(0) open(lock_file, 'a').close() log('Running `nvim \'+PlugUpdate\'`...') subprocess.run(['nvim', '+PlugUpdate']) log('Running `sudo pacman -Syu`...') subprocess.run(['sudo', 'pacman', '-Syu']) log('Running `aur sync -unr`...') subprocess.run(['aur', 'sync', '-unr']) log('Running `nix-channel --update`...') subprocess.run(['nix-channel', '--update']) log('Running `nix-env -u`...') subprocess.run(['nix-env', '-u']) log('Cleaning up...') os.remove(lock_file)