2020-09-21 08:13:28 +02:00
|
|
|
#! /usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
2021-02-11 15:56:52 +01:00
|
|
|
|
|
|
|
"""Get apt updates for `argos <https://github.com/p-e-w/argos>`."""
|
2020-09-21 08:13:28 +02:00
|
|
|
# <bitbar.title>apt</bitbar.title>
|
|
|
|
# <bitbar.version>v1.0</bitbar.version>
|
|
|
|
# <bitbar.author>Tobias Schmidl</bitbar.author>
|
|
|
|
# <bitbar.author.github>schtobia</bitbar.author.github>
|
|
|
|
# <bitbar.desc>Greps and displays system updates.</bitbar.desc>
|
|
|
|
# <bitbar.image></bitbar.image>
|
|
|
|
# <bitbar.dependencies>python,aptdaemon,apt</bitbar.dependencies>
|
|
|
|
# <bitbar.abouturl>https://github.com/schtobia/argos-httping/blob/master/httping.py</bitbar.abouturl>
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
2020-09-21 08:13:37 +02:00
|
|
|
from apt import Cache
|
|
|
|
|
2020-09-21 08:13:28 +02:00
|
|
|
__author__ = "Tobias Schmidl"
|
|
|
|
__copyright__ = "Copyright 2018, Tobias Schmidl"
|
|
|
|
__license__ = "MIT"
|
|
|
|
__version__ = "0.0.1"
|
|
|
|
__maintainer__ = "Tobias Schmidl"
|
|
|
|
|
2020-09-21 08:13:37 +02:00
|
|
|
THEMES = {
|
2020-09-21 08:13:28 +02:00
|
|
|
# Themes are from http://colorbrewer2.org/
|
2020-09-21 08:13:37 +02:00
|
|
|
"purple_green": ["#762a83", "#9970ab", "#c2a5cf", "#a6dba0", "#5aae61", "#1b7837"],
|
|
|
|
"red_green": ["#d73027", "#fc8d59", "#fee08b", "#d9ef8b", "#91cf60", "#1a9850"],
|
|
|
|
"original": ["#acacac", "#ff0101", "#cc673b", "#ce8458", "#6bbb15", "#0ed812"]
|
|
|
|
}
|
|
|
|
CURRENT_THEME = THEMES["red_green"]
|
2020-09-21 08:13:35 +02:00
|
|
|
|
2020-09-21 08:13:37 +02:00
|
|
|
if __name__ == "__main__":
|
|
|
|
try:
|
|
|
|
from aptdaemon import client
|
|
|
|
apt_client = client.AptClient()
|
|
|
|
apt_client.update_cache(wait=True)
|
|
|
|
except ImportError as err:
|
|
|
|
print(str(err), file=sys.stderr)
|
2020-09-21 08:13:28 +02:00
|
|
|
|
2020-09-21 08:13:37 +02:00
|
|
|
cache = Cache()
|
|
|
|
cache.open()
|
|
|
|
update_list = [pkg for pkg in cache if pkg.is_upgradable]
|
|
|
|
if len(update_list) == 0:
|
|
|
|
print('<span color="' + CURRENT_THEME[5] + '">apt: ✔</span>\n----\nclean | font = monospace')
|
|
|
|
sys.exit(0)
|
|
|
|
else:
|
|
|
|
print('<span color="' + CURRENT_THEME[2] + '">apt: ✦ pending</span>\n----')
|
|
|
|
for pkg in update_list:
|
|
|
|
print(pkg.name + ": " + pkg.installed.version + " → " + pkg.candidate.version + " | font = monospace")
|