Skip to content

Commit

Permalink
add support for yay AUR helper
Browse files Browse the repository at this point in the history
  • Loading branch information
nwg-piotr committed Nov 12, 2023
1 parent 1283671 commit b31e4b1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
8 changes: 6 additions & 2 deletions nwg-system-update
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
# Otherwise, just don't install this script. The tray system update notifier won't show up,
# as well as related nwg-shell-config options.

baph -u &&
echo $1; read;
if [ "$2" = "-yay" ]; then
yay -Syu;
else
baph -u;
fi
echo "$1"; read -r;
38 changes: 34 additions & 4 deletions nwg_shell_config/update_indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
check_key(settings, key, defaults[key])

voc = {} # Vocabulary
nwg_system_update_arg = ""

ind = None # Indicator(object) containing

Expand Down Expand Up @@ -174,13 +175,39 @@ def check_updates(self, *args):

# Below we could add update check commands for other distros
if self.distro == "arch":
if is_command("baph"):
global nwg_system_update_arg
nwg_system_update_arg = "-baph"
if is_command("yay"):
nwg_system_update_arg = "-yay"
eprint("Using yay")
pacman, aur = 0, 0
try:
output = subprocess.check_output("checkupdates".split()).decode('utf-8').splitlines()
pacman = len(output)
except subprocess.CalledProcessError:
pass
try:
output = subprocess.check_output("yay -Qu".split()).decode('utf-8').splitlines()
aur = len(output)
except subprocess.CalledProcessError:
pass

if pacman or aur:
update_details = f"pacman: {pacman}, AUR: {aur}"

elif is_command("baph"):
eprint("Using baph")
output = subprocess.check_output("baph -c".split()).decode('utf-8').strip()
if output and output != "0 0":
u = output.split()
update_details = "pacman: {}, AUR: {}".format(u[1], u[0])
update_details = f"pacman: {u[1]}, AUR: {u[0]}"

# elif self.distro == "something_else:
if update_details:
eprint(update_details)
else:
eprint(voc["you-are-up-to-date"])

# elif self.distro == "something_else":
# place your code here

if not update_details:
Expand All @@ -196,7 +223,10 @@ def update(self, *args):
# IMPORTANT: the presence of this script will also determine if to display corresponding
# options in the config utility.
if settings["update-command"] == "nwg-system-update":
subprocess.call("exec foot nwg-system-update '{}'".format(voc["press-enter-to-exit"]), shell=True)
cmd = "exec foot nwg-system-update '{}'".format(voc["press-enter-to-exit"])
if nwg_system_update_arg:
cmd += f" {nwg_system_update_arg}"
subprocess.call(cmd, shell=True)
else:
subprocess.call("exec {}".format(settings["update-command"]), shell=True)

Expand Down

0 comments on commit b31e4b1

Please sign in to comment.