blob: b2dd34fe3deee58955f4cca73a7f0ca7c429814a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
 
  |