您尚未登录。

#1 2021-03-18 20:51:39

naturennn
会员
注册时间: 2011-08-20
帖子: 27

tint2面板上无法显示天气

在executor中使用了一个脚本来显示天气,但未能显示出来。
tint2rc 中的相关内容为:

# Executor 2
execp = new
execp_command = ~/.config/tint2/executors/weather
execp_interval = 0
execp_has_icon = 1
execp_cache_icon = 0
execp_continuous = 0
execp_markup = 1
execp_tooltip = Current weather --> leftclick for 7days weather forecast
execp_lclick_command = exo-open https://openweathermap.org/city/2747891
execp_rclick_command = 
execp_mclick_command = 
execp_uwheel_command = 
execp_dwheel_command = 
execp_font = Iosevka 12
execp_font_color = #eeeeee 100
execp_padding = 8 0
execp_background_id = 5
execp_centered = 0
execp_icon_w = 18
execp_icon_h = 18

weather的内容如下:

#!/bin/bash
#
# ===========================================================
# Based on script from @Anachron's i3blocks, as well as 
# @Addy's icon additions and @Nili's network-connection check
# Mod by @ceeslans, to draw icons from tint2 config folder
# ===========================================================

# Open Weather Map API code, register to http://openweathermap.org to get one :
API_KEY="a2f26c91faf50ba2f7875987d19e8358"

# Check on http://openweathermap.org/find :
CITY_ID="1808872"

# Select applicable temperature symbol "˚C" or "˚F" :
SYMBOL_CELSIUS="˚C"

# Change "Text" to your preferred language :
TEXT_SNOW="Snow"
TEXT_RAINY="Rainy"
TEXT_DRIZZLE="Drizzle"
TEXT_SHOWERS="Showers"
TEXT_SUNNY="Sunny"
TEXT_CLEAR="Clear"
TEXT_CLOUDY="Cloudy"
TEXT_OVERCAST="Overcast"
TEXT_STORM="Storm"
TEXT_FOG="Fog"

# Show Papirus weather-icons :
# ICONPATH="$HOME/.config/tint2/executors/icons/weather/"
# or show original openweathermap weather-icons :
#ICONPATH="$HOME/.config/tint2/executors/icons/weather/openweathermap/"

# Don't change these lines, unless you know what you're doing...
WEATHER_URL="http://api.openweathermap.org/data/2.5/weather?id=${CITY_ID}&appid=${API_KEY}&units=metric"

WEATHER_INFO=$(wget -qO- "${WEATHER_URL}")
WEATHER_MAIN=$(echo "${WEATHER_INFO}" | grep -o -e '\"main\":\"[A-Za-z]*\"' | awk -F ':' '{print $2}' | tr -d '"')
WEATHER_TEMP=$(echo "${WEATHER_INFO}" | grep -o -e '\"temp\":\-\?[0-9]*' | awk -F ':' '{print $2}' | tr -d '"')
# WEATHER_ICON=$(echo "${WEATHER_INFO}" | grep -o -e '\"icon\":\"[0-9a-z]*\"' | awk -F ':' '{print $2}' | tr -d '"')

# To add short condition description in the toolbar, comment out # ${TEXT-*} :

if [[ "${WEATHER_MAIN}" = *Snow* ]]; then
	echo "❄"
    	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_SNOW}"
    
elif [[ "${WEATHER_MAIN}" = *Rain* ]]; then
	echo "?"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}"	# "${TEXT_RAINY}"

elif [[ "${WEATHER_MAIN}" = *Drizzle* ]]; then
	echo "?"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_DRIZZLE}"

elif [[ "${WEATHER_MAIN}" = *Shower* ]]; then
	echo "?"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_SHOWERS}"

elif [[ "${WEATHER_MAIN}" = *Sunny* ]]; then
	echo "☀"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_SUNNY}"
	
elif [[ "${WEATHER_MAIN}" = *Clear* ]]; then
	echo "?"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_CLEAR}"
	
elif [[ "${WEATHER_MAIN}" = *Cloud* ]]; then
	echo "☁"
    echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_CLOUDY}"

elif [[ "${WEATHER_MAIN}" = *Overcast* ]]; then
	echo "?"
    echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_OVERCAST}"
    
elif [[ "${WEATHER_MAIN}" = *Storm* ]]; then
	echo "?"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_STORM}"
    
elif [[ "${WEATHER_MAIN}" = *Fog* ]]; then
	echo "?"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_FOG}"

else
	echo "  "
        echo "${WEATHER_TEMP}${SYMBOL_CELSIUS} ${WEATHER_MAIN}"
fi 

终端里执行tint2的时候,显示的错误信息为

***** Imlib2 Developer Warning ***** :
	This program is calling the Imlib call:

	imlib_image_set_never_changes_on_disk();

	With the parameter:

	image

	being NULL. Please fix your program.

搜了一通,也不知道怎么解决。其他的executor,图片显示都没有什么问题。
请大家帮忙看看,谢谢了。

离线

页脚