From 9ef2c734cab14737428ce1f03c15a8c4752e09e3 Mon Sep 17 00:00:00 2001 From: Aleksandr Beliaev Date: Mon, 13 May 2019 11:08:46 +1200 Subject: [PATCH 01/35] Weather status icon fix --- widget/weather.lua | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/widget/weather.lua b/widget/weather.lua index c998ed9..9c1e797 100644 --- a/widget/weather.lua +++ b/widget/weather.lua @@ -117,20 +117,7 @@ local function factory(args) local sunrise = tonumber(weather_now["sys"]["sunrise"]) local sunset = tonumber(weather_now["sys"]["sunset"]) local icon = weather_now["weather"][1]["icon"] - local loc_now = os.time() -- local time - local loc_m = os.time { year = os.date("%Y"), month = os.date("%m"), day = os.date("%d"), hour = 0 } -- local time from midnight - local loc_d = os.date("*t", loc_now) -- table YMDHMS for current local time (for TZ calculation) - local utc_d = os.date("!*t", loc_now) -- table YMDHMS for current UTC time - local utc_now = os.time(utc_d) -- UTC time now - local offdt = (loc_d.isdst and 1 or 0) * 3600 + 100 * (loc_d.min - utc_d.min) / 60 -- DST offset - local offset = os.difftime(loc_now, utc_now) + (loc_d.isdst and 1 or 0) * 3600 + 100 * (loc_d.min - utc_d.min) / 60 -- TZ offset (including DST) - local offday = (offset < 0 and -86400) or 86400 -- 24 hour correction value (+86400 or -86400) - - -- if current UTC time is earlier then local midnight -> positive offset (negative otherwise) - if offset * (loc_m - utc_now + offdt) > 0 then - sunrise = sunrise + offday -- Shift sunset and sunrise times by 24 hours - sunset = sunset + offday - end + local loc_now = os.time() if sunrise <= loc_now and loc_now <= sunset then icon = string.gsub(icon, "n", "d") From 025508ce835c3a83484b4d32c179347e51498e9f Mon Sep 17 00:00:00 2001 From: Luca Capezzuto Date: Mon, 27 May 2019 13:12:00 +0100 Subject: [PATCH 02/35] widget.temp: autodetect tempfiles; closes #431 --- helpers.lua | 2 +- widget/cpu.lua | 4 +--- widget/temp.lua | 35 ++++++++++++++++++----------------- wiki | 2 +- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/helpers.lua b/helpers.lua index d3fa259..d6f6b3c 100644 --- a/helpers.lua +++ b/helpers.lua @@ -187,7 +187,7 @@ function helpers.trivial_partition_set(set) return ss end --- creates the powerset of a given set +-- create the powerset of a given set function helpers.powerset(s) if not s then return {} end local t = {{}} diff --git a/widget/cpu.lua b/widget/cpu.lua index 81638c2..f4cce73 100644 --- a/widget/cpu.lua +++ b/widget/cpu.lua @@ -25,9 +25,7 @@ local function factory(args) -- Read the amount of time the CPUs have spent performing -- different kinds of work. Read the first line of /proc/stat -- which is the sum of all CPUs. - local times = helpers.lines_match("cpu","/proc/stat") - - for index,time in pairs(times) do + for index,time in pairs(helpers.lines_match("cpu","/proc/stat")) do local coreid = index - 1 local core = cpu.core[coreid] or { last_active = 0 , last_total = 0, usage = 0 } diff --git a/widget/temp.lua b/widget/temp.lua index 3c93252..513bd38 100644 --- a/widget/temp.lua +++ b/widget/temp.lua @@ -7,33 +7,34 @@ local helpers = require("lain.helpers") local wibox = require("wibox") -local open = io.open local tonumber = tonumber -- coretemp -- lain.widget.temp local function factory(args) - local temp = { widget = wibox.widget.textbox() } - local args = args or {} - local timeout = args.timeout or 2 - local tempfile = args.tempfile or "/sys/class/thermal/thermal_zone0/temp" - local settings = args.settings or function() end + local temp = { widget = wibox.widget.textbox() } + local args = args or {} + local timeout = args.timeout or 30 + local settings = args.settings or function() end function temp.update() - local f = open(tempfile) - if f then - coretemp_now = tonumber(f:read("*all")) / 1000 - f:close() - else - coretemp_now = "N/A" - end - - widget = temp.widget - settings() + helpers.async({"find", "/sys/devices", "-name", "temp"}, function(f) + temp_now = {} + local temp_value + for t in f:gmatch("[^\n]+") do + temp_value = helpers.first_line(t) + if temp_value then + temp_now[tonumber(t:match("%d+"))] = temp_value / 1e3 + end + end + coretemp_now = temp_now[0] or "N/A" + widget = temp.widget + settings() + end) end - helpers.newtimer("coretemp", timeout, temp.update) + helpers.newtimer("thermal", timeout, temp.update) return temp end diff --git a/wiki b/wiki index e5a195c..aaeceb1 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit e5a195cfc013627f21d242fa5110b3added00eb2 +Subproject commit aaeceb1598cbbc27b1ee79d9a8d483fd10a4187a From f1964b40e49dff92abdff97b7bd0408435ed589f Mon Sep 17 00:00:00 2001 From: Luca Capezzuto Date: Wed, 29 May 2019 15:28:38 +0100 Subject: [PATCH 03/35] widget.temp: re-add tempfile argument (#432), but keep retrieving all temperature info (#431); closes #432 --- widget/temp.lua | 24 +++++++++++++----------- wiki | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/widget/temp.lua b/widget/temp.lua index 513bd38..e909b32 100644 --- a/widget/temp.lua +++ b/widget/temp.lua @@ -9,26 +9,28 @@ local helpers = require("lain.helpers") local wibox = require("wibox") local tonumber = tonumber --- coretemp +-- {thermal,core} temperature info -- lain.widget.temp local function factory(args) - local temp = { widget = wibox.widget.textbox() } - local args = args or {} - local timeout = args.timeout or 30 - local settings = args.settings or function() end + local temp = { widget = wibox.widget.textbox() } + local args = args or {} + local timeout = args.timeout or 30 + local tempfile = args.tempfile or "/sys/devices/virtual/thermal/thermal_zone0/temp" + local settings = args.settings or function() end function temp.update() - helpers.async({"find", "/sys/devices", "-name", "temp"}, function(f) + helpers.async({"find", "/sys/devices", "-type", "f", "-name", "*temp*"}, function(f) temp_now = {} - local temp_value + local temp_fl, temp_value for t in f:gmatch("[^\n]+") do - temp_value = helpers.first_line(t) - if temp_value then - temp_now[tonumber(t:match("%d+"))] = temp_value / 1e3 + temp_fl = helpers.first_line(t) + if temp_fl then + temp_value = tonumber(temp_fl) + temp_now[t] = temp_value and temp_value/1e3 or temp_fl end end - coretemp_now = temp_now[0] or "N/A" + coretemp_now = temp_now[tempfile] or "N/A" widget = temp.widget settings() end) diff --git a/wiki b/wiki index aaeceb1..d7fd4db 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit aaeceb1598cbbc27b1ee79d9a8d483fd10a4187a +Subproject commit d7fd4db9122b26e8e8408f3515a0cb1cdb8b03e6 From b5352ef66f705de91157d4583eee728e4cbef8cb Mon Sep 17 00:00:00 2001 From: razamatan Date: Fri, 28 Jun 2019 00:24:01 -0700 Subject: [PATCH 04/35] pulsebar: use devicetype and device instead of sink (null var) --- widget/pulsebar.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widget/pulsebar.lua b/widget/pulsebar.lua index 317468f..8846a4c 100644 --- a/widget/pulsebar.lua +++ b/widget/pulsebar.lua @@ -154,7 +154,7 @@ local function factory(args) end) end - helpers.newtimer(string.format("pulsebar-%s", pulsebar.sink), timeout, pulsebar.update) + helpers.newtimer(string.format("pulsebar-%s-%s", pulsebar.devicetype, pulsebar.device), timeout, pulsebar.update) return pulsebar end From 63186a340c3841522414cc26ad37e58bf92dce1d Mon Sep 17 00:00:00 2001 From: Greg Flynn Date: Sat, 10 Aug 2019 13:27:17 -0400 Subject: [PATCH 05/35] add configuration arguments for pulsebar notification characters --- widget/pulsebar.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/widget/pulsebar.lua b/widget/pulsebar.lua index 8846a4c..53bfc3b 100644 --- a/widget/pulsebar.lua +++ b/widget/pulsebar.lua @@ -40,6 +40,9 @@ local function factory(args) local paddings = args.paddings or 1 local ticks = args.ticks or false local ticks_size = args.ticks_size or 7 + local tick = args.tick or "|" + local tick_pre = args.tick_pre or "[" + local tick_post = args.tick_post or "]" pulsebar.colors = args.colors or pulsebar.colors pulsebar.followtag = args.followtag or false @@ -138,8 +141,13 @@ local function factory(args) end int = math.modf((pulsebar._current_level / 100) * tot) - preset.text = string.format("[%s%s]", string.rep("|", int), - string.rep(" ", tot - int)) + preset.text = string.format( + "%s%s%s%s", + tick_pre, + string.rep(tick, int), + string.rep(" ", tot - int), + tick_post + ) if pulsebar.followtag then preset.screen = awful.screen.focused() end From d3b5b5a94d974e678d10a8670886e17a354eede5 Mon Sep 17 00:00:00 2001 From: Greg Flynn Date: Sat, 10 Aug 2019 13:34:15 -0400 Subject: [PATCH 06/35] add arg for none in pulsebar notification --- widget/pulsebar.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/widget/pulsebar.lua b/widget/pulsebar.lua index 53bfc3b..51290f8 100644 --- a/widget/pulsebar.lua +++ b/widget/pulsebar.lua @@ -43,6 +43,7 @@ local function factory(args) local tick = args.tick or "|" local tick_pre = args.tick_pre or "[" local tick_post = args.tick_post or "]" + local tick_none = args.tick_none or " " pulsebar.colors = args.colors or pulsebar.colors pulsebar.followtag = args.followtag or false @@ -145,7 +146,7 @@ local function factory(args) "%s%s%s%s", tick_pre, string.rep(tick, int), - string.rep(" ", tot - int), + string.rep(tick_none, tot - int), tick_post ) From bd636ca4184bb83db3db02a2ee34d8cf80f22c24 Mon Sep 17 00:00:00 2001 From: Luca Capezzuto Date: Mon, 12 Aug 2019 17:29:24 +0100 Subject: [PATCH 07/35] alsabar: added argument for maximum number of ticks in notification; #438 --- widget/alsabar.lua | 24 ++++++++++++++---------- widget/temp.lua | 2 +- wiki | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/widget/alsabar.lua b/widget/alsabar.lua index 9b9f4b9..b86c085 100644 --- a/widget/alsabar.lua +++ b/widget/alsabar.lua @@ -48,8 +48,7 @@ local function factory(args) alsabar.notification_preset = args.notification_preset if not alsabar.notification_preset then - alsabar.notification_preset = {} - alsabar.notification_preset.font = "Monospace 10" + alsabar.notification_preset = { font = "Monospace 10" } end local format_cmd = string.format("%s get %s", alsabar.cmd, alsabar.channel) @@ -115,16 +114,21 @@ local function factory(args) end -- tot is the maximum number of ticks to display in the notification - -- fallback: default horizontal wibox height - local wib, tot = awful.screen.focused().mywibox, 20 + local tot = alsabar.notification_preset.max_ticks - -- if we can grab mywibox, tot is defined as its height if - -- horizontal, or width otherwise - if wib then - if wib.position == "left" or wib.position == "right" then - tot = wib.width + if not tot then + local wib = awful.screen.focused().mywibox + -- if we can grab mywibox, tot is defined as its height if + -- horizontal, or width otherwise + if wib then + if wib.position == "left" or wib.position == "right" then + tot = wib.width + else + tot = wib.height + end + -- fallback: default horizontal wibox height else - tot = wib.height + tot = 20 end end diff --git a/widget/temp.lua b/widget/temp.lua index e909b32..2b97a4e 100644 --- a/widget/temp.lua +++ b/widget/temp.lua @@ -20,7 +20,7 @@ local function factory(args) local settings = args.settings or function() end function temp.update() - helpers.async({"find", "/sys/devices", "-type", "f", "-name", "*temp*"}, function(f) + helpers.async({"find", "/sys/devices/virtual/thermal", "-type", "f", "-name", "*temp*"}, function(f) temp_now = {} local temp_fl, temp_value for t in f:gmatch("[^\n]+") do diff --git a/wiki b/wiki index d7fd4db..e37a9eb 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit d7fd4db9122b26e8e8408f3515a0cb1cdb8b03e6 +Subproject commit e37a9eb41b37cccdd307b4e88d4fcdecb920dcaa From 9120182f4950661a004e8231c3b330a76e53c53c Mon Sep 17 00:00:00 2001 From: Luca Capezzuto Date: Mon, 12 Aug 2019 17:44:58 +0100 Subject: [PATCH 08/35] apply #439 to alsabar as well --- widget/alsabar.lua | 13 +++++++++++-- wiki | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/widget/alsabar.lua b/widget/alsabar.lua index b86c085..b2f7b44 100644 --- a/widget/alsabar.lua +++ b/widget/alsabar.lua @@ -39,6 +39,10 @@ local function factory(args) local paddings = args.paddings or 1 local ticks = args.ticks or false local ticks_size = args.ticks_size or 7 + local tick = args.tick or "|" + local tick_pre = args.tick_pre or "[" + local tick_post = args.tick_post or "]" + local tick_none = args.tick_none or " " alsabar.cmd = args.cmd or "amixer" alsabar.channel = args.channel or "Master" @@ -133,8 +137,13 @@ local function factory(args) end int = math.modf((alsabar._current_level / 100) * tot) - preset.text = string.format("[%s%s]", string.rep("|", int), - string.rep(" ", tot - int)) + preset.text = string.format( + "%s%s%s%s", + tick_pre, + string.rep(tick, int), + string.rep(tick_none, tot - int), + tick_post + ) if alsabar.followtag then preset.screen = awful.screen.focused() end diff --git a/wiki b/wiki index e37a9eb..8b3ab9e 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit e37a9eb41b37cccdd307b4e88d4fcdecb920dcaa +Subproject commit 8b3ab9e38a9876cc2e29766c6ecafffbc1c6ff34 From 71ca1bd76739f5d4f11cc065f2943f1cb87627ab Mon Sep 17 00:00:00 2001 From: Luca Capezzuto Date: Tue, 27 Aug 2019 17:08:37 +0100 Subject: [PATCH 09/35] widget.temp: reset path to /sys/devices; closes #441 --- widget/temp.lua | 2 +- wiki | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/widget/temp.lua b/widget/temp.lua index 2b97a4e..e909b32 100644 --- a/widget/temp.lua +++ b/widget/temp.lua @@ -20,7 +20,7 @@ local function factory(args) local settings = args.settings or function() end function temp.update() - helpers.async({"find", "/sys/devices/virtual/thermal", "-type", "f", "-name", "*temp*"}, function(f) + helpers.async({"find", "/sys/devices", "-type", "f", "-name", "*temp*"}, function(f) temp_now = {} local temp_fl, temp_value for t in f:gmatch("[^\n]+") do diff --git a/wiki b/wiki index 8b3ab9e..2899629 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 8b3ab9e38a9876cc2e29766c6ecafffbc1c6ff34 +Subproject commit 2899629c445cb12efb72cc538e36cfc2ec812201 From 33c0e0c2360a04fcc6f51bccb0ad2a7a9e9c07b3 Mon Sep 17 00:00:00 2001 From: Luca Capezzuto Date: Tue, 27 Aug 2019 17:10:06 +0100 Subject: [PATCH 10/35] readme updated --- README.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.rst b/README.rst index f1a2841..2b77f9a 100644 --- a/README.rst +++ b/README.rst @@ -13,7 +13,7 @@ Layouts, widgets and utilities for Awesome WM 4.x Description ----------- -Successor of awesome-vain_, this module provides alternative layouts, asynchronous widgets and utility functions for Awesome_. Read the wiki_ for all the info. +Successor of awesome-vain_, this module provides alternative layouts, asynchronous widgets and utility functions for Awesome_. Contributions ------------- @@ -35,5 +35,4 @@ Contributed widgets have to be put in ``widget/contrib``. .. _GNU-GPL2: http://www.gnu.org/licenses/gpl-2.0.html .. _awesome-vain: https://github.com/vain/awesome-vain .. _Awesome: https://github.com/awesomeWM/awesome -.. _wiki: https://github.com/lcpz/lain/wiki .. _lain.helpers: https://github.com/lcpz/lain/blob/master/helpers.lua From 97567139050ed27ff2a3cfba9e5a8e17569536f1 Mon Sep 17 00:00:00 2001 From: Felipe Date: Sun, 13 Oct 2019 16:52:27 -0300 Subject: [PATCH 11/35] Add mute_background color for pulsebar --- widget/pulsebar.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/widget/pulsebar.lua b/widget/pulsebar.lua index 51290f8..5f6e47a 100644 --- a/widget/pulsebar.lua +++ b/widget/pulsebar.lua @@ -21,9 +21,10 @@ local tonumber = tonumber local function factory(args) local pulsebar = { colors = { - background = "#000000", - mute = "#EB8F8F", - unmute = "#A4CE8A" + background = "#000000", + mute_background = "#000000", + mute = "#EB8F8F", + unmute = "#A4CE8A" }, _current_level = 0, @@ -104,10 +105,12 @@ local function factory(args) pulsebar._mute = mute pulsebar.tooltip:set_text ("[muted]") pulsebar.bar.color = pulsebar.colors.mute + pulsebar.bar.background_color = pulsebar.colors.mute_background else pulsebar._mute = "no" pulsebar.tooltip:set_text(string.format("%s %s: %s", pulsebar.devicetype, pulsebar.device, volu)) pulsebar.bar.color = pulsebar.colors.unmute + pulsebar.bar.background_color = pulsebar.colors.background end settings() From 6f3c709b426466b54adb43e1ec0821aebd83bb50 Mon Sep 17 00:00:00 2001 From: Jure Varlec Date: Sun, 10 Nov 2019 11:46:18 +0100 Subject: [PATCH 12/35] termfair: update the comment to match reality. --- layout/termfair.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/layout/termfair.lua b/layout/termfair.lua index e33894e..1f919cb 100644 --- a/layout/termfair.lua +++ b/layout/termfair.lua @@ -24,21 +24,21 @@ local function do_fair(p, orientation) if orientation == "west" then -- Layout with fixed number of vertical columns (read from nmaster). - -- New windows align from left to right. When a row is full, a now + -- New windows align from left to right. When a row is full, a new -- one above it is created. Like this: -- (1) (2) (3) -- +---+---+---+ +---+---+---+ +---+---+---+ -- | | | | | | | | | | | | - -- | 1 | | | -> | 2 | 1 | | -> | 3 | 2 | 1 | -> + -- | 1 | | | -> | 1 | 2 | | -> | 1 | 2 | 3 | -> -- | | | | | | | | | | | | -- +---+---+---+ +---+---+---+ +---+---+---+ -- (4) (5) (6) -- +---+---+---+ +---+---+---+ +---+---+---+ - -- | 4 | | | | 5 | 4 | | | 6 | 5 | 4 | + -- | 1 | | | | 1 | 2 | | | 1 | 2 | 3 | -- +---+---+---+ -> +---+---+---+ -> +---+---+---+ - -- | 3 | 2 | 1 | | 3 | 2 | 1 | | 3 | 2 | 1 | + -- | 2 | 3 | 4 | | 3 | 4 | 5 | | 4 | 5 | 6 | -- +---+---+---+ +---+---+---+ +---+---+---+ -- How many vertical columns? Read from nmaster on the tag. From 8e9d7417614b49aab546d7266f9700d464c6eaf9 Mon Sep 17 00:00:00 2001 From: Jure Varlec Date: Sun, 10 Nov 2019 11:51:17 +0100 Subject: [PATCH 13/35] termfair: move common variables to the top of the function. --- layout/termfair.lua | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/layout/termfair.lua b/layout/termfair.lua index 1f919cb..a81461e 100644 --- a/layout/termfair.lua +++ b/layout/termfair.lua @@ -22,6 +22,13 @@ local function do_fair(p, orientation) if #cls == 0 then return end + -- How many vertical columns? Read from nmaster on the tag. + local num_x = tonumber(termfair.nmaster) or t.master_count + local ncol = tonumber(termfair.ncol) or t.column_count + if num_x <= 2 then num_x = 2 end + if ncol <= 1 then ncol = 1 end + local width = math.floor(wa.width/num_x) + if orientation == "west" then -- Layout with fixed number of vertical columns (read from nmaster). -- New windows align from left to right. When a row is full, a new @@ -41,14 +48,6 @@ local function do_fair(p, orientation) -- | 2 | 3 | 4 | | 3 | 4 | 5 | | 4 | 5 | 6 | -- +---+---+---+ +---+---+---+ +---+---+---+ - -- How many vertical columns? Read from nmaster on the tag. - local num_x = tonumber(termfair.nmaster) or t.master_count - local ncol = tonumber(termfair.ncol) or t.column_count - - if num_x <= 2 then num_x = 2 end - if ncol <= 1 then ncol = 1 end - local width = math.floor(wa.width/num_x) - local num_y = math.max(math.ceil(#cls / num_x), ncol) local height = math.floor(wa.height/num_y) local cur_num_x = num_x @@ -128,15 +127,6 @@ local function do_fair(p, orientation) -- | | | 4 | | | 3 | 5 | -- +---+---+---+ +---+---+---+ - -- How many vertical columns? Read from nmaster on the tag. - local num_x = tonumber(termfair.center.nmaster) or t.master_count - local ncol = tonumber(termfair.center.ncol) or t.column_count - - if num_x <= 2 then num_x = 2 end - if ncol <= 1 then ncol = 1 end - - local width = math.floor(wa.width / num_x) - if #cls < num_x then -- Less clients than the number of columns, let's center it! local offset_x = wa.x + (wa.width - #cls*width) / 2 From 5157c9d98261486c21d6e49ca5f4003c829eb326 Mon Sep 17 00:00:00 2001 From: Jure Varlec Date: Sun, 10 Nov 2019 15:31:41 +0100 Subject: [PATCH 14/35] Add the termfair.stable layout. --- layout/termfair.lua | 55 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/layout/termfair.lua b/layout/termfair.lua index a81461e..9edfa1d 100644 --- a/layout/termfair.lua +++ b/layout/termfair.lua @@ -14,6 +14,7 @@ local tonumber = tonumber local termfair = { name = "termfair" } termfair.center = { name = "centerfair" } +termfair.stable = { name = "stablefair" } local function do_fair(p, orientation) local t = p.tag or screen[p.screen].selected_tag @@ -106,6 +107,56 @@ local function do_fair(p, orientation) end end end + elseif orientation == "stable" then + -- Layout with fixed number of vertical columns (read from nmaster). + -- New windows align from left to right. When a row is full, a new + -- one below it is created. Like this: + + -- (1) (2) (3) + -- +---+---+---+ +---+---+---+ +---+---+---+ + -- | | | | | | | | | | | | + -- | 1 | | | -> | 1 | 2 | | -> | 1 | 2 | 3 | -> + -- | | | | | | | | | | | | + -- +---+---+---+ +---+---+---+ +---+---+---+ + + -- (4) (5) (6) + -- +---+---+---+ +---+---+---+ +---+---+---+ + -- | 1 | 2 | 3 | | 1 | 2 | 3 | | 1 | 2 | 3 | + -- +---+---+---+ +---+---+---+ +---+---+---+ + -- | 4 | | | | 4 | 5 | | | 4 | 5 | 6 | + -- +---+---+---+ -> +---+---+---+ -> +---+---+---+ + + local num_y = math.max(math.ceil(#cls / num_x), ncol) + local height = math.floor(wa.height/num_y) + + for i = #cls,1,-1 do + -- Get x and y position. + local c = cls[i] + local this_x = (i - 1) % num_x + local this_y = math.floor((i - this_x - 1) / num_x) + + -- Calculate geometry. + local g = {} + if this_x == (num_x - 1) then + g.width = wa.width - (num_x - 1)*width + else + g.width = width + end + + if this_y == (num_y - 1) then + g.height = wa.height - (num_y - 1)*height + else + g.height = height + end + + g.x = wa.x + this_x*width + g.y = wa.y + this_y*height + + if g.width < 1 then g.width = 1 end + if g.height < 1 then g.height = 1 end + + p.geometries[c] = g + end elseif orientation == "center" then -- Layout with fixed number of vertical columns (read from nmaster). -- Cols are centerded until there is nmaster columns, then windows @@ -220,6 +271,10 @@ function termfair.center.arrange(p) return do_fair(p, "center") end +function termfair.stable.arrange(p) + return do_fair(p, "stable") +end + function termfair.arrange(p) return do_fair(p, "west") end From 52a6258b722f50a579b50eda6b00b233622ab66c Mon Sep 17 00:00:00 2001 From: Neville Li Date: Thu, 5 Mar 2020 21:31:39 -0500 Subject: [PATCH 15/35] add centerwork.{focus,swap}.byidx that behaves like other layouts #447 --- layout/centerwork.lua | 73 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/layout/centerwork.lua b/layout/centerwork.lua index 2b38a69..dc173ba 100644 --- a/layout/centerwork.lua +++ b/layout/centerwork.lua @@ -191,4 +191,77 @@ function centerwork.horizontal.mouse_resize_handler(c, corner, x, y) return mouse_resize_handler(c, corner, x, y, 'horizontal') end +------------------------------------------------------------------------------- +-- make focus.byidx and swap.byidx behave more consistently with other layouts + +local awful = require("awful") +local gears = require("gears") + +local function compare_position(a, b) + if a.x == b.x then + return a.y < b.y + else + return a.x < b.x + end +end + +local function clients_by_position() + local this = client.focus + if this then + sorted = client.focus.first_tag:clients() + table.sort(sorted, compare_position) + + local idx = 0 + for i, that in ipairs(sorted) do + if this.window == that.window then + idx = i + end + end + + if idx > 0 then + return { sorted = sorted, idx = idx } + end + end + return {} +end + +local function in_centerwork() + return client.focus and client.focus.first_tag.layout.name == "centerwork" +end + +centerwork.focus = {} + + +--[[ +Drop in replacements for awful.client.focus.byidx and awful.client.swap.byidx +that behaves consistently with other layouts +--]] + + +function centerwork.focus.byidx(i) + if in_centerwork() then + local cls = clients_by_position() + if cls.idx then + local target = cls.sorted[gears.math.cycle(#cls.sorted, cls.idx + i)] + awful.client.focus.byidx(0, target) + end + else + awful.client.focus.byidx(i) + end +end + +centerwork.swap = {} + +function centerwork.swap.byidx(i) + if in_centerwork() then + local cls = clients_by_position() + if cls.idx then + local target = cls.sorted[gears.math.cycle(#cls.sorted, cls.idx + i)] + client.focus:swap(target) + end + else + awful.client.swap.byidx(i) + end +end + return centerwork From af125b324e4ba5f7bd90dbe4202464594afcea4e Mon Sep 17 00:00:00 2001 From: Luca CPZ <1777696+lcpz@users.noreply.github.com> Date: Fri, 17 Apr 2020 20:25:55 -0500 Subject: [PATCH 16/35] Update bat.lua Ensure that status is never nil. Closes #451 --- widget/bat.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widget/bat.lua b/widget/bat.lua index 3cb801c..3310069 100644 --- a/widget/bat.lua +++ b/widget/bat.lua @@ -136,7 +136,7 @@ local function factory(args) -- "Full", "Unknown" or "Charging". When the laptop is not plugged in, -- one or more of the batteries may be full, but only one battery -- discharging suffices to set global status to "Discharging". - bat_now.status = bat_now.n_status[1] + bat_now.status = bat_now.n_status[1] or "N/A" for _,status in ipairs(bat_now.n_status) do if status == "Discharging" or status == "Charging" then bat_now.status = status From 0775f97b421ea3314af71c576b4b2913dd45ec57 Mon Sep 17 00:00:00 2001 From: Luca CPZ <1777696+lcpz@users.noreply.github.com> Date: Wed, 29 Apr 2020 12:28:39 -0500 Subject: [PATCH 17/35] Update net.lua --- widget/net.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/widget/net.lua b/widget/net.lua index 805b577..a6c43ab 100644 --- a/widget/net.lua +++ b/widget/net.lua @@ -29,13 +29,14 @@ local function factory(args) net.iface = (args.iface and (type(args.iface) == "string" and {args.iface}) or (type(args.iface) == "table" and args.iface)) or {} - function net.get_device() + function net.get_devices() + net.iface = {} -- reset at every call helpers.line_callback("ip link", function(line) net.iface[#net.iface + 1] = not string.match(line, "LOOPBACK") and string.match(line, "(%w+): <") or nil end) end - if #net.iface == 0 then net.get_device() end + if #net.iface == 0 then net.get_devices() end function net.update() -- These are the totals over all specified interfaces From e0bffc00566fbc0c05dc01700c569a589a6900eb Mon Sep 17 00:00:00 2001 From: Neville Li Date: Sat, 23 May 2020 09:17:15 -0400 Subject: [PATCH 18/35] fix fs widget notification alignment --- widget/fs.lua | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/widget/fs.lua b/widget/fs.lua index 58fbf93..8e2441a 100644 --- a/widget/fs.lua +++ b/widget/fs.lua @@ -69,11 +69,10 @@ local function factory(args) end function fs.update() - local notifytable = { [1] = string.format("%-10s %4s\t%6s\t%6s\t\n", "path", "used", "free", "size") } local pathlen = 10 - local maxpathidx = 1 fs_now = {} + local notifypaths = {} for _, mount in ipairs(Gio.unix_mounts_get()) do local path = Gio.unix_mount_get_mount_path(mount) local root = Gio.File.new_for_path(path) @@ -90,19 +89,16 @@ local function factory(args) fs_now[path] = { units = fs.units[units], percentage = math.floor(100 * used / size), -- used percentage - size = size / math.pow(1024, math.floor(units)), - used = used / math.pow(1024, math.floor(units)), - free = free / math.pow(1024, math.floor(units)) + size = size / math.pow(1024, units), + used = used / math.pow(1024, units), + free = free / math.pow(1024, units) } if fs_now[path].percentage > 0 then -- don't notify unused file systems - notifytable[#notifytable+1] = string.format("\n%-10s %3s%%\t%6.2f\t%6.2f\t%s", path, - math.floor(fs_now[path].percentage), fs_now[path].free, fs_now[path].size, - fs_now[path].units) + notifypaths[#notifypaths+1] = path if #path > pathlen then pathlen = #path - maxpathidx = #notifytable end end end @@ -125,14 +121,11 @@ local function factory(args) end end - if pathlen > 10 then -- if are there paths longer than 10 chars, reformat first column accordingly - local pathspaces - for i = 1, #notifytable do - pathspaces = notifytable[i]:match("[ ]+") - if i ~= maxpathidx and pathspaces then - notifytable[i] = notifytable[i]:gsub(pathspaces, pathspaces .. string.rep(" ", pathlen - 10)) - end - end + local fmt = "%-" .. tostring(pathlen) .. "s %4s\t%6s\t%6s\n" + local notifytable = { [1] = string.format(fmt, "path", "used", "free", "size") } + fmt = "\n%-" .. tostring(pathlen) .. "s %3s%%\t%6.2f\t%6.2f %s" + for _, path in ipairs(notifypaths) do + notifytable[#notifytable+1] = string.format(fmt, path, fs_now[path].percentage, fs_now[path].free, fs_now[path].size, fs_now[path].units) end fs.notification_preset.text = tconcat(notifytable) From 89b3d66d8fa7248703f44b5ece3ae1bfb424bafe Mon Sep 17 00:00:00 2001 From: Sebastian Lenz Date: Wed, 10 Jun 2020 14:29:57 +0200 Subject: [PATCH 19/35] Fix notification text for calendar widget --- widget/cal.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/widget/cal.lua b/widget/cal.lua index 928a7bd..1f6df2b 100644 --- a/widget/cal.lua +++ b/widget/cal.lua @@ -126,14 +126,14 @@ local function factory(args) end function cal.show(seconds, month, year, scr) - cal.notification_preset.text = tconcat(cal.build(month, year)) + local text = tconcat(cal.build(month, year)) if cal.three then local current_month, current_year = cal.month, cal.year local prev_month, prev_year = cal.getdate(cal.month, cal.year, -1) local next_month, next_year = cal.getdate(cal.month, cal.year, 1) - cal.notification_preset.text = string.format("%s\n\n%s\n\n%s", - tconcat(cal.build(prev_month, prev_year)), cal.notification_preset.text, + text = string.format("%s\n\n%s\n\n%s", + tconcat(cal.build(prev_month, prev_year)), text, tconcat(cal.build(next_month, next_year))) cal.month, cal.year = current_month, current_year end @@ -143,7 +143,8 @@ local function factory(args) preset = cal.notification_preset, screen = cal.followtag and awful.screen.focused() or scr or 1, icon = cal.icon, - timeout = type(seconds) == "number" and seconds or cal.notification_preset.timeout or 5 + timeout = type(seconds) == "number" and seconds or cal.notification_preset.timeout or 5, + text = text } end From 1c150887b4a581ef57372eed66db7815b1d2803b Mon Sep 17 00:00:00 2001 From: NCM Date: Sun, 25 Oct 2020 14:45:38 -0300 Subject: [PATCH 20/35] weather: use https instead of http api.openweathermap.org api provides a valid ssl certificate --- widget/weather.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/widget/weather.lua b/widget/weather.lua index 9c1e797..79d45d8 100644 --- a/widget/weather.lua +++ b/widget/weather.lua @@ -26,8 +26,8 @@ local function factory(args) local APPID = args.APPID or "3e321f9414eaedbfab34983bda77a66e" -- lain's default local timeout = args.timeout or 60 * 15 -- 15 min local timeout_forecast = args.timeout or 60 * 60 * 24 -- 24 hrs - local current_call = args.current_call or "curl -s 'http://api.openweathermap.org/data/2.5/weather?id=%s&units=%s&lang=%s&APPID=%s'" - local forecast_call = args.forecast_call or "curl -s 'http://api.openweathermap.org/data/2.5/forecast/daily?id=%s&units=%s&lang=%s&cnt=%s&APPID=%s'" + 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/daily?id=%s&units=%s&lang=%s&cnt=%s&APPID=%s'" local city_id = args.city_id or 0 -- placeholder local units = args.units or "metric" local lang = args.lang or "en" From 502a1a28ba87c0808ff0aad87b42285f99e9e39d Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Sat, 31 Oct 2020 10:11:29 -0700 Subject: [PATCH 21/35] Added args.widget info all widgets that can take it --- widget/alsa.lua | 2 +- widget/bat.lua | 2 +- widget/contrib/moc.lua | 2 +- widget/cpu.lua | 2 +- widget/fs.lua | 4 ++-- widget/imap.lua | 2 +- widget/mem.lua | 2 +- widget/mpd.lua | 2 +- widget/net.lua | 2 +- widget/pulse.lua | 2 +- widget/sysload.lua | 2 +- widget/temp.lua | 2 +- widget/weather.lua | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-) diff --git a/widget/alsa.lua b/widget/alsa.lua index 3b6c6d6..49b2cf0 100644 --- a/widget/alsa.lua +++ b/widget/alsa.lua @@ -15,8 +15,8 @@ local string = string -- lain.widget.alsa local function factory(args) - local alsa = { widget = wibox.widget.textbox() } local args = args or {} + local alsa = { widget = args.widget or wibox.widget.textbox() } local timeout = args.timeout or 5 local settings = args.settings or function() end diff --git a/widget/bat.lua b/widget/bat.lua index 3310069..7e69e1f 100644 --- a/widget/bat.lua +++ b/widget/bat.lua @@ -26,8 +26,8 @@ local function factory(args) return end - local bat = { widget = wibox.widget.textbox() } local args = args or {} + local bat = { widget = args.widget or wibox.widget.textbox() } local timeout = args.timeout or 30 local notify = args.notify or "on" local full_notify = args.full_notify or notify diff --git a/widget/contrib/moc.lua b/widget/contrib/moc.lua index f429c77..e9a7dfe 100644 --- a/widget/contrib/moc.lua +++ b/widget/contrib/moc.lua @@ -18,8 +18,8 @@ local string = string -- lain.widget.contrib.moc local function factory(args) - local moc = { widget = wibox.widget.textbox() } local args = args or {} + local moc = { widget = args.widget or wibox.widget.textbox() } local timeout = args.timeout or 2 local music_dir = args.music_dir or os.getenv("HOME") .. "/Music" local cover_pattern = args.cover_pattern or "*\\.(jpg|jpeg|png|gif)$" diff --git a/widget/cpu.lua b/widget/cpu.lua index f4cce73..b823a5f 100644 --- a/widget/cpu.lua +++ b/widget/cpu.lua @@ -16,8 +16,8 @@ local tostring = tostring -- lain.widget.cpu local function factory(args) - local cpu = { core = {}, widget = wibox.widget.textbox() } local args = args or {} + local cpu = { core = {}, widget = args.widget or wibox.widget.textbox() } local timeout = args.timeout or 2 local settings = args.settings or function() end diff --git a/widget/fs.lua b/widget/fs.lua index 8e2441a..53eac66 100644 --- a/widget/fs.lua +++ b/widget/fs.lua @@ -26,8 +26,9 @@ local query = query_size .. "," .. query_free .. "," .. query_used -- lain.widget.fs local function factory(args) + local args = args or {} local fs = { - widget = wibox.widget.textbox(), + widget = args.widget or wibox.widget.textbox(), units = { [1] = "Kb", [2] = "Mb", [3] = "Gb", [4] = "Tb", [5] = "Pb", [6] = "Eb", @@ -50,7 +51,6 @@ local function factory(args) } end - local args = args or {} local timeout = args.timeout or 600 local partition = args.partition local threshold = args.threshold or 99 diff --git a/widget/imap.lua b/widget/imap.lua index b3d9dc7..c8eb2c9 100644 --- a/widget/imap.lua +++ b/widget/imap.lua @@ -17,8 +17,8 @@ local tonumber = tonumber -- lain.widget.imap local function factory(args) - local imap = { widget = wibox.widget.textbox() } local args = args or {} + local imap = { widget = args.widget or wibox.widget.textbox() } local server = args.server local mail = args.mail local password = args.password diff --git a/widget/mem.lua b/widget/mem.lua index 3dcae2b..90933b6 100644 --- a/widget/mem.lua +++ b/widget/mem.lua @@ -14,8 +14,8 @@ local gmatch, lines, floor = string.gmatch, io.lines, math.floor -- lain.widget.mem local function factory(args) - local mem = { widget = wibox.widget.textbox() } local args = args or {} + local mem = { widget = args.widget or wibox.widget.textbox() } local timeout = args.timeout or 2 local settings = args.settings or function() end diff --git a/widget/mpd.lua b/widget/mpd.lua index 01f28e6..13994bd 100644 --- a/widget/mpd.lua +++ b/widget/mpd.lua @@ -19,8 +19,8 @@ local string = string -- lain.widget.mpd local function factory(args) - local mpd = { widget = wibox.widget.textbox() } local args = args or {} + local mpd = { widget = args.widget or wibox.widget.textbox() } local timeout = args.timeout or 2 local password = (args.password and #args.password > 0 and string.format("password %s\\n", args.password)) or "" local host = args.host or os.getenv("MPD_HOST") or "127.0.0.1" diff --git a/widget/net.lua b/widget/net.lua index a6c43ab..bf24fcf 100644 --- a/widget/net.lua +++ b/widget/net.lua @@ -15,8 +15,8 @@ local string = string -- lain.widget.net local function factory(args) - local net = { widget = wibox.widget.textbox(), devices = {} } local args = args or {} + local net = { widget = args.widget or wibox.widget.textbox(), devices = {} } local timeout = args.timeout or 2 local units = args.units or 1024 -- KB local notify = args.notify or "on" diff --git a/widget/pulse.lua b/widget/pulse.lua index f63fe55..5a6fb0b 100644 --- a/widget/pulse.lua +++ b/widget/pulse.lua @@ -15,8 +15,8 @@ local type = type -- lain.widget.pulse local function factory(args) - local pulse = { widget = wibox.widget.textbox(), device = "N/A" } local args = args or {} + local pulse = { widget = args.widget or wibox.widget.textbox(), device = "N/A" } local timeout = args.timeout or 5 local settings = args.settings or function() end diff --git a/widget/sysload.lua b/widget/sysload.lua index adf3e03..38cdd9d 100644 --- a/widget/sysload.lua +++ b/widget/sysload.lua @@ -14,8 +14,8 @@ local open, match = io.open, string.match -- lain.widget.sysload local function factory(args) - local sysload = { widget = wibox.widget.textbox() } local args = args or {} + local sysload = { widget = args.widget or wibox.widget.textbox() } local timeout = args.timeout or 2 local settings = args.settings or function() end diff --git a/widget/temp.lua b/widget/temp.lua index e909b32..8b646a0 100644 --- a/widget/temp.lua +++ b/widget/temp.lua @@ -13,8 +13,8 @@ local tonumber = tonumber -- lain.widget.temp local function factory(args) - local temp = { widget = wibox.widget.textbox() } local args = args or {} + local temp = { widget = args.widget or wibox.widget.textbox() } local timeout = args.timeout or 30 local tempfile = args.tempfile or "/sys/devices/virtual/thermal/thermal_zone0/temp" local settings = args.settings or function() end diff --git a/widget/weather.lua b/widget/weather.lua index 79d45d8..3cf5102 100644 --- a/widget/weather.lua +++ b/widget/weather.lua @@ -21,8 +21,8 @@ local tonumber = tonumber -- lain.widget.weather local function factory(args) - local weather = { widget = wibox.widget.textbox() } local args = args or {} + local weather = { widget = args.widget or wibox.widget.textbox() } local APPID = args.APPID or "3e321f9414eaedbfab34983bda77a66e" -- lain's default local timeout = args.timeout or 60 * 15 -- 15 min local timeout_forecast = args.timeout or 60 * 60 * 24 -- 24 hrs From 9846ab63786b5d6e738aef3c2630344841686809 Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Sat, 31 Oct 2020 13:04:43 -0700 Subject: [PATCH 22/35] Wiki updated for new arguments --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index 2899629..1287ecf 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 2899629c445cb12efb72cc538e36cfc2ec812201 +Subproject commit 1287ecfcb238df04e95c6f9daa6a7848a97bac92 From e48e271bd44ab5c92711e79dcd45dce7b1d191f0 Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Sun, 1 Nov 2020 19:27:00 -0800 Subject: [PATCH 23/35] Wiki update --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index 1287ecf..2899629 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 1287ecfcb238df04e95c6f9daa6a7848a97bac92 +Subproject commit 2899629c445cb12efb72cc538e36cfc2ec812201 From d5b5047404d68aaeac77c939f32c70c7444286d7 Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Tue, 3 Nov 2020 12:55:25 -0800 Subject: [PATCH 24/35] Fix the nil values in net --- widget/net.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/widget/net.lua b/widget/net.lua index bf24fcf..ea2510c 100644 --- a/widget/net.lua +++ b/widget/net.lua @@ -68,13 +68,19 @@ local function factory(args) dev_now.last_t = now_t dev_now.last_r = now_r - if wifi_state == "on" and helpers.first_line(string.format("/sys/class/net/%s/uevent", dev)) == "DEVTYPE=wlan" and string.match(dev_now.carrier, "1") then + if wifi_state == "on" and helpers.first_line(string.format("/sys/class/net/%s/uevent", dev)) == "DEVTYPE=wlan" then dev_now.wifi = true - dev_now.signal = tonumber(string.match(helpers.lines_from("/proc/net/wireless")[3], "(%-%d+%.)")) or nil + if string.match(dev_now.carrier, "1") then + dev_now.signal = tonumber(string.match(helpers.lines_from("/proc/net/wireless")[3], "(%-%d+%.)")) or nil + end + else + dev_now.wifi = false end - if eth_state == "on" and helpers.first_line(string.format("/sys/class/net/%s/uevent", dev)) ~= "DEVTYPE=wlan" and string.match(dev_now.carrier, "1") then + if eth_state == "on" and helpers.first_line(string.format("/sys/class/net/%s/uevent", dev)) ~= "DEVTYPE=wlan" then dev_now.ethernet = true + else + dev_now.ethernet = false end net.devices[dev] = dev_now From a2e2e7194e1238b2b5e8b2b78ef23f23421a1791 Mon Sep 17 00:00:00 2001 From: Marvin Ewald Date: Sat, 14 Nov 2020 02:01:40 +0100 Subject: [PATCH 25/35] Run fs widget update asynchronously Fixes #462 --- widget/fs.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/widget/fs.lua b/widget/fs.lua index 53eac66..63714d2 100644 --- a/widget/fs.lua +++ b/widget/fs.lua @@ -68,7 +68,7 @@ local function factory(args) } end - function fs.update() + local function update_synced() local pathlen = 10 fs_now = {} @@ -131,6 +131,10 @@ local function factory(args) fs.notification_preset.text = tconcat(notifytable) end + function fs.update() + Gio.Async.start(update_synced)() + end + if showpopup == "on" then fs.widget:connect_signal('mouse::enter', function () fs.show(0) end) fs.widget:connect_signal('mouse::leave', function () fs.hide() end) From 6b2a4ce4d9ac3dd5ded5d9bd7f8a1b9bae79e505 Mon Sep 17 00:00:00 2001 From: unisgn Date: Thu, 26 Nov 2020 01:16:30 +0800 Subject: [PATCH 26/35] make quake to remember maximize and fullscreen --- util/quake.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/util/quake.lua b/util/quake.lua index 01891b0..fb1f43e 100644 --- a/util/quake.lua +++ b/util/quake.lua @@ -60,6 +60,8 @@ function quake:display() client.floating = true client.border_width = self.border client.size_hints_honor = false + local maximized = client.maximized + local fullscreen = client.fullscreen client:geometry(self.geometry[self.screen.index] or self:compute_size()) -- Set not sticky and on top @@ -74,11 +76,16 @@ function quake:display() -- Toggle display if self.visible then client.hidden = false + client.maximized = self.maximized + client.fullscreen = self.fullscreen client:raise() self.last_tag = self.screen.selected_tag client:tags({self.screen.selected_tag}) capi.client.focus = client - else + else + self.maximized = maximized + self.fullscreen = fullscreen + client.fullscreen = false client.hidden = true local ctags = client:tags() for i, t in pairs(ctags) do @@ -135,6 +142,9 @@ function quake:new(config) conf.horiz = conf.horiz or "left" -- left, right or center conf.geometry = {} -- internal use + conf.maximized = false + conf.fullscreen = false + local dropdown = setmetatable(conf, { __index = quake }) capi.client.connect_signal("manage", function(c) From a26282d91c39700732ff7e147037b780af4f2709 Mon Sep 17 00:00:00 2001 From: unisgn Date: Thu, 26 Nov 2020 01:29:38 +0800 Subject: [PATCH 27/35] Update quake.lua --- util/quake.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/util/quake.lua b/util/quake.lua index fb1f43e..d2a49d3 100644 --- a/util/quake.lua +++ b/util/quake.lua @@ -85,6 +85,7 @@ function quake:display() else self.maximized = maximized self.fullscreen = fullscreen + client.maximized = false client.fullscreen = false client.hidden = true local ctags = client:tags() From bdb19e827e4d55a08756cb73aa432ab3bceeef6a Mon Sep 17 00:00:00 2001 From: Marvin Ewald Date: Sun, 29 Nov 2020 14:33:16 +0100 Subject: [PATCH 28/35] Fix async update calls in fs widget - Use `gears.protected_call` in order to get errors logged. - Fix `fs.show` not waiting for update to complete. --- widget/fs.lua | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/widget/fs.lua b/widget/fs.lua index 63714d2..7ec32c1 100644 --- a/widget/fs.lua +++ b/widget/fs.lua @@ -12,6 +12,7 @@ local Gio = require("lgi").Gio local focused = require("awful.screen").focused local wibox = require("wibox") local naughty = require("naughty") +local gears = require("gears") local math = math local string = string local tconcat = table.concat @@ -43,12 +44,14 @@ local function factory(args) end function fs.show(seconds, scr) - fs.hide(); fs.update() - fs.notification_preset.screen = fs.followtag and focused() or scr or 1 - fs.notification = naughty.notify { - preset = fs.notification_preset, - timeout = type(seconds) == "number" and seconds or 5 - } + fs.hide() + fs.update(function() + fs.notification_preset.screen = fs.followtag and focused() or scr or 1 + fs.notification = naughty.notify { + preset = fs.notification_preset, + timeout = type(seconds) == "number" and seconds or 5 + } + end) end local timeout = args.timeout or 600 @@ -131,8 +134,13 @@ local function factory(args) fs.notification_preset.text = tconcat(notifytable) end - function fs.update() - Gio.Async.start(update_synced)() + function fs.update(callback) + Gio.Async.start(gears.protected_call.call)(function() + update_synced() + if callback then + callback() + end + end) end if showpopup == "on" then From 0a2ff9e1dea4093088c30af0b75ccd94a4f700ad Mon Sep 17 00:00:00 2001 From: staticssleever668 <64694940+staticssleever668@users.noreply.github.com> Date: Mon, 30 Nov 2020 00:48:32 +0300 Subject: [PATCH 29/35] Fix various luacheck warnings --- helpers.lua | 4 ++-- layout/centerwork.lua | 4 ++-- layout/termfair.lua | 2 +- util/dkjson.lua | 11 +++++------ util/init.lua | 4 ++-- util/menu_iterator.lua | 7 +++---- util/quake.lua | 6 +++--- util/separators.lua | 10 +++++----- widget/alsa.lua | 2 +- widget/alsabar.lua | 6 +++--- widget/bat.lua | 3 ++- widget/cal.lua | 2 +- widget/contrib/moc.lua | 3 ++- widget/contrib/redshift.lua | 12 ++++++------ widget/contrib/task.lua | 4 ++-- widget/contrib/tp_smapi.lua | 8 ++++---- widget/cpu.lua | 4 ++-- widget/fs.lua | 4 ++-- widget/imap.lua | 3 ++- widget/mem.lua | 3 ++- widget/mpd.lua | 3 ++- widget/net.lua | 13 +++++++------ widget/pulse.lua | 3 ++- widget/pulsebar.lua | 5 +++-- widget/sysload.lua | 3 ++- widget/temp.lua | 3 ++- widget/weather.lua | 13 ++++++------- 27 files changed, 76 insertions(+), 69 deletions(-) diff --git a/helpers.lua b/helpers.lua index d6f6b3c..1829b7b 100644 --- a/helpers.lua +++ b/helpers.lua @@ -109,7 +109,7 @@ end -- @return cmd PID function helpers.async(cmd, callback) return spawn.easy_async(cmd, - function (stdout, stderr, reason, exit_code) + function (stdout, _, _, exit_code) callback(stdout, exit_code) end) end @@ -117,7 +117,7 @@ end -- like above, but call spawn.easy_async with a shell function helpers.async_with_shell(cmd, callback) return spawn.easy_async_with_shell(cmd, - function (stdout, stderr, reason, exit_code) + function (stdout, _, _, exit_code) callback(stdout, exit_code) end) end diff --git a/layout/centerwork.lua b/layout/centerwork.lua index dc173ba..81ac8f3 100644 --- a/layout/centerwork.lua +++ b/layout/centerwork.lua @@ -125,7 +125,7 @@ local function arrange(p, layout) end end -local function mouse_resize_handler(c, corner, x, y, orientation) +local function mouse_resize_handler(c, _, _, _, orientation) local wa = c.screen.workarea local mwfact = c.screen.selected_tag.master_width_factor local g = c:geometry() @@ -208,7 +208,7 @@ end local function clients_by_position() local this = client.focus if this then - sorted = client.focus.first_tag:clients() + local sorted = client.focus.first_tag:clients() table.sort(sorted, compare_position) local idx = 0 diff --git a/layout/termfair.lua b/layout/termfair.lua index 9edfa1d..eede3ba 100644 --- a/layout/termfair.lua +++ b/layout/termfair.lua @@ -240,7 +240,7 @@ local function do_fair(p, orientation) for i = 1, (num_x-1) do local height = math.floor(wa.height / num_y[i]) local wy = wa.y - for j = 0, (num_y[i]-2) do + for _ = 0, (num_y[i]-2) do local g = {} g.x = wx g.y = wy diff --git a/util/dkjson.lua b/util/dkjson.lua index 89aa2e1..fb6cedd 100644 --- a/util/dkjson.lua +++ b/util/dkjson.lua @@ -42,8 +42,8 @@ SOFTWARE. --]==] -- global dependencies: -local pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset = - pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset +local pairs, type, tostring, tonumber, getmetatable, setmetatable = + pairs, type, tostring, tonumber, getmetatable, setmetatable local error, require, pcall, select = error, require, pcall, select local floor, huge = math.floor, math.huge local strrep, gsub, strsub, strbyte, strchar, strfind, strlen, strformat = @@ -246,7 +246,7 @@ local function exception(reason, value, state, buffer, buflen, defaultmessage) end end -function json.encodeexception(reason, value, state, defaultmessage) +function json.encodeexception(_, _, _, defaultmessage) return quotestring("<" .. defaultmessage .. ">") end @@ -321,7 +321,7 @@ encode2 = function (value, indent, level, buffer, buflen, tables, globalorder, s local v = value[k] if v then used[k] = true - buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder, state) + buflen, _ = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder, state) prev = true -- add a seperator before the next element end end @@ -504,7 +504,6 @@ end local scanvalue -- forward declaration local function scantable (what, closechar, str, startpos, nullval, objectmeta, arraymeta) - local len = strlen (str) local tbl, n = {}, 0 local pos = startpos + 1 if what == 'object' then @@ -626,7 +625,7 @@ function json.use_lpeg () local PlainChar = 1 - S"\"\\\n\r" local EscapeSequence = (P"\\" * g.C (S"\"\\/bfnrt" + Err "unsupported escape sequence")) / escapechars local HexDigit = R("09", "af", "AF") - local function UTF16Surrogate (match, pos, high, low) + local function UTF16Surrogate (_, _, high, low) high, low = tonumber (high, 16), tonumber (low, 16) if 0xD800 <= high and high <= 0xDBff and 0xDC00 <= low and low <= 0xDFFF then return true, unichar ((high - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000) diff --git a/util/init.lua b/util/init.lua index 55bfa26..f7d3088 100644 --- a/util/init.lua +++ b/util/init.lua @@ -39,7 +39,7 @@ function util.menu_clients_current_tags(menu, args) local t = cls_tags[i] local cls = t:clients() - for k, c in pairs(cls) do + for _, c in pairs(cls) do cls_t[#cls_t + 1] = { awful.util.escape(c.name) or "", function () c.minimized = false @@ -99,7 +99,7 @@ end function util.tag_view_nonempty(direction, sc) local s = sc or awful.screen.focused() - for i = 1, #s.tags do + for _ = 1, #s.tags do awful.tag.viewidx(direction, s) if #s.clients > 0 then return diff --git a/util/menu_iterator.lua b/util/menu_iterator.lua index 9959b25..d457473 100644 --- a/util/menu_iterator.lua +++ b/util/menu_iterator.lua @@ -12,7 +12,6 @@ local naughty = require("naughty") local helpers = require("lain.helpers") -local util = require("lain.util") local atable = require("awful.util").table local assert = assert local pairs = pairs @@ -42,8 +41,8 @@ end -- * timeout: time to wait before confirming the menu selection -- * icon: icon to display in the notification of the chosen label local function iterate(menu, timeout, icon) - local timeout = timeout or 4 -- default timeout for each menu entry - local icon = icon or nil -- icon to display on the menu + timeout = timeout or 4 -- default timeout for each menu entry + icon = icon or nil -- icon to display on the menu -- Build the list of choices if not state.index then @@ -104,7 +103,7 @@ local function menu(args) local ch_combinations = args.combination == "powerset" and helpers.powerset(choices) or helpers.trivial_partition_set(choices) - for _,c in pairs(extra_choices) do + for _, c in pairs(extra_choices) do ch_combinations = atable.join(ch_combinations, {{c[1]}}) end diff --git a/util/quake.lua b/util/quake.lua index d2a49d3..698277b 100644 --- a/util/quake.lua +++ b/util/quake.lua @@ -50,7 +50,7 @@ function quake:display() if not client then -- The client does not exist, we spawn it - cmd = string.format("%s %s %s", self.app, + local cmd = string.format("%s %s %s", self.app, string.format(self.argname, self.name), self.extra) awful.spawn(cmd, { tag = self.screen.selected_tag }) return @@ -89,8 +89,8 @@ function quake:display() client.fullscreen = false client.hidden = true local ctags = client:tags() - for i, t in pairs(ctags) do - ctags[i] = nil + for j, _ in pairs(ctags) do + ctags[j] = nil end client:tags(ctags) end diff --git a/util/separators.lua b/util/separators.lua index 465132d..b13ddf8 100644 --- a/util/separators.lua +++ b/util/separators.lua @@ -21,17 +21,17 @@ function separators.arrow_right(col1, col2) widget.col1 = col1 widget.col2 = col2 - widget.fit = function(m, w, h) + widget.fit = function(_, _, _) return separators.width, separators.height end - widget.update = function(col1, col2) + widget.update = function(_, _) widget.col1 = col1 widget.col2 = col2 widget:emit_signal("widget::redraw_needed") end - widget.draw = function(mycross, wibox, cr, width, height) + widget.draw = function(_, _, cr, width, height) if widget.col2 ~= "alpha" then cr:set_source_rgb(gears.color.parse_color(widget.col2)) cr:new_path() @@ -69,7 +69,7 @@ function separators.arrow_left(col1, col2) widget.col1 = col1 widget.col2 = col2 - widget.fit = function(m, w, h) + widget.fit = function(_, _, _) return separators.width, separators.height end @@ -79,7 +79,7 @@ function separators.arrow_left(col1, col2) widget:emit_signal("widget::redraw_needed") end - widget.draw = function(mycross, wibox, cr, width, height) + widget.draw = function(_, _, cr, width, height) if widget.col1 ~= "alpha" then cr:set_source_rgb(gears.color.parse_color(widget.col1)) cr:new_path() diff --git a/widget/alsa.lua b/widget/alsa.lua index 49b2cf0..cd095e2 100644 --- a/widget/alsa.lua +++ b/widget/alsa.lua @@ -15,7 +15,7 @@ local string = string -- lain.widget.alsa local function factory(args) - local args = args or {} + args = args or {} local alsa = { widget = args.widget or wibox.widget.textbox() } local timeout = args.timeout or 5 local settings = args.settings or function() end diff --git a/widget/alsabar.lua b/widget/alsabar.lua index b2f7b44..8e8cd3a 100644 --- a/widget/alsabar.lua +++ b/widget/alsabar.lua @@ -30,13 +30,13 @@ local function factory(args) _playback = "off" } - local args = args or {} + args = args or {} + local timeout = args.timeout or 5 local settings = args.settings or function() end local width = args.width or 63 local height = args.height or 1 local margins = args.margins or 1 - local paddings = args.paddings or 1 local ticks = args.ticks or false local ticks_size = args.ticks_size or 7 local tick = args.tick or "|" @@ -136,7 +136,7 @@ local function factory(args) end end - int = math.modf((alsabar._current_level / 100) * tot) + local int = math.modf((alsabar._current_level / 100) * tot) preset.text = string.format( "%s%s%s%s", tick_pre, diff --git a/widget/bat.lua b/widget/bat.lua index 7e69e1f..891bd76 100644 --- a/widget/bat.lua +++ b/widget/bat.lua @@ -26,7 +26,8 @@ local function factory(args) return end - local args = args or {} + args = args or {} + local bat = { widget = args.widget or wibox.widget.textbox() } local timeout = args.timeout or 30 local notify = args.notify or "on" diff --git a/widget/cal.lua b/widget/cal.lua index 1f6df2b..91f9b47 100644 --- a/widget/cal.lua +++ b/widget/cal.lua @@ -150,7 +150,7 @@ local function factory(args) function cal.hover_on() cal.show(0) end function cal.move(offset) - local offset = offset or 0 + offset = offset or 0 cal.month, cal.year = cal.getdate(cal.month, cal.year, offset) cal.show(0, cal.month, cal.year) end diff --git a/widget/contrib/moc.lua b/widget/contrib/moc.lua index e9a7dfe..ad6452e 100644 --- a/widget/contrib/moc.lua +++ b/widget/contrib/moc.lua @@ -18,7 +18,8 @@ local string = string -- lain.widget.contrib.moc local function factory(args) - local args = args or {} + args = args or {} + local moc = { widget = args.widget or wibox.widget.textbox() } local timeout = args.timeout or 2 local music_dir = args.music_dir or os.getenv("HOME") .. "/Music" diff --git a/widget/contrib/redshift.lua b/widget/contrib/redshift.lua index d0e5eed..d91d941 100644 --- a/widget/contrib/redshift.lua +++ b/widget/contrib/redshift.lua @@ -15,7 +15,7 @@ local type = type -- lain.widget.contrib.redshift local redshift = { active = false, pid = nil } -function redshift:start() +function redshift.start() execute("pkill redshift") awful.spawn.with_shell("redshift -x") -- clear adjustments redshift.pid = awful.spawn.with_shell("redshift") @@ -25,14 +25,14 @@ function redshift:start() end end -function redshift:toggle() +function redshift.toggle() async({ awful.util.shell, "-c", string.format("ps -p %d -o pid=", redshift.pid) }, function(f) if f and #f > 0 then -- redshift is running -- Sending -USR1 toggles redshift (See project website) execute("pkill -USR1 redshift") redshift.active = not redshift.active else -- not started or killed, (re)start it - redshift:start() + redshift.start() end redshift.update_fun(redshift.active) end) @@ -43,11 +43,11 @@ end -- @param widget: Widget to attach to. -- @param fun: Function to be run each time redshift is toggled (optional). -- Use it to update widget text or icons on status change. -function redshift:attach(widget, fun) +function redshift.attach(widget, fun) redshift.update_fun = fun or function() end - if not redshift.pid then redshift:start() end + if not redshift.pid then redshift.start() end if widget then - widget:buttons(awful.util.table.join(awful.button({}, 1, function () redshift:toggle() end))) + widget:buttons(awful.util.table.join(awful.button({}, 1, function () redshift.toggle() end))) end end diff --git a/widget/contrib/task.lua b/widget/contrib/task.lua index 536e006..2311996 100644 --- a/widget/contrib/task.lua +++ b/widget/contrib/task.lua @@ -10,7 +10,6 @@ local markup = require("lain.util").markup local awful = require("awful") local naughty = require("naughty") local mouse = mouse -local string = string -- Taskwarrior notification -- lain.widget.contrib.task @@ -69,7 +68,8 @@ function task.prompt() end function task.attach(widget, args) - local args = args or {} + args = args or {} + task.show_cmd = args.show_cmd or "task next" task.prompt_text = args.prompt_text or "Enter task command: " task.followtag = args.followtag or false diff --git a/widget/contrib/tp_smapi.lua b/widget/contrib/tp_smapi.lua index b8acbe2..87c5e51 100644 --- a/widget/contrib/tp_smapi.lua +++ b/widget/contrib/tp_smapi.lua @@ -8,7 +8,6 @@ local helpers = require("lain.helpers") local focused = require("awful.screen").focused -local gears = require("gears") local naughty = require("naughty") local wibox = require("wibox") local string = string @@ -61,7 +60,7 @@ local function factory(apipath) local chem = tp_smapi.get(batid, "chemistry") or "no_chem" local status = tp_smapi.get(batid, "state") local time = tp_smapi.time(batid) - local msg = "" + local msg if status and status ~= "idle" then msg = string.format("[%s] %s %s", status, time ~= "N/A" and time or "unknown remaining time", @@ -80,7 +79,8 @@ local function factory(apipath) end function tp_smapi.create_widget(args) - local args = args or {} + args = args or {} + local pspath = args.pspath or "/sys/class/power_supply/" local batteries = args.batteries or (args.battery and {args.battery}) or {} local timeout = args.timeout or 30 @@ -95,7 +95,7 @@ local function factory(apipath) local all_batteries_installed = true - for i, battery in ipairs(batteries) do + for _, battery in ipairs(batteries) do if not tp_smapi.installed(battery) then naughty.notify { preset = naughty.config.critical, diff --git a/widget/cpu.lua b/widget/cpu.lua index b823a5f..c2e28b0 100644 --- a/widget/cpu.lua +++ b/widget/cpu.lua @@ -10,13 +10,13 @@ local helpers = require("lain.helpers") local wibox = require("wibox") local math = math local string = string -local tostring = tostring -- CPU usage -- lain.widget.cpu local function factory(args) - local args = args or {} + args = args or {} + local cpu = { core = {}, widget = args.widget or wibox.widget.textbox() } local timeout = args.timeout or 2 local settings = args.settings or function() end diff --git a/widget/fs.lua b/widget/fs.lua index 63714d2..cc00cab 100644 --- a/widget/fs.lua +++ b/widget/fs.lua @@ -16,7 +16,6 @@ local math = math local string = string local tconcat = table.concat local type = type -local tonumber = tonumber local query_size = Gio.FILE_ATTRIBUTE_FILESYSTEM_SIZE local query_free = Gio.FILE_ATTRIBUTE_FILESYSTEM_FREE local query_used = Gio.FILE_ATTRIBUTE_FILESYSTEM_USED @@ -26,7 +25,8 @@ local query = query_size .. "," .. query_free .. "," .. query_used -- lain.widget.fs local function factory(args) - local args = args or {} + args = args or {} + local fs = { widget = args.widget or wibox.widget.textbox(), units = { diff --git a/widget/imap.lua b/widget/imap.lua index c8eb2c9..e3f7baa 100644 --- a/widget/imap.lua +++ b/widget/imap.lua @@ -17,7 +17,8 @@ local tonumber = tonumber -- lain.widget.imap local function factory(args) - local args = args or {} + args = args or {} + local imap = { widget = args.widget or wibox.widget.textbox() } local server = args.server local mail = args.mail diff --git a/widget/mem.lua b/widget/mem.lua index 90933b6..0318494 100644 --- a/widget/mem.lua +++ b/widget/mem.lua @@ -14,7 +14,8 @@ local gmatch, lines, floor = string.gmatch, io.lines, math.floor -- lain.widget.mem local function factory(args) - local args = args or {} + args = args or {} + local mem = { widget = args.widget or wibox.widget.textbox() } local timeout = args.timeout or 2 local settings = args.settings or function() end diff --git a/widget/mpd.lua b/widget/mpd.lua index 13994bd..143e085 100644 --- a/widget/mpd.lua +++ b/widget/mpd.lua @@ -19,7 +19,8 @@ local string = string -- lain.widget.mpd local function factory(args) - local args = args or {} + args = args or {} + local mpd = { widget = args.widget or wibox.widget.textbox() } local timeout = args.timeout or 2 local password = (args.password and #args.password > 0 and string.format("password %s\\n", args.password)) or "" diff --git a/widget/net.lua b/widget/net.lua index ea2510c..49e60f4 100644 --- a/widget/net.lua +++ b/widget/net.lua @@ -15,7 +15,8 @@ local string = string -- lain.widget.net local function factory(args) - local args = args or {} + args = args or {} + local net = { widget = args.widget or wibox.widget.textbox(), devices = {} } local timeout = args.timeout or 2 local units = args.units or 1024 -- KB @@ -70,16 +71,16 @@ local function factory(args) if wifi_state == "on" and helpers.first_line(string.format("/sys/class/net/%s/uevent", dev)) == "DEVTYPE=wlan" then dev_now.wifi = true - if string.match(dev_now.carrier, "1") then - dev_now.signal = tonumber(string.match(helpers.lines_from("/proc/net/wireless")[3], "(%-%d+%.)")) or nil - end - else + if string.match(dev_now.carrier, "1") then + dev_now.signal = tonumber(string.match(helpers.lines_from("/proc/net/wireless")[3], "(%-%d+%.)")) or nil + end + else dev_now.wifi = false end if eth_state == "on" and helpers.first_line(string.format("/sys/class/net/%s/uevent", dev)) ~= "DEVTYPE=wlan" then dev_now.ethernet = true - else + else dev_now.ethernet = false end diff --git a/widget/pulse.lua b/widget/pulse.lua index 5a6fb0b..69f4d70 100644 --- a/widget/pulse.lua +++ b/widget/pulse.lua @@ -15,7 +15,8 @@ local type = type -- lain.widget.pulse local function factory(args) - local args = args or {} + args = args or {} + local pulse = { widget = args.widget or wibox.widget.textbox(), device = "N/A" } local timeout = args.timeout or 5 local settings = args.settings or function() end diff --git a/widget/pulsebar.lua b/widget/pulsebar.lua index 5f6e47a..19e73b9 100644 --- a/widget/pulsebar.lua +++ b/widget/pulsebar.lua @@ -32,7 +32,8 @@ local function factory(args) device = "N/A" } - local args = args or {} + args = args or {} + local timeout = args.timeout or 5 local settings = args.settings or function() end local width = args.width or 63 @@ -144,7 +145,7 @@ local function factory(args) end end - int = math.modf((pulsebar._current_level / 100) * tot) + local int = math.modf((pulsebar._current_level / 100) * tot) preset.text = string.format( "%s%s%s%s", tick_pre, diff --git a/widget/sysload.lua b/widget/sysload.lua index 38cdd9d..7260524 100644 --- a/widget/sysload.lua +++ b/widget/sysload.lua @@ -14,7 +14,8 @@ local open, match = io.open, string.match -- lain.widget.sysload local function factory(args) - local args = args or {} + args = args or {} + local sysload = { widget = args.widget or wibox.widget.textbox() } local timeout = args.timeout or 2 local settings = args.settings or function() end diff --git a/widget/temp.lua b/widget/temp.lua index 8b646a0..05723f5 100644 --- a/widget/temp.lua +++ b/widget/temp.lua @@ -13,7 +13,8 @@ local tonumber = tonumber -- lain.widget.temp local function factory(args) - local args = args or {} + args = args or {} + local temp = { widget = args.widget or wibox.widget.textbox() } local timeout = args.timeout or 30 local tempfile = args.tempfile or "/sys/devices/virtual/thermal/thermal_zone0/temp" diff --git a/widget/weather.lua b/widget/weather.lua index 3cf5102..afef040 100644 --- a/widget/weather.lua +++ b/widget/weather.lua @@ -21,18 +21,17 @@ local tonumber = tonumber -- lain.widget.weather local function factory(args) - local args = args or {} + args = args or {} + local weather = { widget = args.widget or wibox.widget.textbox() } local APPID = args.APPID or "3e321f9414eaedbfab34983bda77a66e" -- lain's default local timeout = args.timeout or 60 * 15 -- 15 min - local timeout_forecast = args.timeout or 60 * 60 * 24 -- 24 hrs 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/daily?id=%s&units=%s&lang=%s&cnt=%s&APPID=%s'" local city_id = args.city_id or 0 -- placeholder local units = args.units or "metric" local lang = args.lang or "en" local cnt = args.cnt or 5 - local date_cmd = args.date_cmd or "date -u -d @%d +'%%a %%d'" local icons_path = args.icons_path or helpers.icons_dir .. "openweathermap/" local notification_preset = args.notification_preset or {} local notification_text_fun = args.notification_text_fun or @@ -91,8 +90,8 @@ local function factory(args) function weather.forecast_update() local cmd = string.format(forecast_call, city_id, units, lang, cnt, APPID) helpers.async(cmd, function(f) - local pos, err - weather_now, pos, err = json.decode(f, 1, nil) + 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 weather.notification_text = "" @@ -110,8 +109,8 @@ local function factory(args) function weather.update() local cmd = string.format(current_call, city_id, units, lang, APPID) helpers.async(cmd, function(f) - local pos, err, icon - weather_now, pos, err = json.decode(f, 1, nil) + 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"]) From 6b3bdcaed1a8ba4fba8343c5d19b3b73542e0780 Mon Sep 17 00:00:00 2001 From: Luca CPZ Date: Mon, 30 Nov 2020 14:58:27 +0000 Subject: [PATCH 30/35] #474: remove remaining 9 warnings --- helpers.lua | 5 ++--- layout/centerwork.lua | 8 ++++---- layout/termfair.lua | 4 ++-- util/quake.lua | 34 +++++++++++++++++----------------- util/separators.lua | 8 ++++---- 5 files changed, 29 insertions(+), 30 deletions(-) diff --git a/helpers.lua b/helpers.lua index 1829b7b..45f090f 100644 --- a/helpers.lua +++ b/helpers.lua @@ -25,9 +25,8 @@ helpers.scripts_dir = helpers.lain_dir .. 'scripts/' -- {{{ Modules loader -function helpers.wrequire(table, key) - local module = rawget(table, key) - return module or require(table._NAME .. '.' .. key) +function helpers.wrequire(t, k) + return rawget(t, k) or require(t._NAME .. '.' .. k) end -- }}} diff --git a/layout/centerwork.lua b/layout/centerwork.lua index 81ac8f3..142ccbe 100644 --- a/layout/centerwork.lua +++ b/layout/centerwork.lua @@ -24,7 +24,7 @@ local function arrange(p, layout) if #cls == 0 then return end - local c, g = cls[1], {} + local g = {} -- Main column, fixed width and height local mwfact = t.master_width_factor @@ -64,12 +64,12 @@ local function arrange(p, layout) g.width = max(g.width, 1) g.height = max(g.height, 1) - p.geometries[c] = g + p.geometries[cls[1]] = g -- Auxiliary clients if #cls <= 1 then return end for i = 2, #cls do - local c, g = cls[i], {} + g = {} local idxChecker, dimToAssign local rowIndex = floor(i/2) @@ -121,7 +121,7 @@ local function arrange(p, layout) g.width = max(g.width, 1) g.height = max(g.height, 1) - p.geometries[c] = g + p.geometries[cls[i]] = g end end diff --git a/layout/termfair.lua b/layout/termfair.lua index eede3ba..cf018ef 100644 --- a/layout/termfair.lua +++ b/layout/termfair.lua @@ -241,7 +241,7 @@ local function do_fair(p, orientation) local height = math.floor(wa.height / num_y[i]) local wy = wa.y for _ = 0, (num_y[i]-2) do - local g = {} + g = {} g.x = wx g.y = wy g.height = height @@ -252,7 +252,7 @@ local function do_fair(p, orientation) nclient = nclient + 1 wy = wy + height end - local g = {} + g = {} g.x = wx g.y = wy g.height = wa.height - (num_y[i] - 1)*height diff --git a/util/quake.lua b/util/quake.lua index 698277b..8bc68a7 100644 --- a/util/quake.lua +++ b/util/quake.lua @@ -122,8 +122,22 @@ function quake:compute_size() return self.geometry[self.screen.index] end -function quake:new(config) - local conf = config or {} +function quake:toggle() + if self.followtag then self.screen = awful.screen.focused() end + local current_tag = self.screen.selected_tag + if current_tag and self.last_tag ~= current_tag and self.visible then + local c=self:display() + if c then + c:move_to_tag(current_tag) + end + else + self.visible = not self.visible + self:display() + end +end + +function quake.new(conf) + conf = conf or {} conf.app = conf.app or "xterm" -- application to spawn conf.name = conf.name or "QuakeDD" -- window name @@ -162,18 +176,4 @@ function quake:new(config) return dropdown end -function quake:toggle() - if self.followtag then self.screen = awful.screen.focused() end - local current_tag = self.screen.selected_tag - if current_tag and self.last_tag ~= current_tag and self.visible then - local c=self:display() - if c then - c:move_to_tag(current_tag) - end - else - self.visible = not self.visible - self:display() - end -end - -return setmetatable(quake, { __call = function(_, ...) return quake:new(...) end }) +return setmetatable(quake, { __call = function(_, ...) return quake.new(...) end }) diff --git a/util/separators.lua b/util/separators.lua index b13ddf8..23535b7 100644 --- a/util/separators.lua +++ b/util/separators.lua @@ -69,13 +69,13 @@ function separators.arrow_left(col1, col2) widget.col1 = col1 widget.col2 = col2 - widget.fit = function(_, _, _) + widget.fit = function(_, _, _) return separators.width, separators.height end - widget.update = function(col1, col2) - widget.col1 = col1 - widget.col2 = col2 + widget.update = function(c1, c2) + widget.col1 = c1 + widget.col2 = c2 widget:emit_signal("widget::redraw_needed") end From 3236575b527c1e6b17836f82a04dd316115b711f Mon Sep 17 00:00:00 2001 From: Luca CPZ Date: Thu, 3 Dec 2020 11:43:13 +0000 Subject: [PATCH 31/35] wiki updated --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index 2899629..877b34b 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 2899629c445cb12efb72cc538e36cfc2ec812201 +Subproject commit 877b34bf5624caee917c0d81bc553b60dbdeabe2 From 80e41c1e7b375e7be02582554a7ba2fff66c06bd Mon Sep 17 00:00:00 2001 From: Luca Capezzuto Date: Wed, 16 Dec 2020 11:40:26 +0100 Subject: [PATCH 32/35] widget.weather: fix check in notification #479 --- widget/weather.lua | 2 +- wiki | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/widget/weather.lua b/widget/weather.lua index afef040..9cf1ac6 100644 --- a/widget/weather.lua +++ b/widget/weather.lua @@ -67,7 +67,7 @@ local function factory(args) preset = notification_preset, text = weather.notification_text, icon = weather.icon_path, - timeout = type(seconds == "number") and seconds or notification_preset.timeout + timeout = type(seconds) == "number" and seconds or notification_preset.timeout } end diff --git a/wiki b/wiki index 877b34b..ddc6aa0 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 877b34bf5624caee917c0d81bc553b60dbdeabe2 +Subproject commit ddc6aa0649d4fd091c1a73784d0507feb86eaf5f From c2ec8f2a6bc7a6b159c3d693739cbdc7dea4b53b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20James?= Date: Tue, 29 Dec 2020 15:51:23 +0100 Subject: [PATCH 33/35] Allow transparency in util.seperators --- util/separators.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/separators.lua b/util/separators.lua index 23535b7..ae384ec 100644 --- a/util/separators.lua +++ b/util/separators.lua @@ -33,7 +33,7 @@ function separators.arrow_right(col1, col2) widget.draw = function(_, _, cr, width, height) if widget.col2 ~= "alpha" then - cr:set_source_rgb(gears.color.parse_color(widget.col2)) + cr:set_source_rgba(gears.color.parse_color(widget.col2)) cr:new_path() cr:move_to(0, 0) cr:line_to(width, height/2) @@ -50,7 +50,7 @@ function separators.arrow_right(col1, col2) end if widget.col1 ~= "alpha" then - cr:set_source_rgb(gears.color.parse_color(widget.col1)) + cr:set_source_rgba(gears.color.parse_color(widget.col1)) cr:new_path() cr:move_to(0, 0) cr:line_to(width, height/2) @@ -81,7 +81,7 @@ function separators.arrow_left(col1, col2) widget.draw = function(_, _, cr, width, height) if widget.col1 ~= "alpha" then - cr:set_source_rgb(gears.color.parse_color(widget.col1)) + cr:set_source_rgba(gears.color.parse_color(widget.col1)) cr:new_path() cr:move_to(width, 0) cr:line_to(0, height/2) @@ -104,7 +104,7 @@ function separators.arrow_left(col1, col2) cr:line_to(width, height) cr:close_path() - cr:set_source_rgb(gears.color.parse_color(widget.col2)) + cr:set_source_rgba(gears.color.parse_color(widget.col2)) cr:fill() end end From c782f7d775b6fe8784e1b339e9a0d6e522a2357f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Le=20Corre?= Date: Wed, 13 Jan 2021 04:09:47 +0100 Subject: [PATCH 34/35] Validate function before callback. Fixes #482 --- widget/fs.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widget/fs.lua b/widget/fs.lua index 48d80b7..b3a2dad 100644 --- a/widget/fs.lua +++ b/widget/fs.lua @@ -137,7 +137,7 @@ local function factory(args) function fs.update(callback) Gio.Async.start(gears.protected_call.call)(function() update_synced() - if callback then + if type(callback) == "function" and callback then callback() end end) From 15bba301803bec2be7fcd5e826b674f8ed59d7a0 Mon Sep 17 00:00:00 2001 From: Anders Fugmann Date: Mon, 18 Jan 2021 17:47:40 +0100 Subject: [PATCH 35/35] Fix ac detection for bat widget. Multiple power sources may exist under /sys/class/power_supply/. Durring autodetection (get_batteries), will case the detected ac to be reset to 'AC0' if a power source not starting with BAT or AC. This change skips updating the name of the ac device if the devices does not start with 'AC' --- widget/bat.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widget/bat.lua b/widget/bat.lua index 891bd76..77324de 100644 --- a/widget/bat.lua +++ b/widget/bat.lua @@ -43,7 +43,7 @@ local function factory(args) if bstr then batteries[#batteries + 1] = bstr else - ac = string.match(line, "A%w+") or "AC0" + ac = string.match(line, "A%w+") or ac end end) end