Compare commits
2 commits
fdc58d1328
...
a17b8e0ef5
Author | SHA1 | Date | |
---|---|---|---|
a17b8e0ef5 | |||
c4b0463d8d |
2 changed files with 65 additions and 2 deletions
63
home/private_bin/executable_check-exe-versions
Normal file
63
home/private_bin/executable_check-exe-versions
Normal file
|
@ -0,0 +1,63 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
from typing import List
|
||||
|
||||
|
||||
class Exe:
|
||||
def __init__(self, owner: str, name: str, exe: str | None = None) -> None:
|
||||
self.owner = owner
|
||||
self.name = name
|
||||
self.exe = name if exe is None else exe
|
||||
self.repo = f"{owner}/{name}"
|
||||
|
||||
def fetch_tags(self) -> List[str]:
|
||||
output = subprocess.check_output(
|
||||
[
|
||||
"gh",
|
||||
"api",
|
||||
"-H",
|
||||
"Accept: application/vnd.github+json",
|
||||
"-H",
|
||||
"X-GitHub-Api-Version: 2022-11-28",
|
||||
"--paginate",
|
||||
f"repos/{self.owner}/{self.name}/tags",
|
||||
],
|
||||
text=True,
|
||||
)
|
||||
if self.name == "ripgrep":
|
||||
tags = [n for o in json.loads(output) if (n := o["name"])[0].isdigit()]
|
||||
else:
|
||||
tags = [n for o in json.loads(output) if (n := o["name"]).startswith("v")]
|
||||
if not tags:
|
||||
print(f"recieved no tags for {self.owner}/{self.name}")
|
||||
return tags
|
||||
|
||||
def current_version(self) -> str:
|
||||
return subprocess.check_output([self.exe, "--version"], text=True)
|
||||
|
||||
def display(self) -> None:
|
||||
print(f"""
|
||||
name: {self.owner}/{self.name}
|
||||
latest: {self.fetch_tags()[0]}
|
||||
current:
|
||||
""")
|
||||
|
||||
print("\n".join([f" | {line} " for line in self.current_version().splitlines()]))
|
||||
|
||||
|
||||
EXECUTABLES = [
|
||||
Exe(*args)
|
||||
for args in (
|
||||
("sharkdp", "fd"),
|
||||
("BurntSushi", "ripgrep", "rg"),
|
||||
("cli", "cli", "gh"),
|
||||
("jesseduffield", "lazygit"),
|
||||
("neovim", "neovim", "nvim"),
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
for exe in EXECUTABLES:
|
||||
exe.display()
|
|
@ -23,7 +23,7 @@ background {
|
|||
# TIME
|
||||
label {
|
||||
monitor =
|
||||
text = cmd[update:30000] echo "$(date +"%R")"
|
||||
text = cmd[update:1000] echo "$(date +"%R")"
|
||||
color = $text
|
||||
font_size = 90
|
||||
font_family = $font
|
||||
|
@ -35,7 +35,7 @@ label {
|
|||
# DATE
|
||||
label {
|
||||
monitor =
|
||||
text = cmd[update:43200000] echo "$(date +"%A, %d %B %Y")"
|
||||
text = cmd[update:6000] echo "$(date +"%A, %d %B %Y")"
|
||||
color = $text
|
||||
font_size = 25
|
||||
font_family = $font
|
||||
|
|
Loading…
Reference in a new issue