initial repo commit
This commit is contained in:
parent
9cbcdbfde4
commit
9a3c1f1f7a
9 changed files with 1236 additions and 0 deletions
63
custom-scripts/updates
Executable file
63
custom-scripts/updates
Executable file
|
@ -0,0 +1,63 @@
|
|||
#!/bin/bash
|
||||
# _ _ _ _
|
||||
# | | | |_ __ __| | __ _| |_ ___ ___
|
||||
# | | | | '_ \ / _` |/ _` | __/ _ \/ __|
|
||||
# | |_| | |_) | (_| | (_| | || __/\__ \
|
||||
# \___/| .__/ \__,_|\__,_|\__\___||___/
|
||||
# |_|
|
||||
#
|
||||
# by Stephan Raabe (2023)
|
||||
# -----------------------------------------------------
|
||||
|
||||
# -----------------------------------------------------
|
||||
# Define threshholds for color indicators
|
||||
# -----------------------------------------------------
|
||||
|
||||
threshhold_green=0
|
||||
threshhold_yellow=25
|
||||
threshhold_red=100
|
||||
|
||||
# -----------------------------------------------------
|
||||
# Calculate available updates pacman and aur (with aur)
|
||||
# -----------------------------------------------------
|
||||
|
||||
if ! updates_arch=$(checkupdates 2> /dev/null | wc -l ); then
|
||||
updates_arch=0
|
||||
fi
|
||||
|
||||
if ! updates_aur=$(paru -Qua | wc -l); then
|
||||
updates_aur=0
|
||||
fi
|
||||
|
||||
updates=$(("$updates_arch" + "$updates_aur"))
|
||||
|
||||
# -----------------------------------------------------
|
||||
# Testing
|
||||
# -----------------------------------------------------
|
||||
|
||||
# Overwrite updates with numbers for testing
|
||||
# updates=50
|
||||
|
||||
# test JSON output
|
||||
# printf '{"text": "0", "alt": "0", "tooltip": "0 Updates", "class": "red"}'
|
||||
# exit
|
||||
|
||||
# -----------------------------------------------------
|
||||
# Output in JSON format for Waybar Module custom-updates
|
||||
# -----------------------------------------------------
|
||||
|
||||
css_class="green"
|
||||
|
||||
if [ "$updates" -gt $threshhold_yellow ]; then
|
||||
css_class="yellow"
|
||||
fi
|
||||
|
||||
if [ "$updates" -gt $threshhold_red ]; then
|
||||
css_class="red"
|
||||
fi
|
||||
|
||||
if [ "$updates" -gt $threshhold_green ]; then
|
||||
printf '{"text": "%s", "alt": "%s", "tooltip": "%s Updates", "class": "%s"}' "$updates" "$updates" "$updates" "$css_class"
|
||||
else
|
||||
printf '{"text": "0", "alt": "0", "tooltip": "0 Updates", "class": "green"}'
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue