How to Integrate aur updates counter in the bash script using paru

Following is the bash script I’m using with polybar to display number of system updates available, I tried incorporating aur updates with paru -Qau (it shows updates available just like checkupdates command).

But failed due to lack of knowledge about bash scripting, if anyone can help?

Regards

#!/usr/bin/env bash

updates=$(checkupdates)

if [ -z "$updates" ]
then
  count=0
else
  printf '%s\n' "$updates" > /tmp/bspwm-eos-polybar-updates
  count=$(wc -l "/tmp/bspwm-eos-polybar-updates" | awk '{print $1}')
fi

echo "%{T1}%{T-} %{T2}$count%{T-}"

I’d stongly advise against hammering the AUR with requests just for the sake of having an update counter.

There’s a reason why they do rate limiting:

https://wiki.archlinux.org/title/Aurweb_RPC_interface#Limitations

2 Likes

The simplest solution is to install checkupdates+aur and do

checkupdates+aur | wc -l

I can Limit it to once a day maybe…

Why not just running paru or yay once a day then?

Thanks, but I think more simple solution be if someone with know how of bash scripting can help. otherwise I look into that…

I’m doing the same but having it automated is s sigh of relief, one less thing to worry about I guess…

I’m not sure why you’re replying to me with this, but the solution I proposed can literally be put into a polybar module without the need of a script. Just set a timer in the module to run it every x hour/minute/day.

If you insist on a script, there is one here.

Oh, I think I misunderstood your solution earlier, sorry for that, yeah I think your approach is simpler.

if you are talking about the comments, I made in response to @moson , sorry for that also, I don’t know, how everything just getting messy for some reason, I’m replying to someone else, and being mentioned someone else in the response…

1 Like

Just a note here if a ‘script’ is still wanted… in a different thread, I posted a couple of useful bash functions for a) counting pending updates and b)showing a formatted list of pending updates. These could easily be turned into scripts (if needed that way) and swapping in a paru command instead of the yay command should be easy enough.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.