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]
label=
interval=600
signal=5
[separator]

View File

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