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 01/11] 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 02/11] 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 03/11] 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 04/11] 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 05/11] 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 06/11] 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 07/11] 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 08/11] 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 09/11] 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 6b2a4ce4d9ac3dd5ded5d9bd7f8a1b9bae79e505 Mon Sep 17 00:00:00 2001 From: unisgn Date: Thu, 26 Nov 2020 01:16:30 +0800 Subject: [PATCH 10/11] 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 11/11] 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()