forked from external/yambar
exemples/scripts: pacman.sh: handle no update in yambar config
change type to int
This commit is contained in:
parent
c4f58e8673
commit
0f1c3548ae
1 changed files with 26 additions and 31 deletions
|
@ -6,20 +6,31 @@
|
|||
# USAGE: pacman.sh
|
||||
#
|
||||
# TAGS:
|
||||
# Name Type Return
|
||||
# Name Type Return
|
||||
# -------------------------------------------
|
||||
# {pacman} string number of pacman packages
|
||||
# {aur} string number of aur packages
|
||||
# {pkg} string sum of both
|
||||
# {pacman} int number of pacman packages
|
||||
# {aur} int number of aur packages
|
||||
# {pkg} int sum of both
|
||||
#
|
||||
# Exemple configuration:
|
||||
# Exemples configuration:
|
||||
# - script:
|
||||
# path: /absolute/path/to/pacman.sh
|
||||
# args: []
|
||||
# content: { string: { text: " {pacman} + {aur} = {pkg}" } }
|
||||
# path: /absolute/path/to/pacman.sh
|
||||
# args: []
|
||||
# content: { string: { text: "{pacman} + {aur} = {pkg}" } }
|
||||
#
|
||||
# To display a message when there is no update:
|
||||
# - script:
|
||||
# path: /absolute/path/to/pacman.sh
|
||||
# args: []
|
||||
# content:
|
||||
# map:
|
||||
# tag: pkg
|
||||
# default: { string: { text: "{pacman} + {aur} = {pkg}" } }
|
||||
# values:
|
||||
# 0: {string: {text: no updates}}
|
||||
|
||||
|
||||
declare interval no_update aur_helper pacman_num aur_num pkg_num
|
||||
declare interval aur_helper pacman_num aur_num pkg_num
|
||||
|
||||
# Error message in STDERR
|
||||
_err() {
|
||||
|
@ -34,11 +45,6 @@ while true; do
|
|||
# "s" seconds / "m" minutes / "h" hours / "d" days
|
||||
interval="1h"
|
||||
|
||||
# Change the message you want when there is no update
|
||||
# Leave empty if you want a 0 instead of a string
|
||||
# (e.g. no_update="")
|
||||
no_update="no update"
|
||||
|
||||
# Change your aur manager
|
||||
aur_helper="paru"
|
||||
|
||||
|
@ -53,27 +59,16 @@ while true; do
|
|||
|
||||
pkg_num=$(( pacman_num + aur_num ))
|
||||
|
||||
# Only display one if there is no update and multiple tags set
|
||||
if [[ "${pacman_num}" == 0 && "${aur_num}" == 0 ]]; then
|
||||
pacman_num="${no_update:-$pacman_num}"
|
||||
aur_num="${no_update:-$aur_num}"
|
||||
pkg_num="${no_update:-$pkg_num}"
|
||||
|
||||
printf -- '%s\n' "pacman|string|"
|
||||
printf -- '%s\n' "aur|string|"
|
||||
printf -- '%s\n' "pkg|string|${pkg_num}"
|
||||
printf -- '%s\n' ""
|
||||
else
|
||||
printf -- '%s\n' "pacman|string|${pacman_num}"
|
||||
printf -- '%s\n' "aur|string|${aur_num}"
|
||||
printf -- '%s\n' "pkg|string|${pkg_num}"
|
||||
printf -- '%s\n' ""
|
||||
fi
|
||||
printf -- '%s\n' "pacman|int|${pacman_num}"
|
||||
printf -- '%s\n' "aur|int|${aur_num}"
|
||||
printf -- '%s\n' "pkg|int|${pkg_num}"
|
||||
printf -- '%s\n' ""
|
||||
|
||||
sleep "${interval}"
|
||||
|
||||
done
|
||||
|
||||
unset -v interval no_update aur_helper pacman_num aur_num pkg_num
|
||||
unset -v interval aur_helper pacman_num aur_num pkg_num
|
||||
unset -f _err
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue