summaryrefslogtreecommitdiff
path: root/.local/bin/update
blob: fc02143def2fd4f12f54b9118e01baa2a3606e86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/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)