AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-1771815

konstantinosr's questions

Martin Hope
konstantinosr
Asked: 2024-02-28 20:13:50 +0800 CST

如何用conky正确显示天气?

  • 6

我对 conky 中的主题有问题,更具体地说,对 conky 小部件有问题。该主题名为“alsafi”并且工作正常,但天气小部件默认显示博洛尼亚(意大利)的天气。我更改了 中的 API 密钥和城市 ID ~/.config/conky/Alsafi/scripts/weather2.sh,但即使在重新启动并重新启动 conky 后,它仍然显示博洛尼亚。问题可能是什么?

注意:主题从 conky manager 2 运行,因此位置是~/.conky。

编辑后的文件:weather-v2.0.sh

# This script is to get weather data from openweathermap.com in the form of a json file
# so that conky will still display the weather when offline even though it doesn't up to date

# Variables
# get your city id at https://openweathermap.org/find and replace
city_id=256639 #<---modified to display my city 

# replace with yours
api_key=c99cf91646e0ca8d6ff63957a1d20552 #<--- personal api key

# choose between metric for Celcius or imperial for fahrenheit
unit=metric

# i'm not sure it will support all languange, 
lang=en

# Main command
url="api.openweathermap.org/data/2.5/weather?id=${city_id}&appid=${api_key}&cnt=5&units=${unit}&lang=${lang}"
curl ${url} -s -o ~/.cache/weather.json

exit

运行后grep -iRE 'Alsafi|weather.sh' ~/.conky ~/.config/conky终端输出为:

/home/kr/.conky/Sirius/Changelog:-  New Weather.sh
/home/kr/.conky/conky-startup.sh:cd "$HOME/.conky/Alsafi"
/home/kr/.conky/conky-startup.sh:conky -c "$HOME/.conky/Alsafi/Alsafi.conf" &
/home/kr/.conky/Alsafi/Changelog:Alsafi - Conky Theme
/home/kr/.conky/Alsafi/Alsafi.conf:--  ALSAFI
/home/kr/.conky/Alsafi/Alsafi.conf:${execi 600 ~/.config/conky/Alsafi/scripts/weather-v2.0.sh}\
/home/kr/.conky/Alsafi/Alsafi.conf:${offset 0}${voffset 10}${color}${font feather:size=20}${execi 15 ~/.config/conky/Alsafi/scripts/weather-text-icon}${goto 73}${font}
/home/kr/.conky/Alsafi/Alsafi.conf:${offset 0}${voffset 0}${color1}${font Barlow:bold:size=13}${exec ~/.config/conky/Alsafi/scripts/playerctl.sh}
/home/kr/.conky/Alsafi/Alsafi.conf:${offset 0}${voffset 0}${font Barlow:bold:size=10}Wi-Fi : ${execi 5 ~/.config/conky/Alsafi/scripts/ssid}
/home/kr/.conky/Alsafi/start.sh:conky -c $HOME/.config/conky/Alsafi/Alsafi.conf &> /dev/null &
/home/kr/.config/conky/Sirius/Changelog:-   New Weather.sh

好的,重新启动 conky 后,缓存中就有了 Weather.json

➜  ~ cat ~/.cache/weather.json     
{"coord":{"lon":11.4333,"lat":44.4667},"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04n"}],"base":"stations","main":{"temp":11.95,"feels_like":11.66,"temp_min":10.77,"temp_max":13.14,"pressure":1016,"humidity":94},"visibility":7000,"wind":{"speed":3.09,"deg":40},"clouds":{"all":75},"dt":1709155681,"sys":{"type":2,"id":2004497,"country":"IT","sunrise":1709099691,"sunset":1709139562},"timezone":3600,"id":3181927,"name":"Bologna","cod":200}

所以最后经过更多的研究,问题解决了。原因是权限。weather.json 文件有权限从我这里写入和读取,但没有从其他应用程序读取的权限,所以它无法从 api 获取数据。使用 gui 更改权限后问题解决了。感谢您的时间和帮助,我真的很感激。

themes
  • 1 个回答
  • 118 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve