Custom component using wttr.in #549
pauljacobson
started this conversation in
Configuration
Replies: 1 comment 1 reply
-
You could do something like this _G.WeatherStatus = ''
local function update_weather()
_G.WeatherStatus = vim.trim(vim.fn.system("curl -s wttr.in/Nuremberg?format=3"))
end
if _G.Update_weather_timer == nil then
_G.Update_weather_timer = vim.loop.new_timer()
else
_G.Update_weather_timer:stop()
end
_G.Update_weather_timer:start(0, -- never timeout
10*60*1000, -- repeat every 10 minutes
vim.schedule_wrap(update_weather))
require'lualine'.setup {
sections = {
lualine_c = {
function () return _G.WeatherStatus end,
}
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there. I'd like to add a weather indicator to my lualine status bar as a custom icon. I'm not that familiar with Lua, so I'd appreciate some help with this. On the command line, I could run a command like
curl wttr.in/Nuremberg?format=3
to produce a result like this:Nuremberg: 🌦 +11⁰C
(source: wttr.in is a console-oriented weather forecast service that supports various information representation methods)
How would I write a custom component to invoke this in lualine? It seems like a simpler alternative to something like wyattjsmith1/weather.nvim: A simple plugin to display weather on nvim.
Beta Was this translation helpful? Give feedback.
All reactions