Skip to content

Instantly share code, notes, and snippets.

@sistematico
Created June 15, 2016 07:09
Show Gist options
  • Select an option

  • Save sistematico/3440690be0e1d5c3414eeef93465cfa6 to your computer and use it in GitHub Desktop.

Select an option

Save sistematico/3440690be0e1d5c3414eeef93465cfa6 to your computer and use it in GitHub Desktop.
Simples script para mostrar temperatura e condições meteorológicas no Conky ou no Terminal
#!/bin/sh
# AccuWeather (r) RSS weather tool for conky
#
# USO: weather.sh <locationcode>
# (espaços precisam ser substituidos por %20)
#
# (c) Michael Seiler 2007
# Alterações por Lucas Saliés Brum a.k.a. sistematico, <lucas at archlinux dot com dot br>
#
# Lista de localidades: http://bit.ly/28Dll5G
# Fonte: https://bbs.archlinux.org/viewtopic.php?id=37381
# 0 para F e 1 para C
METRICA=1
if [ -z "$1" ]; then
# Local padrão
LOCALIDADE='SAM|BR|BR010|CAMPO%20GRANDE'
else
if [ "$1" == "-h" ]; then
echo
echo "USO: weather.sh <localidade> -c"
echo " weather.sh <localidade> -t"
echo
echo "Exemplo: weather.sh 'SAM|BR|BR010|CAMPO%20GRANDE' -c"
echo
exit 0;
fi
LOCALIDADE=$1
fi
# Default
#curl -s http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRIC}\&locCode\=$1 | perl -ne 'if (/Currently/) {chomp;/\<title\>Currently: (.*)?\<\/title\>/; print "$1"; }'
# Perl
#out=`curl --connect-timeout 30 -s http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRICA}\&locCode\=$LOCALIDADE | perl -ne 'if (/Currently/) {chomp;/\<title\>Currently: (.*)?\<\/title\>/; print "$1"; }'`
# SED
out=`curl --connect-timeout 30 -s http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRICA}\&locCode\=$LOCALIDADE | grep '<title>Currently' | sed "s/<title>Currently://;s/<\/title>//g"`
cond1=`echo $out | cut -d':' -f 1`
temp=`echo $out | cut -d':' -f 2 | cut -c 2-4`
case "$cond1" in
'Fog') cond="Neblina" ;;
'Snow') cond="Nevando" ;;
'Cloudy') cond="Nublado" ;;
'Sunny') cond="Ensolarado" ;;
'T-Storms') cond="Pancada" ;;
'Mostly Clear') cond="Parcialmente Limpo" ;;
'Clear') cond="Limpo" ;;
*) cond=$cond1 ;;
esac
if [ "$2" == "-t" ]; then
echo -e "$temp"
elif [ "$2" == "-c" ]; then
echo -e "$cond"
else
echo -e "$cond $temp"
fi
exit 0
@Ser4ph4
Copy link

Ser4ph4 commented Mar 2, 2021

qual a chamada no conky ?

@sistematico
Copy link
Author

qual a chamada no conky ?

Já fazem 5 anos, eu não uso mais o Conky e não me lembro.
Procura pela variável exec ou execi na documentação.

http://conky.sourceforge.net/variables.html

@Ser4ph4
Copy link

Ser4ph4 commented Mar 3, 2021

Blz man.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment