1
0
mirror of https://github.com/frebib/dotfiles.git synced 2024-06-14 12:57:23 +00:00

Rewrite i3b/updates in bash with AUR support

This commit is contained in:
Joe Groocock 2017-09-29 16:32:38 +01:00
parent 1819e6ae03
commit 16883bff80
Signed by: frebib
GPG Key ID: E0B16BEACFBB6A86
2 changed files with 29 additions and 10 deletions

View File

@ -57,6 +57,7 @@ signal=15
[updates] [updates]
label= label=
interval=600 interval=600
signal=5
[separator] [separator]

View File

@ -1,13 +1,31 @@
#!/bin/python2 #!/bin/bash
set -e
import commands for p in pacaur yaourt pacman; do
import os if $p --version &>/dev/null; then
PAC="$p"
break;
fi
done
button = os.environ.get('BLOCK_BUTTON') if [ -z "$PAC" ]; then
if button == '1': >&2 echo "Error: No Arch package manager found?"
os.system("i3-sensible-terminal -r i3blocks-update-term -e 'pacaur -Syu'") fi
updates = commands.getstatusoutput("/usr/bin/checkupdates | wc -l")[1] if [ "$BLOCK_BUTTON" == 1 ]; then
if updates and updates != '0': nohup i3-sensible-terminal -r i3blocks-update-term -e "sh -c '$PAC -Syu; pkill -RTMIN+5 i3blocks'" &>/dev/null &
print updates disown
print updates fi
if [ $p = "pacman" ]; then
exec 3< <(checkupdates)
else
exec 3< <({ checkupdates & cower -u & })
fi
count="$(wc -l <&3)"
if [ -n "$count" -a "$count" -gt 0 ]; then
echo $count
echo $count
fi