From 50e893228faea549d28e4b30116380d185eeeb9e Mon Sep 17 00:00:00 2001 From: Leon Connor Holm Date: Tue, 27 Dec 2022 00:38:35 +0100 Subject: [PATCH 1/9] updated current_call and forecast_call api calls --- widget/weather.lua | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/widget/weather.lua b/widget/weather.lua index 6937ca3..7863c57 100644 --- a/widget/weather.lua +++ b/widget/weather.lua @@ -24,11 +24,12 @@ local function factory(args) args = args or {} local weather = { widget = args.widget or wibox.widget.textbox() } - local APPID = args.APPID -- mandatory + local APPID = args.APPID -- mandatory api key local timeout = args.timeout or 60 * 15 -- 15 min - local current_call = args.current_call or "curl -s 'https://api.openweathermap.org/data/2.5/weather?id=%s&units=%s&lang=%s&APPID=%s'" - local forecast_call = args.forecast_call or "curl -s 'https://api.openweathermap.org/data/2.5/forecast?id=%s&units=%s&lang=%s&APPID=%s'" - local city_id = args.city_id or 0 -- placeholder + local current_call = args.current_call or "curl -s 'https://api.openweathermap.org/data/2.5/weather?lat=%s&lon=%s&APPID=%s&units=%s&lang=%s'" + local forecast_call = args.forecast_call or "curl -s 'https://api.openweathermap.org/data/2.5/forecast?lat=%s&lon=%s&APPID=%s&cnt=%s&units=%s&lang=%s'" + local lat = args.lat or 0 -- placeholder + local lon = args.lon or 0 -- placeholder local units = args.units or "metric" local lang = args.lang or "en" local cnt = args.cnt or 5 @@ -87,7 +88,7 @@ local function factory(args) end function weather.forecast_update() - local cmd = string.format(forecast_call, city_id, units, lang, APPID) + local cmd = string.format(forecast_call, lat, lon, APPID, cnt, units, lang) helpers.async(cmd, function(f) local err weather_now, _, err = json.decode(f, 1, nil) @@ -106,11 +107,12 @@ local function factory(args) end function weather.update() - local cmd = string.format(current_call, city_id, units, lang, APPID) + local cmd = string.format(current_call, lat, lon, APPID, units, lang) + helpers.async(cmd, function(f) local err weather_now, _, err = json.decode(f, 1, nil) - + if not err and type(weather_now) == "table" and tonumber(weather_now["cod"]) == 200 then local sunrise = tonumber(weather_now["sys"]["sunrise"]) local sunset = tonumber(weather_now["sys"]["sunset"]) @@ -130,6 +132,7 @@ local function factory(args) weather.icon_path = icons_path .. "na.png" weather.widget:set_markup(weather_na_markup) end + weather.icon:set_image(weather.icon_path) end) @@ -137,8 +140,8 @@ local function factory(args) if showpopup == "on" then weather.attach(weather.widget) end - weather.timer = helpers.newtimer("weather-" .. city_id, timeout, weather.update, false, true) - weather.timer_forecast = helpers.newtimer("weather_forecast-" .. city_id, timeout, weather.forecast_update, false, true) + weather.timer = helpers.newtimer("weather-" .. lat .. ":" .. lon, timeout, weather.update, false, true) + weather.timer_forecast = helpers.newtimer("weather_forecast-" .. lat .. ":" .. lon, timeout, weather.forecast_update, false, true) return weather end From d0b9588cfa4db6174b47091da1e79ab25933f810 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Tue, 3 Jan 2023 17:50:16 +0100 Subject: [PATCH 2/9] build(luarocks): add all modules (#547) --- lain-scm-1.rockspec | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/lain-scm-1.rockspec b/lain-scm-1.rockspec index 70b0f43..a596de1 100644 --- a/lain-scm-1.rockspec +++ b/lain-scm-1.rockspec @@ -17,6 +17,39 @@ dependencies = { supported_platforms = { "linux" } build = { type = "builtin", - modules = { lain = "init.lua" } + modules = { + ["lain"] = "init.lua", + ["lain.helpers"] = "helpers.lua", + ["lain.layout"] = "layout/init.lua", + ["lain.layout.cascade"] = "layout/cascade.lua", + ["lain.layout.centerwork"] = "layout/centerwork.lua", + ["lain.layout.termfair"] = "layout/termfair.lua", + ["lain.util"] = "util/init.lua", + -- ["lain.util.dkjson"] = "util/dkjson.lua", -- RESOLVED BY DEPENDENCY TO dkjson + ["lain.util.markup"] = "util/markup.lua", + ["lain.util.menu_iterator"] = "util/menu_iterator.lua", + ["lain.util.quake"] = "util/quake.lua", + ["lain.util.separators"] = "util/separators.lua", + ["lain.widget"] = "widget/init.lua", + ["lain.widget.contrib"] = "widget/contrib/init.lua", + ["lain.widget.contrib.moc"] = "widget/contrib/moc.lua", + ["lain.widget.contrib.redshift"] = "widget/contrib/redshift.lua", + ["lain.widget.contrib.task"] = "widget/contrib/task.lua", + ["lain.widget.contrib.tp_smapi"] = "widget/contrib/tp_smapi.lua", + ["lain.widget.alsa"] = "widget/alsa.lua", + ["lain.widget.alsabar"] = "widget/alsabar.lua", + ["lain.widget.bat"] = "widget/bat.lua", + ["lain.widget.cal"] = "widget/cal.lua", + ["lain.widget.cpu"] = "widget/cpu.lua", + ["lain.widget.fs"] = "widget/fs.lua", + ["lain.widget.imap"] = "widget/imap.lua", + ["lain.widget.mem"] = "widget/mem.lua", + ["lain.widget.mpd"] = "widget/mpd.lua", + ["lain.widget.net"] = "widget/net.lua", + ["lain.widget.pulse"] = "widget/pulse.lua", + ["lain.widget.pulsebar"] = "widget/pulsebar.lua", + ["lain.widget.sysload"] = "widget/sysload.lua", + ["lain.widget.temp"] = "widget/temp.lua", + ["lain.widget.weather"] = "widget/weather.lua" + } } - From 506ecf2ea27306c205ed816d614b1349df30b7f9 Mon Sep 17 00:00:00 2001 From: Luca Capezzuto Date: Tue, 3 Jan 2023 18:31:02 +0100 Subject: [PATCH 3/9] #547: create new rockspec version --- lain-scm-2.rockspec | 55 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 lain-scm-2.rockspec diff --git a/lain-scm-2.rockspec b/lain-scm-2.rockspec new file mode 100644 index 0000000..352ca8a --- /dev/null +++ b/lain-scm-2.rockspec @@ -0,0 +1,55 @@ +package = "lain" +version = "scm-2" +source = { + url = "git+https://github.com/lcpz/lain.git", + tag = "master" +} +description = { + summary = "Layout, widgets and utilities for Awesome WM", + detailed = "Alternative layouts, asynchronous widgets and utility functions for Awesome WM. Non-Lua dependency: curl (for IMAP, MPD and weather widgets).", + homepage = "https://github.com/lcpz/lain", + license = "GPL2" +} +dependencies = { + "lua >= 5.3", + "dkjson >= 2.6-1" +} +supported_platforms = { "linux" } +build = { + type = "builtin", + modules = { + ["lain"] = "init.lua", + ["lain.helpers"] = "helpers.lua", + ["lain.layout"] = "layout/init.lua", + ["lain.layout.cascade"] = "layout/cascade.lua", + ["lain.layout.centerwork"] = "layout/centerwork.lua", + ["lain.layout.termfair"] = "layout/termfair.lua", + ["lain.util"] = "util/init.lua", + -- ["lain.util.dkjson"] = "util/dkjson.lua", -- RESOLVED BY DEPENDENCY TO dkjson + ["lain.util.markup"] = "util/markup.lua", + ["lain.util.menu_iterator"] = "util/menu_iterator.lua", + ["lain.util.quake"] = "util/quake.lua", + ["lain.util.separators"] = "util/separators.lua", + ["lain.widget"] = "widget/init.lua", + ["lain.widget.contrib"] = "widget/contrib/init.lua", + ["lain.widget.contrib.moc"] = "widget/contrib/moc.lua", + ["lain.widget.contrib.redshift"] = "widget/contrib/redshift.lua", + ["lain.widget.contrib.task"] = "widget/contrib/task.lua", + ["lain.widget.contrib.tp_smapi"] = "widget/contrib/tp_smapi.lua", + ["lain.widget.alsa"] = "widget/alsa.lua", + ["lain.widget.alsabar"] = "widget/alsabar.lua", + ["lain.widget.bat"] = "widget/bat.lua", + ["lain.widget.cal"] = "widget/cal.lua", + ["lain.widget.cpu"] = "widget/cpu.lua", + ["lain.widget.fs"] = "widget/fs.lua", + ["lain.widget.imap"] = "widget/imap.lua", + ["lain.widget.mem"] = "widget/mem.lua", + ["lain.widget.mpd"] = "widget/mpd.lua", + ["lain.widget.net"] = "widget/net.lua", + ["lain.widget.pulse"] = "widget/pulse.lua", + ["lain.widget.pulsebar"] = "widget/pulsebar.lua", + ["lain.widget.sysload"] = "widget/sysload.lua", + ["lain.widget.temp"] = "widget/temp.lua", + ["lain.widget.weather"] = "widget/weather.lua" + } +} From 14d9c637ab3c661c1319116815694bcb7700338f Mon Sep 17 00:00:00 2001 From: Luca Capezzuto Date: Fri, 6 Jan 2023 13:54:14 +0100 Subject: [PATCH 4/9] #546: satisfy review requests --- widget/weather.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/widget/weather.lua b/widget/weather.lua index 7863c57..93028b5 100644 --- a/widget/weather.lua +++ b/widget/weather.lua @@ -25,7 +25,7 @@ local function factory(args) local weather = { widget = args.widget or wibox.widget.textbox() } local APPID = args.APPID -- mandatory api key - local timeout = args.timeout or 60 * 15 -- 15 min + local timeout = args.timeout or 900 -- 15 min local current_call = args.current_call or "curl -s 'https://api.openweathermap.org/data/2.5/weather?lat=%s&lon=%s&APPID=%s&units=%s&lang=%s'" local forecast_call = args.forecast_call or "curl -s 'https://api.openweathermap.org/data/2.5/forecast?lat=%s&lon=%s&APPID=%s&cnt=%s&units=%s&lang=%s'" local lat = args.lat or 0 -- placeholder @@ -89,6 +89,7 @@ local function factory(args) function weather.forecast_update() local cmd = string.format(forecast_call, lat, lon, APPID, cnt, units, lang) + helpers.async(cmd, function(f) local err weather_now, _, err = json.decode(f, 1, nil) @@ -112,7 +113,7 @@ local function factory(args) helpers.async(cmd, function(f) local err weather_now, _, err = json.decode(f, 1, nil) - + if not err and type(weather_now) == "table" and tonumber(weather_now["cod"]) == 200 then local sunrise = tonumber(weather_now["sys"]["sunrise"]) local sunset = tonumber(weather_now["sys"]["sunset"]) @@ -132,7 +133,6 @@ local function factory(args) weather.icon_path = icons_path .. "na.png" weather.widget:set_markup(weather_na_markup) end - weather.icon:set_image(weather.icon_path) end) From c5b18e3313c8983da05a435c98c38bb00ceb64ed Mon Sep 17 00:00:00 2001 From: Luca CPZ <1777696+lcpz@users.noreply.github.com> Date: Thu, 12 Jan 2023 18:33:46 +0000 Subject: [PATCH 5/9] Delete lain-scm-2.rockspec --- lain-scm-2.rockspec | 55 --------------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 lain-scm-2.rockspec diff --git a/lain-scm-2.rockspec b/lain-scm-2.rockspec deleted file mode 100644 index 352ca8a..0000000 --- a/lain-scm-2.rockspec +++ /dev/null @@ -1,55 +0,0 @@ -package = "lain" -version = "scm-2" -source = { - url = "git+https://github.com/lcpz/lain.git", - tag = "master" -} -description = { - summary = "Layout, widgets and utilities for Awesome WM", - detailed = "Alternative layouts, asynchronous widgets and utility functions for Awesome WM. Non-Lua dependency: curl (for IMAP, MPD and weather widgets).", - homepage = "https://github.com/lcpz/lain", - license = "GPL2" -} -dependencies = { - "lua >= 5.3", - "dkjson >= 2.6-1" -} -supported_platforms = { "linux" } -build = { - type = "builtin", - modules = { - ["lain"] = "init.lua", - ["lain.helpers"] = "helpers.lua", - ["lain.layout"] = "layout/init.lua", - ["lain.layout.cascade"] = "layout/cascade.lua", - ["lain.layout.centerwork"] = "layout/centerwork.lua", - ["lain.layout.termfair"] = "layout/termfair.lua", - ["lain.util"] = "util/init.lua", - -- ["lain.util.dkjson"] = "util/dkjson.lua", -- RESOLVED BY DEPENDENCY TO dkjson - ["lain.util.markup"] = "util/markup.lua", - ["lain.util.menu_iterator"] = "util/menu_iterator.lua", - ["lain.util.quake"] = "util/quake.lua", - ["lain.util.separators"] = "util/separators.lua", - ["lain.widget"] = "widget/init.lua", - ["lain.widget.contrib"] = "widget/contrib/init.lua", - ["lain.widget.contrib.moc"] = "widget/contrib/moc.lua", - ["lain.widget.contrib.redshift"] = "widget/contrib/redshift.lua", - ["lain.widget.contrib.task"] = "widget/contrib/task.lua", - ["lain.widget.contrib.tp_smapi"] = "widget/contrib/tp_smapi.lua", - ["lain.widget.alsa"] = "widget/alsa.lua", - ["lain.widget.alsabar"] = "widget/alsabar.lua", - ["lain.widget.bat"] = "widget/bat.lua", - ["lain.widget.cal"] = "widget/cal.lua", - ["lain.widget.cpu"] = "widget/cpu.lua", - ["lain.widget.fs"] = "widget/fs.lua", - ["lain.widget.imap"] = "widget/imap.lua", - ["lain.widget.mem"] = "widget/mem.lua", - ["lain.widget.mpd"] = "widget/mpd.lua", - ["lain.widget.net"] = "widget/net.lua", - ["lain.widget.pulse"] = "widget/pulse.lua", - ["lain.widget.pulsebar"] = "widget/pulsebar.lua", - ["lain.widget.sysload"] = "widget/sysload.lua", - ["lain.widget.temp"] = "widget/temp.lua", - ["lain.widget.weather"] = "widget/weather.lua" - } -} From 8840037e65c9d467acfd6bd425274acaaa0b2f2a Mon Sep 17 00:00:00 2001 From: Luca CPZ <1777696+lcpz@users.noreply.github.com> Date: Thu, 12 Jan 2023 19:37:03 +0000 Subject: [PATCH 6/9] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..49c0ca9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,36 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Please read the [wiki](https://github.com/lcpz/lain/wiki) and browse the [Issues section](https://github.com/lcpz/lain/issues) first.** + +If you can't find a solution, then please provide: + +* output of `awesome -v` and `lua -v` +* expected behavior and actual behavior +* steps to reproduce the problem +* X error log + +### How to provide X error log + +There are two ways: + +* (Physically) Restart X like this: + ```shell + startx -- -keeptty -nolisten tcp > $HOME/.xorg.log 2>&1 + ``` + the error log will be output into `$HOME/.xorg.log`. + +* (Virtually) Use [Xephyr](https://wikipedia.org/wiki/Xephyr): + ```shell + # set screen size as you like + Xephyr :1 -screen 1280x800 2> stdout.txt & DISPLAY=:1 awesome + ``` + the error log will be output in the file `stdout.txt`. + +Before reporting, read the log and see if you can solve it yourself. From 4fa8e10c84306d94b36d7ef719d29a994e22df9c Mon Sep 17 00:00:00 2001 From: Luca CPZ <1777696+lcpz@users.noreply.github.com> Date: Thu, 12 Jan 2023 19:37:20 +0000 Subject: [PATCH 7/9] Delete ISSUE_TEMPLATE.md --- ISSUE_TEMPLATE.md | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 ISSUE_TEMPLATE.md diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md deleted file mode 100644 index e9dcc0b..0000000 --- a/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,33 +0,0 @@ -# Please, read me! - -So that I can help you quickly and without having to redirect you here. - -# If you have an issue - -**Please read the [wiki](https://github.com/lcpz/lain/wiki) and search the [Issues section](https://github.com/lcpz/lain/issues) first.** - -If you can't find a solution there, then go ahead and provide: - -* output of `awesome -v` and `lua -v` -* expected behavior and actual behavior -* steps to reproduce the problem -* X error log - -# How to provide X error log - -There are two ways: - -* (Physically) Restart X like this: - ```shell - startx -- -keeptty -nolisten tcp > $HOME/.xorg.log 2>&1 - ``` - the error log will be output into `$HOME/.xorg.log`. - -* (Virtually) Use [Xephyr](https://wikipedia.org/wiki/Xephyr): - ```shell - # set screen size as you like - Xephyr :1 -screen 1280x800 2> stdout.txt & DISPLAY=:1 awesome - ``` - the error log will be output in the file `stdout.txt`. - -Before reporting, read the log and see if you can solve it yourself. From f832197eaa254fb7030df68b4146c1676852b992 Mon Sep 17 00:00:00 2001 From: Luca Capezzuto Date: Thu, 12 Jan 2023 20:42:39 +0100 Subject: [PATCH 8/9] Add issue template; set up Action to update Rockspec #542 --- .github/ISSUE_TEMPLATE/bug_report.md | 7 ++----- .github/workflows/main.yml | 27 +++++++++++++++++++++++---- lain-scm-1.rockspec | 6 ++++-- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 49c0ca9..d4297ce 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,9 +1,6 @@ --- -name: Bug report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' +name: Bugs +about: Bugs and unintended behavior --- diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 37957f6..3193e0b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,9 +9,28 @@ jobs: linting: runs-on: ubuntu-latest steps: - - run: echo "Running tests triggered by a ${{ github.event_name }} event." - - run: echo "Testing ${{ github.ref }} from ${{ github.repository }} on ${{ runner.os }}" - - name: Check out code + - name: Checkout uses: actions/checkout@v3 - - name: Run tests + + - name: Luacheck linter uses: lunarmodules/luacheck@v0 + + rockspec: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: leafo/gh-actions-lua@v9 + - uses: leafo/gh-actions-luarocks@v4 + + - name: Update Rockspec + shell: bash + env: + LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }} + run: | + if [[ $(git diff *.rockspec | grep "+version") ]] + then + echo "Rockspec changed, uploading to LuaRocks.org" + luarocks upload *.rockspec --api-key "$LUAROCKS_API_KEY" + else + echo "Rockspec unchanged, nothing to do" + fi diff --git a/lain-scm-1.rockspec b/lain-scm-1.rockspec index a596de1..57fd1f5 100644 --- a/lain-scm-1.rockspec +++ b/lain-scm-1.rockspec @@ -1,13 +1,15 @@ +rockspec_format = "3.0" package = "lain" version = "scm-1" source = { - url = "git+https://github.com/lcpz/lain.git", - tag = "master" + url = "git+https://github.com/lcpz/lain.git" } description = { summary = "Layout, widgets and utilities for Awesome WM", detailed = "Alternative layouts, asynchronous widgets and utility functions for Awesome WM. Non-Lua dependency: curl (for IMAP, MPD and weather widgets).", homepage = "https://github.com/lcpz/lain", + issues_url = "https://github.com/lcpz/lain/issues", + maintainer = "Luca Cpz", license = "GPL2" } dependencies = { From 88f5a8abd2649b348ffec433a24a263b37f122c0 Mon Sep 17 00:00:00 2001 From: Luca Capezzuto Date: Thu, 12 Jan 2023 21:22:48 +0100 Subject: [PATCH 9/9] wiki updated --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index ad8081c..d73b84d 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit ad8081cb3e3cb336323d1f72d34c7c8304490b14 +Subproject commit d73b84de973e4087087a371210c6fc0ad88e8bd5