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-1018490

Wonky's questions

Martin Hope
Wonky
Asked: 2020-05-11 22:03:01 +0800 CST

如何更改执行 .desktop 文件的默认终端?

  • 7

我一直在尝试以 alacritty 作为默认值来执行 vim。我已经将 alacritty 设置为我的默认终端模拟器,并且在我的 vim.desktop 中我更改exec=vim %F为exec=alacritty -e vim %F. 问题是当我打开一个文件时,它首先在 gnome 终端中执行命令,然后在 alacritty 中启动 vim,问题是 gnome 终端保持打开状态。我也尝试过创建一个脚本:

#!/bin/bash
alacritty -e vim & disown | exit

这根本不起作用。我不知道还能做什么,我在网上找不到任何东西。提前致谢!

是否可以更改运行Exec=命令的默认终端?这样一来,只要写Exec=vim %F下来,它就可以轻快地运行

vim command-line bash .desktop
  • 3 个回答
  • 4038 Views
Martin Hope
Wonky
Asked: 2019-11-25 11:09:17 +0800 CST

如何读取 .json 以输出特定数字?

  • 4

你好我一直在使用这个:

curl -s "http://api.openweathermap.org/data/2.5/forecast?id=6361046&APPID=6be5e3a6e62680c28044791e8fc7b568&units=metric" -o ~/.cache/weather.json

在我的缓存文件夹中写入一个 weather.json 文件。输出是这个。问题是它只在 1 行中,我正在尝试使用 grep 来获取今天的图标值的输出:

{"cod":"200","message":0,"cnt":40,"list":[{"dt":1574629200,"main":{"temp":12.8,"temp_min":12.8,"temp_max":13.07,"pressure":1020,"sea_level":1020,"grnd_level":1012,"humidity":82,"temp_kf":-0.27},"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04n"}]

在这种情况下是“04n”所以我可以使用这样的东西:

~/.weather-icons/$(grep "icon" ~/.cache/weather.json).png

这将输出~/.weather-icons/04n.png,因此我可以使用文件夹中与图标值同名的图标使用 $image 在 conky 中显示。我的问题是我怎样才能完成这项工作?我不知道是否有更好的命令来使用此处显示的参数读取 file.json,或者是否有一种方法可以使用 grep 来输出图标值。谢谢

conky grep json
  • 2 个回答
  • 1905 Views
Martin Hope
Wonky
Asked: 2019-11-23 09:40:45 +0800 CST

我怎样才能让 Conky 显示天气?

  • 4

我一直在努力让 conky 显示天气,我刚刚安装它,发现 yahoo 停止了 conky 主题正在使用的 api url(http://weather.yahooapis.com/forecastrss?w= 1103816&u=c),我尝试将 url 更改为 accuweather 和 openweather ,但什么也没有。我只是不明白这是如何工作的,我不知道如何让它正常工作,这里是代码:

##Weather
${image .jelly-weather-icons/conky_icons/circle2.png -s 190x190}
${texeci 1300 curl -s "http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRIC}#\&locCode\=$LOCCOD" -o #~/.cache/weather.xml}
${voffset -110}${offset 425}${font ITC Avant Garde Gothic Pro:bold:size=20}${execi 1300 grep #"yweather:condition" ~/.cache/weather.xml | grep -o "temp=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | #grep -o "[^\"]*"}${font ITC Avant Garde Gothic Pro:bold:size=8}${voffset -16}o${voffset 14}${font}#${color1}
${execi 1300 cp -f .weather-icons/$(grep "yweather:condition" ~/.cache/weather.xml | grep -o #"code=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*").png ~/.cache/weather.png}${image #~/.cache/weather.png -p 425,23 -s 35x35}
${offset 420}${voffset -105}${font ITC Avant Garde Gothic Pro:size=14} Sevilla

顺便说一句,我在互联网上找不到任何可以帮助我的东西......在此先感谢:)

Edit1:这是conky主题保存在cache/weather.xml中的api http://api.openweathermap.org/data/2.5/forecast?id=6361046&APPID=6be5e3a6e62680c28044791e8fc7b568 我正在慢慢理解它是如何工作的

Edit2:这就是代码现在的样子,我注意到我打错了一些 # 试图评论整个天气部分。我只是不明白 conky 如何读取 xml(我自己不知道如何读取 xml,但我想我可以通过一些 xml 指南来解决这个问题:P)

##Weather
${image .jelly-weather-icons/conky_icons/circle2.png -s 190x190}
${texeci 1300 curl -s "http://api.openweathermap.org/data/2.5/forecast?id=6361046&APPID=6be5e3a6e62680c28044791e8fc7b568&units=metric" -o ~/.cache/weather.xml}
${voffset -110}${offset 425}${font ITC Avant Garde Gothic Pro:bold:size=20}${execi 1300 grep "weather:description" ~/.cache/weather.xml | grep -o "temp=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*"}${font ITC Avant Garde Gothic Pro:bold:size=8}${voffset -16}o${voffset 14}${font}${color1}
${execi 1300 cp -f .weather-icons/$(grep "yweather:condition" ~/.cache/weather.xml | grep -o "code=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*").png ~/.cache/weather.png}${image ~/.cache/weather.png -p 425,23 -s 35x35}
${offset 420}${voffset -105}${font ITC Avant Garde Gothic Pro:size=14} Sevilla

Edit3:感谢@WinEunuuchs2Unix和@steeldriver ,我终于让它工作了,这就是代码最终寻找想要在他们的 conky 代码中使用它的任何人的方式:

##Weather

${voffset -80}${offset 435}${font ITC Avant Garde Gothic Pro:bold:size=20}${execi 1300 curl -s "http://api.openweathermap.org/data/2.5/forecast?id=6361046&APPID=6be5e3a6e62680c28044791e8fc7b568&units=metric" | jq -r '.list[0].main.temp' | awk '{printf("%.0f\n", $1)}'}${font ITC Avant Garde Gothic Pro:bold:size=8}${voffset -16}o${voffset 24}${font}${color1}
${execi 1300 cp -f .iconos/$(curl -s "http://api.openweathermap.org/data/2.5/forecast?id=6361046&APPID=6be5e3a6e62680c28044791e8fc7b568&units=metric" | jq -r '.list[0].weather[].icon').png ~/.cache/weather.png}${image ~/.cache/weather.png -p 425,20 -s 60x60}
${offset 420}${voffset -115}${font ITC Avant Garde Gothic Pro:bold:size=14} Sevilla

基本上它的作用是使用从openweather url读取一个json curl,并jq搜索温度的值.list[0].weather[].icon和.list[0].main.temp温度,它输出一个带有2位十进制数字的值,我使用其余代码将其剪掉以供个人喜好awk '{printf("%.0f\n", $1)}'只是conky的了解您想要它的位置以及您想要它的方式的方法。如果您想自己使用它,只需更改Sevilla您的城市,并更改curl -s "...your location api url..."注意,如果您为您的 api url 使用不同的站点,则必须更改jq以适应新的 json 数据。另请注意,您必须使用此图标列表中的所有图标创建一个文件夹或使用您自己的图标,但请记住使用相同的命名(01d.png,02d.png,...)并且不要忘记编辑这个${execi 1300 cp -f .iconos/$(curl -s "http:/...并替换.iconos/为您的文件夹的目录。

如果您想尝试 conky 主题,请在这里

conky weather 18.04
  • 5 个回答
  • 11775 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