Add community scripts for i3blocks

This commit is contained in:
2020-02-19 15:55:35 +00:00
parent 3233439d88
commit 3236629420
19 changed files with 746 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
################################
# Calculates a given expression
#
# Dependencies:
# - bc
#
# @param {String} 1: The expression to calculate
# @return {Number}: The result of the expression
################################
calc() {
echo "$1" | bc
}
################################
# Counts lines in text, accounting for empty values
#
# @param {String} 1: The input text
# @return {Number}: The number of lines
################################
numLines() {
if [[ "$1" == "" ]]; then
echo 0
else
echo "$1" | wc -l
fi
}
cacheDir=".cache"
cacheFile="$cacheDir/i3-blocks-contrib-${BLOCK_NAME}"
if [[ -z $cacheDir ]]; then
mkdir $cacheDir
fi
getCache() {
cat $cacheFile || echo $1
}
setCache() {
echo "$1" > $cacheFile
}