checkupdates: Fix for shared module
Cache result of checkupdates in temporary file, that gets updated after 15 seconds. It's a workaround for shared custom/pacman module that can only run for one bar at once. Usually it causes the module to work only in one bar. This way all bars should show the same output.
This commit is contained in:
parent
9b19f29c3f
commit
411a8955a0
|
|
@ -1,5 +1,26 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
count="$(checkupdates-with-aur | wc -l)"
|
count_file=/tmp/waybar/module/pacman/count
|
||||||
|
threshold_date="$(date -d 'now - 15 seconds' +%s)"
|
||||||
|
|
||||||
|
while pgrep checkupdates | grep -v $$; do
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -f "$count_file" ]; then
|
||||||
|
last_update="$(stat --format='%Y' "$count_file")"
|
||||||
|
if [ "$last_update" -ge "$threshold_date" ]; then
|
||||||
|
count="$(cat "$count_file")"
|
||||||
|
else
|
||||||
|
count="$(checkupdates-with-aur | wc -l)"
|
||||||
|
mkdir -p /tmp/waybar/module/pacman
|
||||||
|
echo "$count" > /tmp/waybar/module/pacman/count
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
count="$(checkupdates-with-aur | wc -l)"
|
||||||
|
mkdir -p /tmp/waybar/module/pacman
|
||||||
|
echo "$count" > /tmp/waybar/module/pacman/count
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
class="ok"
|
class="ok"
|
||||||
if [ "$count" -gt 0 ]; then
|
if [ "$count" -gt 0 ]; then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue