wording and other minor improvments
This commit is contained in:
@@ -39,11 +39,14 @@
|
|||||||
# Usage: ver
|
# Usage: ver
|
||||||
ver()
|
ver()
|
||||||
{
|
{
|
||||||
local PARSED=$(getopt -o h --long help -n 'ver' -- "$@")
|
local PARSED
|
||||||
|
|
||||||
|
PARSED=$(getopt -o h --long help -n 'ver' -- "$@")
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
disp E "Invalid options, use \"ver --help\" to display usage."
|
disp E "Invalid options, use \"ver --help\" to display usage."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
eval set -- "$PARSED"
|
eval set -- "$PARSED"
|
||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@@ -72,11 +75,13 @@ export -f ver
|
|||||||
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Display weather of the given city (or default one)
|
# Display weather for the given city (or the default one)
|
||||||
# Usage: meteo [city1 city2 ...]
|
# Usage: meteo [city1 city2 ...]
|
||||||
meteo()
|
meteo()
|
||||||
{
|
{
|
||||||
local PARSED=$(getopt -o h --long help -n 'meteo' -- "$@")
|
local PARSED
|
||||||
|
|
||||||
|
PARSED=$(getopt -o h --long help -n 'meteo' -- "$@")
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
disp E "Invalid options, use \"meteo --help\" to display usage."
|
disp E "Invalid options, use \"meteo --help\" to display usage."
|
||||||
return 1
|
return 1
|
||||||
@@ -85,7 +90,9 @@ meteo()
|
|||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h|--help)
|
-h|--help)
|
||||||
printf "meteo: Fetch weather data.\nUsage: meteo [city1 city2 ...]\n"
|
printf "meteo: Fetch weather data.\n"
|
||||||
|
printf "Usage: meteo [city1 city2 ...]\n"
|
||||||
|
printf "If no city is provided, the default city from configuration will be used.\n"
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--)
|
--)
|
||||||
@@ -100,12 +107,13 @@ meteo()
|
|||||||
done
|
done
|
||||||
|
|
||||||
local cities=("$@")
|
local cities=("$@")
|
||||||
|
local city="" encoded=""
|
||||||
[[ $# -eq 0 ]] && cities=("$DEFAULT_CITY")
|
[[ $# -eq 0 ]] && cities=("$DEFAULT_CITY")
|
||||||
|
|
||||||
for city in "${cities[@]}"; do
|
for city in "${cities[@]}"; do
|
||||||
encoded=$(urlencode "$city")
|
encoded=$(urlencode "$city")
|
||||||
dwl "https://wttr.in/$encoded" || \
|
dwl "https://wttr.in/$encoded" || \
|
||||||
disp E "Failed fetching datas for $city."
|
disp E "Failed to fetch weather data for $city."
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
export -f meteo
|
export -f meteo
|
||||||
@@ -117,16 +125,20 @@ export -f meteo
|
|||||||
# Usage: showinfo
|
# Usage: showinfo
|
||||||
showinfo()
|
showinfo()
|
||||||
{
|
{
|
||||||
local PARSED=$(getopt -o h --long help -n 'showinfo' -- "$@")
|
local PARSED
|
||||||
|
|
||||||
|
PARSED=$(getopt -o h --long help -n 'showinfo' -- "$@")
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
disp E "Invalid options, use \"showinfo --help\" to display usage."
|
disp E "Invalid options, use \"showinfo --help\" to display usage."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
eval set -- "$PARSED"
|
eval set -- "$PARSED"
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h|--help)
|
-h|--help)
|
||||||
printf "showinfo: Display system information (hostname, kernel, uptime).\nUsage: showinfo\n"
|
printf "showinfo: Display system information (hostname, kernel, uptime and fetch output when available).\n"
|
||||||
|
printf "Usage: showinfo\n"
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--)
|
--)
|
||||||
@@ -140,20 +152,20 @@ showinfo()
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
local hostname_str
|
||||||
|
local figopt=()
|
||||||
|
hostname_str="$(hostname)"
|
||||||
|
|
||||||
printf "\n"
|
printf "\n"
|
||||||
if command -v figlet >/dev/null 2>&1; then
|
if command -v figlet >/dev/null 2>&1; then
|
||||||
if [[ -s /usr/share/figlet/ansi_shadow.flf ]]; then
|
[[ -s /usr/share/figlet/ansi_shadow.flf ]] && \
|
||||||
local figopt="-f ansi_shadow"
|
figopt=(-f ansi_shadow)
|
||||||
fi
|
figlet -k "${figopt[@]}" "$hostname_str"
|
||||||
if [[ -n $figopt ]]; then
|
|
||||||
figlet -k $figopt $(hostname)
|
|
||||||
else
|
|
||||||
figlet $(hostname)
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
hostname -f
|
printf "%s\n" "$hostname_str"
|
||||||
fi
|
fi
|
||||||
echo ""
|
|
||||||
|
printf "\n"
|
||||||
if command -v neofetch >/dev/null 2>&1; then
|
if command -v neofetch >/dev/null 2>&1; then
|
||||||
neofetch
|
neofetch
|
||||||
elif command -v fastfetch >/dev/null 2>&1; then
|
elif command -v fastfetch >/dev/null 2>&1; then
|
||||||
@@ -163,11 +175,11 @@ showinfo()
|
|||||||
if [[ -s /etc/os-release ]]; then
|
if [[ -s /etc/os-release ]]; then
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
. /etc/os-release
|
. /etc/os-release
|
||||||
printf "$NAME $VERSION\n"
|
printf "%s %s\n" "$NAME" "$VERSION"
|
||||||
else
|
else
|
||||||
cat /proc/version
|
cat /proc/version
|
||||||
fi
|
fi
|
||||||
printf "Uptime: $(uptime -p)\n"
|
printf "Uptime: %s\n" "$(uptime -p)"
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user