diff options
author | Juan J. Martinez <jjm@usebox.net> | 2024-03-13 19:54:28 +0000 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2024-03-13 19:54:28 +0000 |
commit | c8d539691cbeded1c4ee1389afa6625485cc9c44 (patch) | |
tree | dc1b616d7c0a9254cd56b08cd53258065f750475 | |
parent | f6faa3cf1ace9a6f0cb40c78393069734246262a (diff) | |
download | dotnvim-c8d539691cbeded1c4ee1389afa6625485cc9c44.tar.gz dotnvim-c8d539691cbeded1c4ee1389afa6625485cc9c44.zip |
Apt updates indicator
-rwxr-xr-x | i3/check-updates.py | 35 | ||||
-rw-r--r-- | i3/i3status.conf | 5 |
2 files changed, 40 insertions, 0 deletions
diff --git a/i3/check-updates.py b/i3/check-updates.py new file mode 100755 index 0000000..2e25c4b --- /dev/null +++ b/i3/check-updates.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +# add a crontab entry with crontab -e: +# 0 */2 * * * $HOME/.config/nvim/i3/check-updates.py +# +# create /etc/apt/apt.conf.d/10periodic with: +# APT::Periodic::Enable "1"; +# APT::Periodic::Update-Package-Lists "1"; +# APT::Periodic::AutocleanInterval "7"; +# APT::Periodic::Verbose "1"; +# + + +import subprocess +import pathlib +import os + +CMD = ["apt", "list", "--upgradeable"] + + +def check_updates(): + output = str(subprocess.check_output(CMD, stderr=subprocess.DEVNULL)) + output = output.splitlines() + return len(output[1:-1]) + + +if __name__ == "__main__": + pending = check_updates() + if pending == 0: + result = "" + else: + result = f"{pending} updates" + + with open(os.path.join(pathlib.Path.home(), ".pending_updates"), "wt") as fd: + fd.write(result) diff --git a/i3/i3status.conf b/i3/i3status.conf index 349924d..2cb2a16 100644 --- a/i3/i3status.conf +++ b/i3/i3status.conf @@ -15,6 +15,7 @@ order += "cpu_usage" order += "cpu_temperature 0" order += "memory" order += "disk /" +order += "read_file updates" order += "volume master" order += "tztime local" @@ -49,3 +50,7 @@ volume master { mixer = "Master" mixer_idx = 0 } + +read_file updates { + path = "/home/reidrac/.pending_updates" +} |