OK
Mit der "Präsentation" war von mir eigentlich als Scherz gemeint...
Das artet dann richtig in Arbeit aus, ops. Ich will es dir aber so einfach, wie möglich machen. Sei dir bewußt, @damo ist Conky-Oberklasse!
Es wird für die zwei Conky folgendes benötigt;
Pakete:conky-all
lm-sensors
jq
-zur Ermittlung des Standortes:
http://bulk.openweathermap.org/sample/city.list.json.gz-für Chemnitz wäre das die ID=6548487 (habe ich in der Konfiguration überall eingetragen
)
Fonts:Dustismo
Liberation
Monofur
Avantgarde
Birdman
Die zwei bereits gezeigten
Konfigurationen. Mit diesen (wegen Chemnitz) Änderungen nach
conky.text = [[ für das Wetter ist zu verändern:
};
conky.text = [[
${execpi 300 bash /home/unklarer/damo-weather/lua-weather.sh Chemnitz,DE}\
${color0}${voffset 180} #${alignc}${font monofur bold:size=12}${time %H:%M}
#${alignc}${font monofur bold:size=8}${time %a.%d. %b}
${alignc -30}${font monofur bold:size=7}Chemnitz${font}
]];
und
conky.text = [[ für den rainmeter-Conky
};
conky.text = [[
${color}${font AvantGarde LT ExtraLight:pixelsize=150}${alignr}${time %H}
${voffset -65}${alignr}${color3}${time %M}
${voffset -90}${color}${font AvantGarde LT ExtraLight:pixelsize=20}${alignr}${time %A} | ${alignr}${time %d.%B %Y}
${voffset 20}${color}${font}ram ${alignr}${mem} / ${memmax}
cpu ${alignr}${cpu cpu0}%
cpu temp ${alignr}${color}${hwmon 1 temp 2} °C
GPU ${alignr}${hwmon 2 temp 1} °C
fs ${alignr}${fs_used_perc /}% / ${fs_size /}
${voffset 30}${alignr}${kernel}
${hr}
${font Birdman}Siduction ${alignr} W E A T H E R
#${goto 40}${font liberation mono:size=9}${execi 600 curl 'wttr.in/leipzig?q?0?T'}${font}
${hr}
${font Birdman}Linux News DE ${alignr}F E E D
${font AvantGarde LT ExtraLight:pixelsize=14}${rss http://feeds.feedburner.com/linuxnewsde/ 15 item_titles 4 2}
#${rss https://forum.siduction.org/index.php?action=.xml;type=rss/ 15 item_titles 3 2}
#${color}${font AvantGarde LT ExtraLight:pixelsize=14}${voffset 2}${execi 300 $HOME/.conky/damo/elegance-atomfeed.sh}
${hr}
]];
das lua-weather-script
lua-weather.sh#!/bin/bash
#
## lua-weather.sh by <damo> July 2016
## Adapted from bunsenweather.sh, which was based on ideas from
## weatherbang.sh version 1.0, 2013 by Ryan Fantus
##
## Requires:
## 'jq' (sudo apt-get install jq);
## API Key from http://openweathermap.org/api
##
## USAGE: Call this script from Conky with ( replace "<t>" with the update interval)
## ${execpi <t> /path/to/lua-weather.sh [location]}
#### User configurables: ##############################################
# Get API KEY by registering for one at http://openweathermap.org/api
api="cbcdd9a40999d5d68afc55145f756764"
# Either set the location manually here, or by passing it as a script parameter in the Conky.
# "yourlocation" must be a name (which doesn't have spaces), or a numeric id.
#
# id's can be obtained from http://bulk.openweathermap.org/sample/city.list.json.gz
# Download and extract the json file, then simply search for an id with grep.
# For example: grep "New York" city.list.json
#
# If $place is not set, then the script attempts to get a geolocation from the IP address.
place="$1" # Get $place from script parameter.
place="6548487" # Uncomment and add name or id. NB If the name has spaces, then you must use the id.
# Choose fahrenheit/Imperial or Celcius/metric:
#metric='imperial'
metric='metric'
# data file
datafile="/home/unklarer/tmp/weather.txt"
#########################################################################
connectiontest() {
local -i i attempts=${1-0}
for (( i=0; i < attempts || attempts == 0; i++ )); do
if wget -O - 'http://ftp.debian.org/debian/README' &> /dev/null; then
return 0
fi
if (( i == attempts - 1 )); then # if last attempt
return 1
fi
done
}
placeholder() {
if (( $1 == 1 )) &>/dev/null;then
echo "No internet connection"
echo "Weather information unavailable"
else
echo "No API key"
echo "Weather information unavailable"
fi
}
if [[ $metric == metric ]] &>/dev/null;then
scaleT="°C"
scaleV="m/s"
else
scaleT="°F"
scaleV="mph"
fi
if [[ -z "$api" ]] &>/dev/null;then
placeholder 0 && exit 1
else
connectiontest 10
# If latlong is preferred then don't set a value for $place
if (( $? == 0 )) &>/dev/null;then
if [[ -z $place ]] &>/dev/null;then
# Geolocate IP:
ipinfo=$(curl -s ipinfo.io)
latlong=$(echo "$ipinfo" | jq -r '.loc')
# Parse the latitude and longitude
lat=${latlong%,*}
long=${latlong#*,}
location="lat=$lat&lon=$long"
else
# check if numeric id, or placename is being used
[[ ${place##*[!0-9]*} ]] &>/dev/null && location="id=$place" || location="q=$place"
fi
# get json data from openweathermap:
weather=$(curl -s http://api.openweathermap.org/data/2.5/weather\?APPID=$api\&"$location"\&units=$metric)
city=$(echo "$weather" | jq -r '.name') # In case location has spaces in the name
weather_desc=$(echo "$weather" | jq -r '.weather[0].description') # In case description has spaces in the name
# load values into array:
all=($(echo "$weather" | jq -r '.coord.lon,.coord.lat,.weather[0].main,.main.temp,.main.pressure,.main.temp_min,.main.temp_max,.wind.speed,.wind.deg,.clouds.all,.sys.sunrise,.sys.sunset'))
# ARRAY INDEX 0 1 2 3 4 5 6 7 8 9 10 11
longitude=$(printf '%06.1f' ${all[0]})
latitude=$(printf '%+.1f' ${all[1]})
condition="${all[2]}"
temperature=$(printf '%+.1f%s' ${all[3]} $scaleT)
pressure=$(printf '%.f %s' ${all[4]} mb)
temperature_min=$(printf '%+.1f%s' ${all[5]} $scaleT)
temperature_max=$(printf '%+.1f%s' ${all[6]} $scaleT)
cloud_cover=$(printf '%d%s' ${all[9]} %)
sunrise=$(date -d @${all[10]} +"%R")
sunset=$(date -d @${all[11]} +"%R")
description="$weather_desc"
winddir=$(printf '%3.f%s' ${all[8]} °)
winddir=${all[8]}
echo ${winddir%.*} > "$datafile"
windspeed=$(echo ${all[7]}*1.9 | bc)
windspeed=$(printf '%01.1f %s' "$windspeed" "kn")
echo "$windspeed" >> "$datafile"
echo "$sunrise" | sed 's/://' >> "$datafile"
echo "$sunset" | sed 's/://'>> "$datafile"
temp_degrees=$(printf '%.1f' ${all[3]})
echo "$temp_degrees" >> "$datafile"
echo "$city" >> "$datafile"
echo "$description" >> "$datafile"
else
placeholder 1
fi
fi
exit
Der API-Schlüssel war eine Zugabe von damo, er funktioniert noch immer
und, du mußt den Pfad zur tmp-Datei entsprechend anpassen.