diff options
Diffstat (limited to 'nixos/scripts/dm-weather')
-rwxr-xr-x | nixos/scripts/dm-weather | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/nixos/scripts/dm-weather b/nixos/scripts/dm-weather new file mode 100755 index 0000000..b2dd34f --- /dev/null +++ b/nixos/scripts/dm-weather @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# +# Script name: dm-weather +# Description: Simple graphical weather app +# Dependencies: dmenu, curl, yad +# GitLab: https://www.gitlab.com/dwt1/dmscripts +# License: https://www.gitlab.com/dwt1/dmscripts/LICENSE +# Contributors: HostGrady +# Derek Taylor + +# Set with the flags "-e", "-u","-o pipefail" cause the script to fail +# if certain things happen, which is a good thing. Otherwise, we can +# get hidden bugs that are hard to discover. +set -euo pipefail + +# shellcheck disable=SC1091 +source ./_dm-helper.sh 2>/dev/null || source _dm-helper.sh 2>/dev/null + +source_dmscripts_configs + +if configs_are_different; then + echo "$(date): configs are different" >>"$DM_CONFIG_DIFF_LOGFILE" + sleep 1 +fi + +main() { + # Here we obtain the location from the list in the config + # As this is loaded from other file it is technically not defined + # shellcheck disable=SC2154 + _location="$(printf '%s\n' "${weather_locations}" | ${MENU} "Where do you want to see the weather?")" + echo "$_location" + + # If $weather_opts is unset, give it an empty value + weather_opts+='' + + # Curl wttr.in, a CLI weather app. + # curl -s "https://wttr.in/${_location// /%20}?T&${weather_opts}" | yad --text-info --maximized + kitty -e sh -c "curl -s 'https://wttr.in/${_location// /%20}?T&${weather_opts}'; read -n 1 -s" + +} + +MENU="$(get_menu_program "$@")" +[[ "${BASH_SOURCE[0]}" == "${0}" ]] && main |