From fb14da7adc6c9dc3d9af1b2f7aa4f572c5794ec2 Mon Sep 17 00:00:00 2001 From: Roland Hieber Date: Wed, 8 Jun 2016 03:20:21 +0200 Subject: [PATCH 01/84] mpd: make notifications hideable in widget config --- widgets/mpd.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/widgets/mpd.lua b/widgets/mpd.lua index 1972050..b2327bd 100644 --- a/widgets/mpd.lua +++ b/widgets/mpd.lua @@ -37,6 +37,7 @@ local function worker(args) local music_dir = args.music_dir or os.getenv("HOME") .. "/Music" local cover_size = args.cover_size or 100 local default_art = args.default_art or "" + local show_notifications = args.show_notifications == true local followmouse = args.followmouse or false local echo_cmd = args.echo_cmd or "echo" local settings = args.settings or function() end @@ -90,7 +91,7 @@ local function worker(args) if mpd_now.state == "play" then - if mpd_now.title ~= helpers.get_map("current mpd track") + if show_notifications and mpd_now.title ~= helpers.get_map("current mpd track") then helpers.set_map("current mpd track", mpd_now.title) From effa8f1dc2e428f876b916efc5b2d8efcbf64863 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Wed, 8 Jun 2016 11:46:02 +0200 Subject: [PATCH 02/84] #204: revert to not hidden as default --- widgets/bat.lua | 4 ++-- widgets/mpd.lua | 4 ++-- wiki | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index 3b9cca0..e5b5afc 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -28,7 +28,7 @@ local function worker(args) local timeout = args.timeout or 30 local batteries = args.batteries or (args.battery and {args.battery}) or {"BAT0"} local ac = args.ac or "AC0" - local notify = args.notify or "on" + local notify = args.notify or true local settings = args.settings or function() end bat.widget = wibox.widget.textbox('') @@ -133,7 +133,7 @@ local function worker(args) settings() -- notifications for low and critical states - if bat_now.status == "Discharging" and notify == "on" and bat_now.perc then + if notify and bat_now.perc and bat_now.status == "Discharging" then local nperc = tonumber(bat_now.perc) or 100 if nperc <= 5 then bat.id = naughty.notify({ diff --git a/widgets/mpd.lua b/widgets/mpd.lua index b2327bd..65a9274 100644 --- a/widgets/mpd.lua +++ b/widgets/mpd.lua @@ -37,7 +37,7 @@ local function worker(args) local music_dir = args.music_dir or os.getenv("HOME") .. "/Music" local cover_size = args.cover_size or 100 local default_art = args.default_art or "" - local show_notifications = args.show_notifications == true + local notify = args.notify or true local followmouse = args.followmouse or false local echo_cmd = args.echo_cmd or "echo" local settings = args.settings or function() end @@ -91,7 +91,7 @@ local function worker(args) if mpd_now.state == "play" then - if show_notifications and mpd_now.title ~= helpers.get_map("current mpd track") + if notify and mpd_now.title ~= helpers.get_map("current mpd track") then helpers.set_map("current mpd track", mpd_now.title) diff --git a/wiki b/wiki index 25dd1a2..00c10f5 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 25dd1a2ec44da832d06ded29f393d716e4b54783 +Subproject commit 00c10f580b55e50a3d6c9c590fe17df15b3ec93c From c251f2844bbbe95f2c0cc2bf97008aa981fcfc85 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Wed, 8 Jun 2016 11:52:36 +0200 Subject: [PATCH 03/84] revert to not hidden as default 2 --- widgets/bat.lua | 4 ++-- widgets/mpd.lua | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index e5b5afc..62d1469 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -28,7 +28,7 @@ local function worker(args) local timeout = args.timeout or 30 local batteries = args.batteries or (args.battery and {args.battery}) or {"BAT0"} local ac = args.ac or "AC0" - local notify = args.notify or true + local notify = args.notify or "on" local settings = args.settings or function() end bat.widget = wibox.widget.textbox('') @@ -133,7 +133,7 @@ local function worker(args) settings() -- notifications for low and critical states - if notify and bat_now.perc and bat_now.status == "Discharging" then + if notify == "on" and bat_now.perc and bat_now.status == "Discharging" then local nperc = tonumber(bat_now.perc) or 100 if nperc <= 5 then bat.id = naughty.notify({ diff --git a/widgets/mpd.lua b/widgets/mpd.lua index 65a9274..b0ab28f 100644 --- a/widgets/mpd.lua +++ b/widgets/mpd.lua @@ -37,7 +37,7 @@ local function worker(args) local music_dir = args.music_dir or os.getenv("HOME") .. "/Music" local cover_size = args.cover_size or 100 local default_art = args.default_art or "" - local notify = args.notify or true + local notify = args.notify or "on" local followmouse = args.followmouse or false local echo_cmd = args.echo_cmd or "echo" local settings = args.settings or function() end @@ -91,7 +91,7 @@ local function worker(args) if mpd_now.state == "play" then - if notify and mpd_now.title ~= helpers.get_map("current mpd track") + if notify == "on" and mpd_now.title ~= helpers.get_map("current mpd track") then helpers.set_map("current mpd track", mpd_now.title) From e363fdfeafc331ee29780905361f137aa691b5df Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Wed, 8 Jun 2016 11:55:23 +0200 Subject: [PATCH 04/84] wiki updated; #204 --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index 00c10f5..792e2e9 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 00c10f580b55e50a3d6c9c590fe17df15b3ec93c +Subproject commit 792e2e940ad8b42f13b9d4875fad24fceba62be5 From 5547a4949653f29d418e44a2c159ee7cd5688b98 Mon Sep 17 00:00:00 2001 From: Luke Bonham Date: Thu, 9 Jun 2016 11:53:07 +0200 Subject: [PATCH 05/84] battery: always update status #199 #203 --- widgets/bat.lua | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index 62d1469..0da9708 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -92,10 +92,7 @@ local function worker(args) local energy_percentage = tonumber(first_line(bstr .. "/capacity")) or math.floor((energy_now / energy_full) * 100) - if bat_now.n_status[i] ~= "Charging" and bat_now.n_status[i] ~= "Discharging" - then - bat_now.n_status[i] = first_line(bstr .. "/status") or "N/A" - end + bat_now.n_status[i] = first_line(bstr .. "/status") or "N/A" sum_rate_current = sum_rate_current + (rate_current or 0) sum_rate_voltage = sum_rate_voltage + rate_voltage @@ -109,8 +106,8 @@ local function worker(args) bat_now.status = bat_now.n_status[1] bat_now.ac_status = first_line(string.format("/sys/class/power_supply/%s/online", ac)) or "N/A" - -- update {perc,time,watt} iff rate > 0 and battery not full - if (sum_rate_current > 0 or sum_rate_power > 0) and not (bat_now.status == "Full") + -- update {perc,time,watt} iff battery not full and rate > 0 + if bat_now.status ~= "Full" and (sum_rate_current > 0 or sum_rate_power > 0) then local rate_time = 0 @@ -124,9 +121,9 @@ local function worker(args) local minutes = math.floor((rate_time - hours) * 60) local watt = sum_rate_power / 1e6 - bat_now.perc = string.format("%d", math.min(100, sum_energy_percentage / #batteries)) + bat_now.perc = tonumber(string.format("%d", math.min(100, sum_energy_percentage / #batteries))) bat_now.time = string.format("%02d:%02d", hours, minutes) - bat_now.watt = string.format("%.2fW", watt) + bat_now.watt = tonumber(string.format("%.2fW", watt)) end widget = bat.widget @@ -134,16 +131,15 @@ local function worker(args) -- notifications for low and critical states if notify == "on" and bat_now.perc and bat_now.status == "Discharging" then - local nperc = tonumber(bat_now.perc) or 100 - if nperc <= 5 then + if perc <= 5 then bat.id = naughty.notify({ preset = bat_notification_critical_preset, - replaces_id = bat.id, + replaces_id = bat.id }).id - elseif nperc <= 15 then + elseif perc <= 15 then bat.id = naughty.notify({ preset = bat_notification_low_preset, - replaces_id = bat.id, + replaces_id = bat.id }).id end end From f76940230a854482a2ff3715fd2427eba206e68d Mon Sep 17 00:00:00 2001 From: Luke Bonham Date: Thu, 9 Jun 2016 12:19:03 +0200 Subject: [PATCH 06/84] battery: always update status (fix perc) #199 #203 --- widgets/bat.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index 0da9708..df0ee5d 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -131,12 +131,12 @@ local function worker(args) -- notifications for low and critical states if notify == "on" and bat_now.perc and bat_now.status == "Discharging" then - if perc <= 5 then + if bat_now.perc <= 5 then bat.id = naughty.notify({ preset = bat_notification_critical_preset, replaces_id = bat.id }).id - elseif perc <= 15 then + elseif bat_now.perc <= 15 then bat.id = naughty.notify({ preset = bat_notification_low_preset, replaces_id = bat.id From 610bc1991a424c9f1ac550c1748ce9b41ce023e0 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Mon, 13 Jun 2016 09:08:05 +0200 Subject: [PATCH 07/84] #199 #203 fix attempt 2 --- widgets/bat.lua | 42 +++++++++++++++++++++++------------------- wiki | 2 +- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index df0ee5d..92d1833 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -50,7 +50,7 @@ local function worker(args) } bat_now = { - status = "Not present", + status = "N/A", ac_status = "N/A", perc = "N/A", time = "N/A", @@ -59,7 +59,7 @@ local function worker(args) bat_now.n_status = {} for i = 1, #batteries do - bat_now.n_status[i] = "Not present" + bat_now.n_status[i] = "N/A" end function update() @@ -104,26 +104,30 @@ local function worker(args) end bat_now.status = bat_now.n_status[1] - bat_now.ac_status = first_line(string.format("/sys/class/power_supply/%s/online", ac)) or "N/A" + bat_now.ac_status = tonumber(first_line(string.format("/sys/class/power_supply/%s/online", ac))) or "N/A" - -- update {perc,time,watt} iff battery not full and rate > 0 - if bat_now.status ~= "Full" and (sum_rate_current > 0 or sum_rate_power > 0) - then - local rate_time = 0 + if bat_now.status ~= "N/A" then + -- update {perc,time,watt} iff battery not full and rate > 0 + if bat_now.status ~= "Full" and (sum_rate_current > 0 or sum_rate_power > 0) then + local rate_time = 0 - if bat_now.status == "Charging" then - rate_time = (sum_energy_full - sum_energy_now) / (sum_rate_power or sum_rate_current) - elseif bat_now.status == "Discharging" then - rate_time = sum_energy_now / (sum_rate_power or sum_rate_current) + if bat_now.status == "Charging" then + rate_time = (sum_energy_full - sum_energy_now) / (sum_rate_power or sum_rate_current) + elseif bat_now.status == "Discharging" then + rate_time = sum_energy_now / (sum_rate_power or sum_rate_current) + end + + local hours = math.floor(rate_time) + local minutes = math.floor((rate_time - hours) * 60) + local watt = (sum_rate_power / 1e6) + + bat_now.perc = tonumber(string.format("%d", math.min(100, sum_energy_percentage / #batteries))) + bat_now.time = string.format("%02d:%02d", hours, minutes) + bat_now.watt = tonumber(string.format("%.2f", watt)) + -- consistency check + elseif bat_now.status == "Full" then + bat_now.perc = 100 end - - local hours = math.floor(rate_time) - local minutes = math.floor((rate_time - hours) * 60) - local watt = sum_rate_power / 1e6 - - bat_now.perc = tonumber(string.format("%d", math.min(100, sum_energy_percentage / #batteries))) - bat_now.time = string.format("%02d:%02d", hours, minutes) - bat_now.watt = tonumber(string.format("%.2fW", watt)) end widget = bat.widget diff --git a/wiki b/wiki index 792e2e9..f7076d2 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 792e2e940ad8b42f13b9d4875fad24fceba62be5 +Subproject commit f7076d287c5bf0cb0672969cba0520fd03c7bc7d From 7384fa0fa63aa5c487fd50b6263965d452d2059f Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Wed, 15 Jun 2016 09:33:52 +0200 Subject: [PATCH 08/84] #199 #203 fix attempt 3 --- widgets/bat.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index 92d1833..0c8fe5f 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -74,13 +74,14 @@ local function worker(args) local bstr = "/sys/class/power_supply/" .. battery local present = first_line(bstr .. "/present") - if present == "1" + if tonumber(present) == 1 then -- current_now(I)[uA], voltage_now(U)[uV], power_now(P)[uW] local rate_current = tonumber(first_line(bstr .. "/current_now")) local rate_voltage = tonumber(first_line(bstr .. "/voltage_now")) local rate_power = tonumber(first_line(bstr .. "/power_now")) + -- energy_now(P)[uWh], charge_now(I)[uAh] local energy_now = tonumber(first_line(bstr .. "/energy_now") or first_line(bstr .. "/charge_now")) @@ -97,7 +98,7 @@ local function worker(args) sum_rate_current = sum_rate_current + (rate_current or 0) sum_rate_voltage = sum_rate_voltage + rate_voltage sum_rate_power = sum_rate_power + (rate_power or ((rate_voltage * rate_current) / 1e6)) - sum_energy_now = sum_energy_now + energy_now + sum_energy_now = sum_energy_now + (energy_now or 0) sum_energy_full = sum_energy_full + energy_full sum_energy_percentage = sum_energy_percentage + energy_percentage end @@ -119,14 +120,13 @@ local function worker(args) local hours = math.floor(rate_time) local minutes = math.floor((rate_time - hours) * 60) - local watt = (sum_rate_power / 1e6) - bat_now.perc = tonumber(string.format("%d", math.min(100, sum_energy_percentage / #batteries))) bat_now.time = string.format("%02d:%02d", hours, minutes) - bat_now.watt = tonumber(string.format("%.2f", watt)) - -- consistency check + bat_now.watt = tonumber(string.format("%.2f", sum_rate_power / 1e6)) elseif bat_now.status == "Full" then - bat_now.perc = 100 + bat_now.perc = 100 + bat_now.time = "00:00" + bat_now.watt = 0 end end From bea41c9f4d55edcf56fc8c8559f08d0d2780d57b Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Wed, 15 Jun 2016 09:34:28 +0200 Subject: [PATCH 09/84] wiki updated --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index f7076d2..eaa4aaa 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit f7076d287c5bf0cb0672969cba0520fd03c7bc7d +Subproject commit eaa4aaac7fb0123a4dba05ac2ee63a5fa1247525 From b5b6e79a13620b77a6948ed911934eae00ad89d8 Mon Sep 17 00:00:00 2001 From: Roland Hieber Date: Mon, 20 Jun 2016 19:21:29 +0200 Subject: [PATCH 10/84] mpd: change whitespace to make the next commit pretty --- widgets/mpd.lua | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/widgets/mpd.lua b/widgets/mpd.lua index b0ab28f..5d8f068 100644 --- a/widgets/mpd.lua +++ b/widgets/mpd.lua @@ -58,28 +58,28 @@ local function worker(args) function mpd.update() async.request(echo .. " | curl --connect-timeout 1 -fsm 3 " .. mpdh, function (f) mpd_now = { - state = "N/A", - file = "N/A", - name = "N/A", - artist = "N/A", - title = "N/A", - album = "N/A", - date = "N/A", - time = "N/A", - elapsed = "N/A" + state = "N/A", + file = "N/A", + name = "N/A", + artist = "N/A", + title = "N/A", + album = "N/A", + date = "N/A", + time = "N/A", + elapsed = "N/A" } for line in string.gmatch(f, "[^\n]+") do for k, v in string.gmatch(line, "([%w]+):[%s](.*)$") do - if k == "state" then mpd_now.state = v - elseif k == "file" then mpd_now.file = v - elseif k == "Name" then mpd_now.name = escape_f(v) - elseif k == "Artist" then mpd_now.artist = escape_f(v) - elseif k == "Title" then mpd_now.title = escape_f(v) - elseif k == "Album" then mpd_now.album = escape_f(v) - elseif k == "Date" then mpd_now.date = escape_f(v) - elseif k == "Time" then mpd_now.time = v - elseif k == "elapsed" then mpd_now.elapsed = string.match(v, "%d+") + if k == "state" then mpd_now.state = v + elseif k == "file" then mpd_now.file = v + elseif k == "Name" then mpd_now.name = escape_f(v) + elseif k == "Artist" then mpd_now.artist = escape_f(v) + elseif k == "Title" then mpd_now.title = escape_f(v) + elseif k == "Album" then mpd_now.album = escape_f(v) + elseif k == "Date" then mpd_now.date = escape_f(v) + elseif k == "Time" then mpd_now.time = v + elseif k == "elapsed" then mpd_now.elapsed = string.match(v, "%d+") end end end From 7584d13fc11bb519ba09528c9fb132a31474a31c Mon Sep 17 00:00:00 2001 From: Roland Hieber Date: Mon, 20 Jun 2016 19:23:40 +0200 Subject: [PATCH 11/84] mpd: add info about playlist pos/length and single/consume/repeat/random mode --- widgets/mpd.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/widgets/mpd.lua b/widgets/mpd.lua index 5d8f068..6a327b0 100644 --- a/widgets/mpd.lua +++ b/widgets/mpd.lua @@ -58,6 +58,12 @@ local function worker(args) function mpd.update() async.request(echo .. " | curl --connect-timeout 1 -fsm 3 " .. mpdh, function (f) mpd_now = { + random_mode = false, + single_mode = false, + repeat_mode = false, + consume_mode = false, + pls_pos = "N/A", + pls_len = "N/A", state = "N/A", file = "N/A", name = "N/A", @@ -80,6 +86,12 @@ local function worker(args) elseif k == "Date" then mpd_now.date = escape_f(v) elseif k == "Time" then mpd_now.time = v elseif k == "elapsed" then mpd_now.elapsed = string.match(v, "%d+") + elseif k == "song" then mpd_now.pls_pos = v + elseif k == "playlistlength" then mpd_now.pls_len = v + elseif k == "repeat" then mpd_now.repeat_mode = v ~= "0" + elseif k == "single" then mpd_now.single_mode = v ~= "0" + elseif k == "random" then mpd_now.random_mode = v ~= "0" + elseif k == "consume" then mpd_now.consume_mode = v ~= "0" end end end From c9ed5d4f802701348ee3b1039c1bbb18a91526a1 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Tue, 21 Jun 2016 10:52:20 +0200 Subject: [PATCH 12/84] wiki updated --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index eaa4aaa..060b182 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit eaa4aaac7fb0123a4dba05ac2ee63a5fa1247525 +Subproject commit 060b1822e3a0bdcd59bcae2d047908b031310ea6 From c0646ff1641100887c182cfe2be1c0e7c9f8c5ad Mon Sep 17 00:00:00 2001 From: Alexandre Terrien Date: Wed, 22 Jun 2016 23:21:01 +0200 Subject: [PATCH 13/84] Added gpmpd widget --- widgets/contrib/gpmdp.lua | 105 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 widgets/contrib/gpmdp.lua diff --git a/widgets/contrib/gpmdp.lua b/widgets/contrib/gpmdp.lua new file mode 100644 index 0000000..6b4341b --- /dev/null +++ b/widgets/contrib/gpmdp.lua @@ -0,0 +1,105 @@ + +--[[ + + Licensed under GNU General Public License v2 + * (c) 2016, Alexandre Terrien + +--]] + +local helpers = require("lain.helpers") +local json = require("lain.util.dkjson") + +local pread = require("awful.util").pread + +local naughty = require("naughty") +local wibox = require("wibox") + +local mouse = mouse + +local setmetatable = setmetatable + +-- Google Play Music Desktop infos +-- lain.widget.contrib.gpmdp +local gpmdp = {} + +local function worker(args) + local args = args or {} + local timeout = args.timeout or 2 + local notify = args.notify or "off" + local followmouse = args.followmouse or false + local file_location = args.file_location or + os.getenv("HOME") .. "/.config/Google Play Music Desktop Player/json_store/playback.json" + local settings = args.settings or function() end + + gpmdp.widget = wibox.widget.textbox('') + + gpmdp_notification_preset = { + title = "Now playing", + timeout = 6 + } + + helpers.set_map("gpmpd_current", nil) + + function gpmdp.update() + file, err = io.open(file_location, "r") + if not file + then + gpm_now = { + running = false, + playing = false + } + else + dict, pos, err = json.decode(file:read "*a", 1, nil) + file:close() + gpm_now = {} + gpm_now.artist = dict.song.artist + gpm_now.album = dict.song.album + gpm_now.title = dict.song.title + gpm_now.cover_url = dict.song.albumArt + gpm_now.playing = dict.playing + end + if (pread("pidof 'Google Play Music Desktop Player'") ~= '') then + gpm_now.running = true + else + gpm_now.running = false + end + + gpmdp_notification_preset.text = string.format( + "%s (%s) - %s", + gpm_now.artist, + gpm_now.album, + gpm_now.title) + widget = gpmdp.widget + settings() + + if gpm_now.playing + then + if notify == "on" and gpm_now.title ~= helpers.get_map("gpmpd_current") + then + helpers.set_map("gpmpd_current", gpm_now.title) + + current_icon = "/tmp/gpmcover.png" + os.execute("curl " .. gpm_now.cover_url .. " -o " .. current_icon) + + if followmouse then + gpmdp_notification_preset.screen = mouse.screen + end + + gpmdp.id = naughty.notify({ + preset = gpmdp_notification_preset, + icon = current_icon, + replaces_id = gpmdp.id, + }).id + end + elseif (not gpm_now.running) + then + helpers.set_map("current mpd track", nil) + end + end + + helpers.newtimer("gpmdp", timeout, gpmdp.update) + + return setmetatable(gpmdp, { __index = gpmdp.widget }) +end + +return setmetatable(gpmdp, { __call = function(_, ...) return worker(...) end }) From c73b151849443f63d6d185c3c80dfa04f2ce04dc Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Thu, 23 Jun 2016 10:14:10 +0200 Subject: [PATCH 14/84] #199 #203 fix attempt 4 --- widgets/bat.lua | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index 0c8fe5f..fa9f854 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -63,25 +63,25 @@ local function worker(args) end function update() - local sum_rate_current = 0 - local sum_rate_voltage = 0 - local sum_rate_power = 0 - local sum_energy_now = 0 - local sum_energy_full = 0 + local sum_rate_current = 0 + local sum_rate_voltage = 0 + local sum_rate_power = 0 + local sum_energy_now = 0 + local sum_energy_full = 0 local sum_energy_percentage = 0 + local pspath = "/sys/class/power_supply/" + -- local pspath = "/home/luke/Download/" for i, battery in ipairs(batteries) do - local bstr = "/sys/class/power_supply/" .. battery + local bstr = pspath .. battery local present = first_line(bstr .. "/present") - if tonumber(present) == 1 - then + if tonumber(present) == 1 then -- current_now(I)[uA], voltage_now(U)[uV], power_now(P)[uW] local rate_current = tonumber(first_line(bstr .. "/current_now")) local rate_voltage = tonumber(first_line(bstr .. "/voltage_now")) local rate_power = tonumber(first_line(bstr .. "/power_now")) - -- energy_now(P)[uWh], charge_now(I)[uAh] local energy_now = tonumber(first_line(bstr .. "/energy_now") or first_line(bstr .. "/charge_now")) @@ -105,17 +105,19 @@ local function worker(args) end bat_now.status = bat_now.n_status[1] - bat_now.ac_status = tonumber(first_line(string.format("/sys/class/power_supply/%s/online", ac))) or "N/A" + bat_now.ac_status = tonumber(first_line(string.format("%s%s/online", pspath, ac))) or "N/A" if bat_now.status ~= "N/A" then -- update {perc,time,watt} iff battery not full and rate > 0 if bat_now.status ~= "Full" and (sum_rate_current > 0 or sum_rate_power > 0) then local rate_time = 0 + local sum_rpc = sum_rate_power or sum_rate_current + if sum_rpc >= 1e8 then sum_rpc = sum_rpc / 10 end if bat_now.status == "Charging" then - rate_time = (sum_energy_full - sum_energy_now) / (sum_rate_power or sum_rate_current) + rate_time = (sum_energy_full - sum_energy_now) / sum_rpc elseif bat_now.status == "Discharging" then - rate_time = sum_energy_now / (sum_rate_power or sum_rate_current) + rate_time = sum_energy_now / sum_rpc end local hours = math.floor(rate_time) From 14a3f6689ba5f3d189aa8d47f857dab1ffa2a3e7 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Fri, 24 Jun 2016 20:14:23 +0200 Subject: [PATCH 15/84] some fixes --- widgets/bat.lua | 1 - widgets/fs.lua | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index fa9f854..080c43f 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -70,7 +70,6 @@ local function worker(args) local sum_energy_full = 0 local sum_energy_percentage = 0 local pspath = "/sys/class/power_supply/" - -- local pspath = "/home/luke/Download/" for i, battery in ipairs(batteries) do local bstr = pspath .. battery diff --git a/widgets/fs.lua b/widgets/fs.lua index a1d5d95..6ec8dac 100644 --- a/widgets/fs.lua +++ b/widgets/fs.lua @@ -92,6 +92,7 @@ local function worker(args) fs_now.size_mb = tonumber(fs_info[partition .. " size_mb"]) or 0 fs_now.size_gb = tonumber(fs_info[partition .. " size_gb"]) or 0 + notification_preset = fs.notification_preset widget = fs.widget settings() From cda6ec98fe549f6a1bf87baeb9ac47e80411ffc7 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sat, 25 Jun 2016 14:05:05 +0200 Subject: [PATCH 16/84] battery: magnitude differences check added; closes #199 #203 --- widgets/bat.lua | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index 080c43f..f3ddd33 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -16,6 +16,7 @@ local wibox = require("wibox") local math = { floor = math.floor, min = math.min } local string = { format = string.format } local tonumber = tonumber +local tostring = tostring local setmetatable = setmetatable @@ -69,7 +70,8 @@ local function worker(args) local sum_energy_now = 0 local sum_energy_full = 0 local sum_energy_percentage = 0 - local pspath = "/sys/class/power_supply/" + --local pspath = "/sys/class/power_supply/" + local pspath = "/home/luke/Download/" for i, battery in ipairs(batteries) do local bstr = pspath .. battery @@ -109,25 +111,39 @@ local function worker(args) if bat_now.status ~= "N/A" then -- update {perc,time,watt} iff battery not full and rate > 0 if bat_now.status ~= "Full" and (sum_rate_current > 0 or sum_rate_power > 0) then - local rate_time = 0 - local sum_rpc = sum_rate_power or sum_rate_current - if sum_rpc >= 1e8 then sum_rpc = sum_rpc / 10 end + local sum_rpc = sum_rate_power or sum_rate_current + local enr = 0 + local m1 = tostring(sum_rpc):len() + local m2 = 0 if bat_now.status == "Charging" then - rate_time = (sum_energy_full - sum_energy_now) / sum_rpc - elseif bat_now.status == "Discharging" then - rate_time = sum_energy_now / sum_rpc + enr = sum_energy_full - sum_energy_now + m2 = tostring(sum_energy_full):len() + else -- Discharging + enr = sum_energy_now + m2 = tostring(enr):len() end - local hours = math.floor(rate_time) - local minutes = math.floor((rate_time - hours) * 60) - bat_now.perc = tonumber(string.format("%d", math.min(100, sum_energy_percentage / #batteries))) - bat_now.time = string.format("%02d:%02d", hours, minutes) - bat_now.watt = tonumber(string.format("%.2f", sum_rate_power / 1e6)) + -- solve magnitude differences, which may be caused + -- by file discrepancies + magnitude_diff = m1 - m2 + if magnitude_diff > 0 then + sum_rpc = sum_rpc / 10^magnitude_diff + elseif magnitude_diff < 0 then + enr = enr / 10^(magnitude_diff * -1) + end + + local rate_time = enr / sum_rpc + local hours = math.floor(rate_time) + local minutes = math.floor((rate_time - hours) * 60) + + bat_now.perc = tonumber(string.format("%d", math.min(100, sum_energy_percentage / #batteries))) + bat_now.time = string.format("%02d:%02d", hours, minutes) + bat_now.watt = tonumber(string.format("%.2f", sum_rate_power / 1e6)) elseif bat_now.status == "Full" then - bat_now.perc = 100 - bat_now.time = "00:00" - bat_now.watt = 0 + bat_now.perc = 100 + bat_now.time = "00:00" + bat_now.watt = 0 end end From 029039e81f6418e4ea9636a1e30604ea157173dc Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sat, 25 Jun 2016 14:07:43 +0200 Subject: [PATCH 17/84] battery: forgot to remove debugging line --- widgets/bat.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index f3ddd33..d429c71 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -70,8 +70,7 @@ local function worker(args) local sum_energy_now = 0 local sum_energy_full = 0 local sum_energy_percentage = 0 - --local pspath = "/sys/class/power_supply/" - local pspath = "/home/luke/Download/" + local pspath = "/sys/class/power_supply/" for i, battery in ipairs(batteries) do local bstr = pspath .. battery From 53b782f7c14871c6dd8c9d03fa14e45cedfd3298 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sat, 25 Jun 2016 14:27:20 +0200 Subject: [PATCH 18/84] gpmdp: some fixe + added wiki; #206 --- widgets/contrib/gpmdp.lua | 64 +++++++++++++++++---------------------- wiki | 2 +- 2 files changed, 28 insertions(+), 38 deletions(-) diff --git a/widgets/contrib/gpmdp.lua b/widgets/contrib/gpmdp.lua index 6b4341b..fa51440 100644 --- a/widgets/contrib/gpmdp.lua +++ b/widgets/contrib/gpmdp.lua @@ -1,20 +1,18 @@ --[[ - - Licensed under GNU General Public License v2 - * (c) 2016, Alexandre Terrien - + + Licensed under GNU General Public License v2 + * (c) 2016, Alexandre Terrien + --]] -local helpers = require("lain.helpers") -local json = require("lain.util.dkjson") - -local pread = require("awful.util").pread - -local naughty = require("naughty") -local wibox = require("wibox") - -local mouse = mouse +local helpers = require("lain.helpers") +local json = require("lain.util.dkjson") +local pread = require("awful.util").pread +local naughty = require("naughty") +local wibox = require("wibox") +local mouse = mouse +local os = { getenv = os.getenv } local setmetatable = setmetatable @@ -28,7 +26,7 @@ local function worker(args) local notify = args.notify or "off" local followmouse = args.followmouse or false local file_location = args.file_location or - os.getenv("HOME") .. "/.config/Google Play Music Desktop Player/json_store/playback.json" + os.getenv("HOME") .. "/.config/Google Play Music Desktop Player/json_store/playback.json" local settings = args.settings or function() end gpmdp.widget = wibox.widget.textbox('') @@ -38,48 +36,40 @@ local function worker(args) timeout = 6 } - helpers.set_map("gpmpd_current", nil) + helpers.set_map("gpmdp_current", nil) function gpmdp.update() file, err = io.open(file_location, "r") if not file then - gpm_now = { - running = false, - playing = false - } + gpm_now = { running = false, playing = false } else dict, pos, err = json.decode(file:read "*a", 1, nil) file:close() gpm_now = {} - gpm_now.artist = dict.song.artist - gpm_now.album = dict.song.album - gpm_now.title = dict.song.title - gpm_now.cover_url = dict.song.albumArt - gpm_now.playing = dict.playing + gpm_now.artist = dict.song.artist + gpm_now.album = dict.song.album + gpm_now.title = dict.song.title + gpm_now.cover_url = dict.song.albumArt + gpm_now.playing = dict.playing end + if (pread("pidof 'Google Play Music Desktop Player'") ~= '') then gpm_now.running = true else gpm_now.running = false end - gpmdp_notification_preset.text = string.format( - "%s (%s) - %s", - gpm_now.artist, - gpm_now.album, - gpm_now.title) + gpmdp_notification_preset.text = string.format("%s (%s) - %s", gpm_now.artist, gpm_now.album, gpm_now.title) widget = gpmdp.widget settings() if gpm_now.playing then - if notify == "on" and gpm_now.title ~= helpers.get_map("gpmpd_current") + if notify == "on" and gpm_now.title ~= helpers.get_map("gpmdp_current") then - helpers.set_map("gpmpd_current", gpm_now.title) - - current_icon = "/tmp/gpmcover.png" - os.execute("curl " .. gpm_now.cover_url .. " -o " .. current_icon) + helpers.set_map("gpmdp_current", gpm_now.title) + os.execute("curl " .. gpm_now.cover_url .. " -o /tmp/gpmcover.png") if followmouse then gpmdp_notification_preset.screen = mouse.screen @@ -87,13 +77,13 @@ local function worker(args) gpmdp.id = naughty.notify({ preset = gpmdp_notification_preset, - icon = current_icon, + icon = "/tmp/gpmcover.png", replaces_id = gpmdp.id, }).id end - elseif (not gpm_now.running) + elseif not gpm_now.running then - helpers.set_map("current mpd track", nil) + helpers.set_map("gpmdp_current", nil) end end diff --git a/wiki b/wiki index 060b182..c4e5537 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 060b1822e3a0bdcd59bcae2d047908b031310ea6 +Subproject commit c4e5537b9502894954c825fad4fd90d9abd3b29d From 4003d0963948f857fe53534b876ac9defe7e3fec Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sat, 25 Jun 2016 17:51:21 +0200 Subject: [PATCH 19/84] battery: magnitude check was 1 order off: fixed; #199 #207 --- widgets/bat.lua | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index d429c71..069fac8 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -13,11 +13,13 @@ local first_line = require("lain.helpers").first_line local naughty = require("naughty") local wibox = require("wibox") -local math = { floor = math.floor, min = math.min } +local math = { abs = math.abs, + floor = math.floor, + log10 = math.log10, + min = math.min } local string = { format = string.format } -local tonumber = tonumber -local tostring = tostring +local tonumber = tonumber local setmetatable = setmetatable -- Battery infos @@ -110,32 +112,21 @@ local function worker(args) if bat_now.status ~= "N/A" then -- update {perc,time,watt} iff battery not full and rate > 0 if bat_now.status ~= "Full" and (sum_rate_current > 0 or sum_rate_power > 0) then - local sum_rpc = sum_rate_power or sum_rate_current - local enr = 0 - local m1 = tostring(sum_rpc):len() - local m2 = 0 + local rate_time = 0 if bat_now.status == "Charging" then - enr = sum_energy_full - sum_energy_now - m2 = tostring(sum_energy_full):len() + rate_time = (sum_energy_full - sum_energy_now) / (sum_rate_power or sum_rate_current) else -- Discharging - enr = sum_energy_now - m2 = tostring(enr):len() + rate_time = sum_energy_now / (sum_rate_power or sum_rate_current) end - -- solve magnitude differences, which may be caused - -- by file discrepancies - magnitude_diff = m1 - m2 - if magnitude_diff > 0 then - sum_rpc = sum_rpc / 10^magnitude_diff - elseif magnitude_diff < 0 then - enr = enr / 10^(magnitude_diff * -1) + if rate_time < 0.01 then -- check for magnitude discrepancies + rate_time_magnitude = math.abs(math.floor(math.log10(rate_time))) + rate_time = rate_time * 10^(rate_time_magnitude - 2) end - local rate_time = enr / sum_rpc local hours = math.floor(rate_time) local minutes = math.floor((rate_time - hours) * 60) - bat_now.perc = tonumber(string.format("%d", math.min(100, sum_energy_percentage / #batteries))) bat_now.time = string.format("%02d:%02d", hours, minutes) bat_now.watt = tonumber(string.format("%.2f", sum_rate_power / 1e6)) From 0a6274b4343fa5b9ed9fb83ac72cbe9fc89610b0 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sun, 26 Jun 2016 12:32:38 +0200 Subject: [PATCH 20/84] wiki restructured; moved widgets/contrib/ccurr to abase/use case examples/bitcoin because Crypty API is dead and Coinbase API V1 -> V2 --- widgets/contrib/ccurr.lua | 82 --------------------------------------- wiki | 2 +- 2 files changed, 1 insertion(+), 83 deletions(-) delete mode 100644 widgets/contrib/ccurr.lua diff --git a/widgets/contrib/ccurr.lua b/widgets/contrib/ccurr.lua deleted file mode 100644 index 980e19b..0000000 --- a/widgets/contrib/ccurr.lua +++ /dev/null @@ -1,82 +0,0 @@ - ---[[ - - Licensed under GNU General Public License v2 - * (c) 2014, Aaron Lebo - ---]] - -local newtimer = require("lain.helpers").newtimer -local json = require("lain.util").dkjson - -local wibox = require("wibox") - -local string = { format = string.format } -local tonumber = tonumber - --- Crypto currencies widget --- lain.widgets.contrib.ccurr -local ccurr = {} - --- Currently gets --- * BTC/USD --- * DOGE/USD --- using Coinbase and Cryptsy APIs. - --- requires http://dkolf.de/src/dkjson-lua.fsl/home --- based upon http://awesome.naquadah.org/wiki/Bitcoin_Price_Widget - -local function get(url) - local f = io.popen('curl -m 5 -s "' .. url .. '"') - if not f then - return 0 - else - local s = f:read("*all") - f:close() - return s - end -end - -local function parse(j) - local obj, pos, err = json.decode(j, 1, nil) - if err then - return nil - else - return obj - end -end - -local function worker(args) - local args = args or {} - local timeout = args.timeout or 600 - local btc_url = args.btc_url or "https://coinbase.com/api/v1/prices/buy" - local doge_url = args.doge_url or "http://pubapi.cryptsy.com/api.php?method=singlemarketdata&marketid=132" - local settings = args.settings or function() end - - ccurr.widget = wibox.widget.textbox('') - - local function update() - price_now = { - btc = "N/A", - doge = "N/A" - } - - btc = parse(get(btc_url)) - doge = parse(get(doge_url)) - - if btc and doge then - price_now.btc = tonumber(btc["subtotal"]["amount"]) - price_now.doge = tonumber(doge["return"]["markets"]["DOGE"]["lasttradeprice"]) - price_now.doge = string.format("%.4f", price_now.btc * price_now.doge) - end - - widget = ccurr.widget - settings() - end - - newtimer("ccurr", timeout, update) - - return ccurr.widget -end - -return setmetatable(ccurr, { __call = function(_, ...) return worker(...) end }) diff --git a/wiki b/wiki index c4e5537..851d58d 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit c4e5537b9502894954c825fad4fd90d9abd3b29d +Subproject commit 851d58df3ac1ea7b06458809cdde0c8a64d8c266 From 606a995b90b682b0a9a88d55ecc675bb9ce39700 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sun, 26 Jun 2016 13:13:22 +0200 Subject: [PATCH 21/84] added quake --- util/quake.lua | 159 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 util/quake.lua diff --git a/util/quake.lua b/util/quake.lua new file mode 100644 index 0000000..9f703b0 --- /dev/null +++ b/util/quake.lua @@ -0,0 +1,159 @@ + +--[[ + + Licensed under GNU General Public License v2 + * (c) 2016, Luke Bonham + +--]] + +local awful = require("awful") +local capi = { client = client, + mouse = mouse, + screen = screen, + timer = timer } +local string = string + +local pairs = pairs +local setmetatable = setmetatable +local tostring = tostring + +-- Quake-like Dropdown application spawn +-- Original version: https://awesomewm.org/wiki/Drop-down_terminal#Another_solution +local quake = {} + +-- If you have a rule like "awful.client.setslave" for your terminals, +-- ensure you use an exception for QuakeDD. Otherwise, you may +-- run into problems with focus. + +function quake:display() + -- First, we locate the client + local client = nil + local i = 0 + for c in awful.client.iterate(function (c) + -- c.name may be changed! + return c.instance == self.name + end, nil, self.screen) + do + i = i + 1 + if i == 1 then + client = c + else + -- Additional matching clients, let's remove the sticky bit + -- which may persist between awesome restarts. We don't close + -- them as they may be valuable. They will just turn into + -- normal clients. + c.sticky = false + c.ontop = false + c.above = false + end + end + + if not client and not self.visible then return end + + if not client then + -- The client does not exist, we spawn it + awful.util.spawn(self.app .. " " .. string.format(self.argname, self.name), + false, self.screen) + return + end + + -- Resize + awful.client.floating.set(client, true) + client.border_width = 0 + client.size_hints_honor = false + client:geometry(self.geometry) + + -- Not sticky and on top + client.ontop = true + client.above = true + client.skip_taskbar = true + client.sticky = false + + -- This is not a normal window, don't apply any specific keyboard stuff + client:buttons({}) + client:keys({}) + + -- Toggle display + if self.visible then + client.hidden = false + client:raise() + self.last_tag = tostring(awful.tag.selected(self.screen)) + client:tags({awful.tag.selected(self.screen)}) + capi.client.focus = client + else + client.hidden = true + local ctags = client:tags() + for i, t in pairs(ctags) do + ctags[i] = nil + end + client:tags(ctags) + end + + return client +end + +function quake:new(config) + local conf = config or {} + + conf.app = conf.app or "xterm" -- application to spawn + conf.name = conf.name or "QuakeDD" -- window name + conf.argname = conf.argname or "-name %s" -- how to specify window name + conf.visible = conf.visible or false -- initially not visible + conf.screen = conf.screen or capi.mouse.screen + + -- If width or height <= 1 this is a proportion of the workspace + wibox_height = conf.wibox_height or 18 -- statusbar weight + height = conf.height or 0.25 -- height + width = conf.width or 1 -- width + vert = conf.vert or "top" -- top, bottom or center + horiz = conf.horiz or "center" -- left, right or center + + -- Compute size + local geom = capi.screen[conf.screen].workarea + if width <= 1 then width = geom.width * width end + if height <= 1 then height = geom.height * height end + local x, y + if horiz == "left" then x = geom.x + elseif horiz == "right" then x = geom.width + geom.x - width + else x = geom.x + (geom.width - width)/2 end + if vert == "top" then y = geom.y + elseif vert == "bottom" then y = geom.height + geom.y - height + else y = geom.y + (geom.height - height)/2 end + conf.geometry = { x = x, y = y + wibox_height, width = width, height = height } + + local console = setmetatable(conf, { __index = quake }) + capi.client.connect_signal("manage", function(c) + if c.instance == console.name and c.screen == console.screen then + console:display() + end + end) + capi.client.connect_signal("unmanage", function(c) + if c.instance == console.name and c.screen == console.screen then + console.visible = false + end + end) + + -- "Reattach" currently running quake application. This is in case awesome is restarted. + local reattach = capi.timer { timeout = 0 } + reattach:connect_signal("timeout", function() + reattach:stop() + console:display() + end) + reattach:start() + + return console +end + +function quake:toggle() + current_tag = awful.tag.selected(self.screen) + if self.last_tag ~= tostring(current_tag) and self.visible then + awful.client.movetotag(current_tag, self:display()) + else + self.visible = not self.visible + self:display() + end +end + +setmetatable(quake, { __call = function(_, ...) return quake:new(...) end }) + +return quake From 6f01d292de214bd81a6487cea4001a91a77fbc66 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sun, 26 Jun 2016 13:43:20 +0200 Subject: [PATCH 22/84] #207 fix attempt --- widgets/bat.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index 069fac8..62016d7 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -69,6 +69,7 @@ local function worker(args) local sum_rate_current = 0 local sum_rate_voltage = 0 local sum_rate_power = 0 + local sum_rate_energy = 0 local sum_energy_now = 0 local sum_energy_full = 0 local sum_energy_percentage = 0 @@ -99,7 +100,8 @@ local function worker(args) sum_rate_current = sum_rate_current + (rate_current or 0) sum_rate_voltage = sum_rate_voltage + rate_voltage - sum_rate_power = sum_rate_power + (rate_power or ((rate_voltage * rate_current) / 1e6)) + sum_rate_power = sum_rate_power + (rate_power or 0) + sum_rate_energy = sum_rate_energy + (rate_power or ((rate_voltage * rate_current) / 1e6)) sum_energy_now = sum_energy_now + (energy_now or 0) sum_energy_full = sum_energy_full + energy_full sum_energy_percentage = sum_energy_percentage + energy_percentage @@ -111,16 +113,17 @@ local function worker(args) if bat_now.status ~= "N/A" then -- update {perc,time,watt} iff battery not full and rate > 0 - if bat_now.status ~= "Full" and (sum_rate_current > 0 or sum_rate_power > 0) then + if bat_now.status ~= "Full" and (sum_rate_power > 0 or sum_rate_current > 0) then local rate_time = 0 + local div = (sum_rate_power > 0 and sum_rate_power) or sum_rate_current if bat_now.status == "Charging" then - rate_time = (sum_energy_full - sum_energy_now) / (sum_rate_power or sum_rate_current) + rate_time = (sum_energy_full - sum_energy_now) / div else -- Discharging - rate_time = sum_energy_now / (sum_rate_power or sum_rate_current) + rate_time = sum_energy_now / div end - if rate_time < 0.01 then -- check for magnitude discrepancies + if rate_time < 0.01 then -- check for magnitude discrepancies (#199) rate_time_magnitude = math.abs(math.floor(math.log10(rate_time))) rate_time = rate_time * 10^(rate_time_magnitude - 2) end @@ -129,7 +132,7 @@ local function worker(args) local minutes = math.floor((rate_time - hours) * 60) bat_now.perc = tonumber(string.format("%d", math.min(100, sum_energy_percentage / #batteries))) bat_now.time = string.format("%02d:%02d", hours, minutes) - bat_now.watt = tonumber(string.format("%.2f", sum_rate_power / 1e6)) + bat_now.watt = tonumber(string.format("%.2f", sum_rate_energy / 1e6)) elseif bat_now.status == "Full" then bat_now.perc = 100 bat_now.time = "00:00" From 92e72dcce4eb61b5bd945c197db88bcad4e15ad7 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sun, 26 Jun 2016 17:27:42 +0200 Subject: [PATCH 23/84] util/quake: this is a normal window --- util/quake.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/util/quake.lua b/util/quake.lua index 9f703b0..ab412ac 100644 --- a/util/quake.lua +++ b/util/quake.lua @@ -69,10 +69,6 @@ function quake:display() client.skip_taskbar = true client.sticky = false - -- This is not a normal window, don't apply any specific keyboard stuff - client:buttons({}) - client:keys({}) - -- Toggle display if self.visible then client.hidden = false From 86432aa3a2f8c6437ec47e5dd88b110612329e6e Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sun, 26 Jun 2016 20:08:34 +0200 Subject: [PATCH 24/84] battery: safety checks; #208 --- widgets/bat.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index 62016d7..e9ed928 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -99,12 +99,12 @@ local function worker(args) bat_now.n_status[i] = first_line(bstr .. "/status") or "N/A" sum_rate_current = sum_rate_current + (rate_current or 0) - sum_rate_voltage = sum_rate_voltage + rate_voltage + sum_rate_voltage = sum_rate_voltage + (rate_voltage or 0) sum_rate_power = sum_rate_power + (rate_power or 0) - sum_rate_energy = sum_rate_energy + (rate_power or ((rate_voltage * rate_current) / 1e6)) + sum_rate_energy = sum_rate_energy + (rate_power or (((rate_voltage or 0) * (rate_current or 0)) / 1e6)) sum_energy_now = sum_energy_now + (energy_now or 0) - sum_energy_full = sum_energy_full + energy_full - sum_energy_percentage = sum_energy_percentage + energy_percentage + sum_energy_full = sum_energy_full + (energy_full or 0) + sum_energy_percentage = sum_energy_percentage + (energy_percentage or 0) end end From 29ae2ec2d413e2f788712eac3df372b4a5534fe5 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Wed, 6 Jul 2016 10:33:23 +0200 Subject: [PATCH 25/84] bat: type checking on perc #209 --- widgets/bat.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index e9ed928..2da5e2d 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -19,6 +19,7 @@ local math = { abs = math.abs, min = math.min } local string = { format = string.format } +local type = type local tonumber = tonumber local setmetatable = setmetatable @@ -74,6 +75,7 @@ local function worker(args) local sum_energy_full = 0 local sum_energy_percentage = 0 local pspath = "/sys/class/power_supply/" + pspath = "/home/luke/Download/" for i, battery in ipairs(batteries) do local bstr = pspath .. battery @@ -144,7 +146,7 @@ local function worker(args) settings() -- notifications for low and critical states - if notify == "on" and bat_now.perc and bat_now.status == "Discharging" then + if notify == "on" and type(bat_now.perc) == "number" and bat_now.status == "Discharging" then if bat_now.perc <= 5 then bat.id = naughty.notify({ preset = bat_notification_critical_preset, From 41ccab3196c0051d7ce68e1e77ca97acf20db52d Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Wed, 6 Jul 2016 10:35:13 +0200 Subject: [PATCH 26/84] bat: forgot to remove debug line; #209 --- widgets/bat.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index 2da5e2d..91e826e 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -75,7 +75,6 @@ local function worker(args) local sum_energy_full = 0 local sum_energy_percentage = 0 local pspath = "/sys/class/power_supply/" - pspath = "/home/luke/Download/" for i, battery in ipairs(batteries) do local bstr = pspath .. battery From cbab9ef81befe8be7c3b518f270b7084407e6ceb Mon Sep 17 00:00:00 2001 From: Dmitry Sidorov Date: Thu, 7 Jul 2016 15:52:36 +0300 Subject: [PATCH 27/84] Battery remaining percentage must be int, not float --- widgets/bat.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index 91e826e..ec9a289 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -131,7 +131,7 @@ local function worker(args) local hours = math.floor(rate_time) local minutes = math.floor((rate_time - hours) * 60) - bat_now.perc = tonumber(string.format("%d", math.min(100, sum_energy_percentage / #batteries))) + bat_now.perc = tonumber(string.format("%d", math.floor(math.min(100, sum_energy_percentage / #batteries)))) bat_now.time = string.format("%02d:%02d", hours, minutes) bat_now.watt = tonumber(string.format("%.2f", sum_rate_energy / 1e6)) elseif bat_now.status == "Full" then From a221555ad4e384a907696a887c47380263230a69 Mon Sep 17 00:00:00 2001 From: Dmitry Sidorov Date: Fri, 8 Jul 2016 02:08:27 +0300 Subject: [PATCH 28/84] Bugfix. Data must be shown even there is no any packets sent or received. --- widgets/net.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/widgets/net.lua b/widgets/net.lua index ee2cfa7..1883168 100644 --- a/widgets/net.lua +++ b/widgets/net.lua @@ -128,12 +128,12 @@ local function worker(args) net_now.sent = string.gsub(string.format('%.1f', net_now.sent), ',', '.') net_now.received = string.gsub(string.format('%.1f', net_now.received), ',', '.') - widget = net.widget - settings() - net.last_t = total_t net.last_r = total_r end + + widget = net.widget + settings() end helpers.newtimer(iface, timeout, update) From fc3f86b5697211c0c1086cfe8af3518608cd3f60 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Fri, 8 Jul 2016 11:38:04 +0200 Subject: [PATCH 29/84] #211: wiki updated --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index 851d58d..eea2db6 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 851d58df3ac1ea7b06458809cdde0c8a64d8c266 +Subproject commit eea2db67ce65ddf68f4aae89741450f13efc3495 From dd4f40c48c32406f7d1dcb53fd7ec1879b6ffb8d Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sun, 10 Jul 2016 11:05:26 +0200 Subject: [PATCH 30/84] wiki & readme updated --- README.rst | 2 +- wiki | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index be3e377..87e11b5 100644 --- a/README.rst +++ b/README.rst @@ -43,5 +43,5 @@ Screenshots .. _GNU-GPL2: http://www.gnu.org/licenses/gpl-2.0.html .. _awesome-vain: https://github.com/vain/awesome-vain -.. _Awesome: http://awesome.naquadah.org/ +.. _Awesome: https://github.com/awesomeWM/awesome .. _wiki: https://github.com/copycat-killer/lain/wiki diff --git a/wiki b/wiki index eea2db6..52da2ca 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit eea2db67ce65ddf68f4aae89741450f13efc3495 +Subproject commit 52da2ca514814006be9762fa3ba4f225d555aad4 From d16094bc6811118f778e334a1bbf5fdafd966644 Mon Sep 17 00:00:00 2001 From: Roland Hieber Date: Thu, 14 Jul 2016 17:24:38 +0200 Subject: [PATCH 31/84] task widget: make command line configurable --- widgets/contrib/task.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/widgets/contrib/task.lua b/widgets/contrib/task.lua index 6f131e2..946966a 100644 --- a/widgets/contrib/task.lua +++ b/widgets/contrib/task.lua @@ -43,7 +43,7 @@ function task:show(scr_pos) local scrp = scr_pos or task.scr_pos end - f = io.popen('task') + f = io.popen('task ' .. task.cmdline) c_text = "" @@ -133,6 +133,7 @@ function task:attach(widget, args) task.timeout = args.timeout or 7 task.scr_pos = args.scr_pos or 1 task.followmouse = args.followmouse or false + task.cmdline = args.cmdline or "next" task.notify_icon = icons_dir .. "/taskwarrior/task.png" task.notify_icon_small = icons_dir .. "/taskwarrior/tasksmall.png" From 74bd2eb9918f86f18d4b61d4f34fb57bfc0c9e5a Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Fri, 15 Jul 2016 17:48:20 +0200 Subject: [PATCH 32/84] #213: wiki updated --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index 52da2ca..d67d0cd 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 52da2ca514814006be9762fa3ba4f225d555aad4 +Subproject commit d67d0cd36287fc1f8be8d0fcb3dd15e6025e5e8b From c909b67a6a12f159e1ed3cda53ea609b1b2798f2 Mon Sep 17 00:00:00 2001 From: Dmitry Sidorov Date: Sat, 16 Jul 2016 12:24:59 +0300 Subject: [PATCH 33/84] fs widget: make notification and popup configurable --- widgets/fs.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/widgets/fs.lua b/widgets/fs.lua index 6ec8dac..5215c86 100644 --- a/widgets/fs.lua +++ b/widgets/fs.lua @@ -58,6 +58,8 @@ local function worker(args) local args = args or {} local timeout = args.timeout or 600 local partition = args.partition or "/" + local showpopup = args.showpopup or "on" + local notify = args.notify or "on" local settings = args.settings or function() end fs.followmouse = args.followmouse or false @@ -96,7 +98,7 @@ local function worker(args) widget = fs.widget settings() - if fs_now.used >= 99 and not helpers.get_map(partition) + if notify == "on" and fs_now.used >= 99 and not helpers.get_map(partition) then naughty.notify({ title = "warning", @@ -111,8 +113,10 @@ local function worker(args) end end - fs.widget:connect_signal('mouse::enter', function () fs:show(0) end) - fs.widget:connect_signal('mouse::leave', function () fs:hide() 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) + end helpers.newtimer(partition, timeout, update) From ca11d6acbea616cefabaf376d8d38b9a364958f0 Mon Sep 17 00:00:00 2001 From: Dmitry Sidorov Date: Sun, 17 Jul 2016 11:24:00 +0300 Subject: [PATCH 34/84] tasks widget: Ability to specify font name --- widgets/contrib/task.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/widgets/contrib/task.lua b/widgets/contrib/task.lua index 946966a..f721548 100644 --- a/widgets/contrib/task.lua +++ b/widgets/contrib/task.lua @@ -25,6 +25,11 @@ local task = {} local task_notification = nil +function findLast(haystack, needle) + local i=haystack:match(".*"..needle.."()") + if i==nil then return nil else return i-1 end +end + function task:hide() if task_notification ~= nil then naughty.destroy(task_notification) @@ -125,8 +130,8 @@ function task:attach(widget, args) local args = args or {} task.font_size = tonumber(args.font_size) or 12 - task.font = beautiful.font:sub(beautiful.font:find(""), - beautiful.font:find(" ")) + task.font = args.font or beautiful.font:sub(beautiful.font:find(""), + findLast(beautiful.font, " ")) task.fg = args.fg or beautiful.fg_normal or "#FFFFFF" task.bg = args.bg or beautiful.bg_normal or "#FFFFFF" task.position = args.position or "top_right" From 233f424dfc4c106326f7875d4bdf1c17399c1608 Mon Sep 17 00:00:00 2001 From: Roland Hieber Date: Fri, 22 Jul 2016 06:51:30 +0200 Subject: [PATCH 35/84] task: proper XML escaping in notification --- widgets/contrib/task.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/widgets/contrib/task.lua b/widgets/contrib/task.lua index f721548..98817f9 100644 --- a/widgets/contrib/task.lua +++ b/widgets/contrib/task.lua @@ -52,7 +52,7 @@ function task:show(scr_pos) c_text = "" - .. f:read("*all"):gsub("\n*$", "") + .. awful.util.escape(f:read("*all"):gsub("\n*$", "")) .. "" f:close() @@ -75,7 +75,7 @@ function task:prompt_add() c_text = "\n" - .. f:read("*all") + .. awful.util.escape(f:read("*all")) .. "" f:close() @@ -107,7 +107,7 @@ function task:prompt_search() c_text = "" - .. c_text + .. awful.util.escape(c_text) .. "" end From ebd506d6932972388b4cb92ba7599667d52fc2a7 Mon Sep 17 00:00:00 2001 From: Roman Saldygashev Date: Mon, 25 Jul 2016 16:30:27 +0500 Subject: [PATCH 36/84] add used memory percentage --- widgets/mem.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/widgets/mem.lua b/widgets/mem.lua index f6213b2..3a6bdec 100644 --- a/widgets/mem.lua +++ b/widgets/mem.lua @@ -46,6 +46,7 @@ local function worker(args) mem_now.used = mem_now.total - (mem_now.free + mem_now.buf + mem_now.cache) mem_now.swapused = mem_now.swap - mem_now.swapf + mem_now.perc = math.floor(mem_now.used / mem_now.total * 100) widget = mem.widget settings() From 98d3ab90837d9200bdfba66013698fbc41072371 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Wed, 27 Jul 2016 11:40:41 +0200 Subject: [PATCH 37/84] #216: wiki updated --- widgets/mem.lua | 2 +- wiki | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/widgets/mem.lua b/widgets/mem.lua index 3a6bdec..99d91c7 100644 --- a/widgets/mem.lua +++ b/widgets/mem.lua @@ -46,7 +46,7 @@ local function worker(args) mem_now.used = mem_now.total - (mem_now.free + mem_now.buf + mem_now.cache) mem_now.swapused = mem_now.swap - mem_now.swapf - mem_now.perc = math.floor(mem_now.used / mem_now.total * 100) + mem_now.perc = math.floor(mem_now.used / mem_now.total * 100) widget = mem.widget settings() diff --git a/wiki b/wiki index d67d0cd..7689c02 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit d67d0cd36287fc1f8be8d0fcb3dd15e6025e5e8b +Subproject commit 7689c026b9b2a1a7d2582c48700aace3983b8711 From a366df30e00945b779e5ee4943de3992e07b430f Mon Sep 17 00:00:00 2001 From: Autumn Lansing Date: Thu, 28 Jul 2016 16:13:35 -0500 Subject: [PATCH 38/84] Fixed notification screen bug in task widget --- widgets/contrib/task.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/widgets/contrib/task.lua b/widgets/contrib/task.lua index 98817f9..27061b9 100644 --- a/widgets/contrib/task.lua +++ b/widgets/contrib/task.lua @@ -40,12 +40,12 @@ end function task:show(scr_pos) task:hide() - local f, c_text + local f, c_text, scrp if task.followmouse then - local scrp = mouse.screen + scrp = mouse.screen else - local scrp = scr_pos or task.scr_pos + scrp = scr_pos or task.scr_pos end f = io.popen('task ' .. task.cmdline) From 85ed92417dfca8fbdcfc89b7efb5308edd4d1193 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Wed, 3 Aug 2016 17:38:51 +0200 Subject: [PATCH 39/84] quake: set default geometry only on first spawn --- util/quake.lua | 15 ++++++++++----- widgets/contrib/redshift.lua | 9 ++++----- widgets/contrib/tpbat/smapi.lua | 1 - widgets/mem.lua | 12 ++++++------ widgets/mpd.lua | 12 ++++++------ widgets/pulseaudio.lua | 12 ++++++------ wiki | 2 +- 7 files changed, 33 insertions(+), 30 deletions(-) diff --git a/util/quake.lua b/util/quake.lua index ab412ac..5a55200 100644 --- a/util/quake.lua +++ b/util/quake.lua @@ -51,17 +51,22 @@ function quake:display() if not client and not self.visible then return end if not client then - -- The client does not exist, we spawn it - awful.util.spawn(self.app .. " " .. string.format(self.argname, self.name), - false, self.screen) - return + -- The client does not exist, we spawn it + awful.util.spawn(self.app .. " " .. string.format(self.argname, self.name), + false, self.screen) + self.exist = true + return end -- Resize awful.client.floating.set(client, true) client.border_width = 0 client.size_hints_honor = false - client:geometry(self.geometry) + if self.notexist then + -- set default geometry only on first spawn + client:geometry(self.geometry) + self.notexist = false + end -- Not sticky and on top client.ontop = true diff --git a/widgets/contrib/redshift.lua b/widgets/contrib/redshift.lua index 5ed9300..69247ee 100644 --- a/widgets/contrib/redshift.lua +++ b/widgets/contrib/redshift.lua @@ -16,11 +16,10 @@ local setmetatable = setmetatable -- lain.widgets.contrib.redshift local redshift = {} -local attached = false -- true if attached to a widget -local active = false -- true if redshift is active -local running = false -- true if redshift was initialized -local update_fnct = function() end -- Function that is run each time redshift is toggled. See redshift:attach(). - +local attached = false -- true if attached to a widget +local active = false -- true if redshift is active +local running = false -- true if redshift was initialized +local update_fnct = function() end -- Function that is run each time redshift is toggled. See redshift:attach(). local function init() -- As there is no way to determine if redshift was previously diff --git a/widgets/contrib/tpbat/smapi.lua b/widgets/contrib/tpbat/smapi.lua index c7f093e..271d9c2 100644 --- a/widgets/contrib/tpbat/smapi.lua +++ b/widgets/contrib/tpbat/smapi.lua @@ -16,7 +16,6 @@ local tonumber = tonumber local setmetatable = setmetatable local smapi = {} - local apipath = "/sys/devices/platform/smapi" -- Most are readable values, but some can be written to (not implemented, yet?) diff --git a/widgets/mem.lua b/widgets/mem.lua index 99d91c7..aede803 100644 --- a/widgets/mem.lua +++ b/widgets/mem.lua @@ -7,15 +7,15 @@ --]] -local newtimer = require("lain.helpers").newtimer +local newtimer = require("lain.helpers").newtimer -local wibox = require("wibox") +local wibox = require("wibox") -local io = { lines = io.lines } -local math = { floor = math.floor } -local string = { gmatch = string.gmatch } +local io = { lines = io.lines } +local math = { floor = math.floor } +local string = { gmatch = string.gmatch } -local setmetatable = setmetatable +local setmetatable = setmetatable -- Memory usage (ignoring caches) -- lain.widgets.mem diff --git a/widgets/mpd.lua b/widgets/mpd.lua index 6a327b0..8568764 100644 --- a/widgets/mpd.lua +++ b/widgets/mpd.lua @@ -14,13 +14,13 @@ local escape_f = require("awful.util").escape local naughty = require("naughty") local wibox = require("wibox") -local os = { execute = os.execute, - getenv = os.getenv } -local math = { floor = math.floor } +local os = { execute = os.execute, + getenv = os.getenv } +local math = { floor = math.floor } local mouse = mouse -local string = { format = string.format, - match = string.match, - gmatch = string.gmatch } +local string = { format = string.format, + match = string.match, + gmatch = string.gmatch } local setmetatable = setmetatable diff --git a/widgets/pulseaudio.lua b/widgets/pulseaudio.lua index 17fdb9c..c2686d8 100644 --- a/widgets/pulseaudio.lua +++ b/widgets/pulseaudio.lua @@ -6,14 +6,14 @@ --]] -local read_pipe = require("lain.helpers").read_pipe -local newtimer = require("lain.helpers").newtimer -local wibox = require("wibox") +local read_pipe = require("lain.helpers").read_pipe +local newtimer = require("lain.helpers").newtimer +local wibox = require("wibox") -local string = { match = string.match, - format = string.format } +local string = { match = string.match, + format = string.format } -local setmetatable = setmetatable +local setmetatable = setmetatable -- PulseAudio volume -- lain.widgets.pulseaudio diff --git a/wiki b/wiki index 7689c02..1a72051 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 7689c026b9b2a1a7d2582c48700aace3983b8711 +Subproject commit 1a72051053b009e74f7a50e5cff784829eda370c From dd19cbc77a15510b4bf9101feddf3b10968d9cf1 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Thu, 4 Aug 2016 12:34:22 +0200 Subject: [PATCH 40/84] quake: set default geometry only on first spawn; typo fixed --- util/quake.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/util/quake.lua b/util/quake.lua index 5a55200..000c618 100644 --- a/util/quake.lua +++ b/util/quake.lua @@ -54,7 +54,7 @@ function quake:display() -- The client does not exist, we spawn it awful.util.spawn(self.app .. " " .. string.format(self.argname, self.name), false, self.screen) - self.exist = true + self.notexist = true return end @@ -63,7 +63,6 @@ function quake:display() client.border_width = 0 client.size_hints_honor = false if self.notexist then - -- set default geometry only on first spawn client:geometry(self.geometry) self.notexist = false end From 417c3ce33b2d6ee58b88237fea0edc96c1af2013 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Thu, 4 Aug 2016 12:56:39 +0200 Subject: [PATCH 41/84] wiki updated --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index 1a72051..380e58f 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 1a72051053b009e74f7a50e5cff784829eda370c +Subproject commit 380e58f33a5a092cf36072458f7a2a4d1b07698e From 27ffe0084a62c37526b39ece9c574416ad67f972 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Fri, 5 Aug 2016 10:09:18 +0100 Subject: [PATCH 42/84] asyncshell: minor fix to spawn with shell invocation Fixed an erroneous call to "awful.spawn.with_shell" when "with_shell" is not defined. --- asyncshell.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asyncshell.lua b/asyncshell.lua index a8e3676..61336db 100644 --- a/asyncshell.lua +++ b/asyncshell.lua @@ -52,7 +52,7 @@ function asyncshell.request(command, callback, timeout) id, formatted_command ) - if type(awful.spawn) == 'table' then + if type(awful.spawn) == 'table' and awful.spawn.with_shell then awful.spawn.with_shell(req) else awful.util.spawn_with_shell(req) From 4eec21ad8e26c57c4992fcc01ab8539113166228 Mon Sep 17 00:00:00 2001 From: Sudo Nice Date: Wed, 10 Aug 2016 21:23:45 +0300 Subject: [PATCH 43/84] quake: allow to pass extra arguments --- util/quake.lua | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/util/quake.lua b/util/quake.lua index 000c618..0bd7148 100644 --- a/util/quake.lua +++ b/util/quake.lua @@ -31,7 +31,7 @@ function quake:display() local i = 0 for c in awful.client.iterate(function (c) -- c.name may be changed! - return c.instance == self.name + return c.instance == self.name end, nil, self.screen) do i = i + 1 @@ -52,8 +52,8 @@ function quake:display() if not client then -- The client does not exist, we spawn it - awful.util.spawn(self.app .. " " .. string.format(self.argname, self.name), - false, self.screen) + awful.util.spawn(self.app .. " " .. string.format(self.argname, self.name) .. + " " .. self.extra, false, self.screen) self.notexist = true return end @@ -95,17 +95,18 @@ end function quake:new(config) local conf = config or {} - conf.app = conf.app or "xterm" -- application to spawn - conf.name = conf.name or "QuakeDD" -- window name - conf.argname = conf.argname or "-name %s" -- how to specify window name - conf.visible = conf.visible or false -- initially not visible - conf.screen = conf.screen or capi.mouse.screen + conf.app = conf.app or "xterm" -- application to spawn + conf.name = conf.name or "QuakeDD" -- window name + conf.argname = conf.argname or "-name %s" -- how to specify window name + conf.extra = conf.extra or "" -- extra arguments + conf.visible = conf.visible or false -- initially not visible + conf.screen = conf.screen or capi.mouse.screen -- If width or height <= 1 this is a proportion of the workspace wibox_height = conf.wibox_height or 18 -- statusbar weight - height = conf.height or 0.25 -- height - width = conf.width or 1 -- width - vert = conf.vert or "top" -- top, bottom or center + height = conf.height or 0.25 -- height + width = conf.width or 1 -- width + vert = conf.vert or "top" -- top, bottom or center horiz = conf.horiz or "center" -- left, right or center -- Compute size @@ -125,19 +126,19 @@ function quake:new(config) capi.client.connect_signal("manage", function(c) if c.instance == console.name and c.screen == console.screen then console:display() - end + end end) capi.client.connect_signal("unmanage", function(c) if c.instance == console.name and c.screen == console.screen then console.visible = false - end - end) + end + end) -- "Reattach" currently running quake application. This is in case awesome is restarted. local reattach = capi.timer { timeout = 0 } reattach:connect_signal("timeout", function() reattach:stop() - console:display() + console:display() end) reattach:start() From 9dc19f882188cd649c46f88fa6f8434152f89254 Mon Sep 17 00:00:00 2001 From: Sudo Nice Date: Thu, 11 Aug 2016 09:53:02 +0300 Subject: [PATCH 44/84] quake: let border width be configurable --- util/quake.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/quake.lua b/util/quake.lua index 0bd7148..be9258c 100644 --- a/util/quake.lua +++ b/util/quake.lua @@ -60,7 +60,7 @@ function quake:display() -- Resize awful.client.floating.set(client, true) - client.border_width = 0 + client.border_width = self.border client.size_hints_honor = false if self.notexist then client:geometry(self.geometry) @@ -101,6 +101,7 @@ function quake:new(config) conf.extra = conf.extra or "" -- extra arguments conf.visible = conf.visible or false -- initially not visible conf.screen = conf.screen or capi.mouse.screen + conf.border = conf.border or 1 -- If width or height <= 1 this is a proportion of the workspace wibox_height = conf.wibox_height or 18 -- statusbar weight From a659d1a4bc99d27a1746985e13f68efc3dd256c7 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Thu, 11 Aug 2016 13:43:35 +0200 Subject: [PATCH 45/84] #221 use string.format; wiki updated --- helpers.lua | 2 +- util/quake.lua | 5 +++-- wiki | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/helpers.lua b/helpers.lua index 8fb794c..309162e 100644 --- a/helpers.lua +++ b/helpers.lua @@ -93,9 +93,9 @@ function helpers.newtimer(_name, timeout, fun, nostart) local name = timeout if not helpers.timer_table[name] then helpers.timer_table[name] = capi.timer({ timeout = timeout }) + helpers.timer_table[name]:start() end helpers.timer_table[name]:connect_signal("timeout", fun) - helpers.timer_table[name]:start() if not nostart then helpers.timer_table[name]:emit_signal("timeout") end diff --git a/util/quake.lua b/util/quake.lua index be9258c..771741e 100644 --- a/util/quake.lua +++ b/util/quake.lua @@ -52,8 +52,9 @@ function quake:display() if not client then -- The client does not exist, we spawn it - awful.util.spawn(self.app .. " " .. string.format(self.argname, self.name) .. - " " .. self.extra, false, self.screen) + awful.util.spawn(string.format("%s %s %s", self.app, + string.format(self.argname, self.name), self.extra), + false, self.screen) self.notexist = true return end diff --git a/wiki b/wiki index 380e58f..8d62fdf 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 380e58f33a5a092cf36072458f7a2a4d1b07698e +Subproject commit 8d62fdf794fe0d26802a7d0f7cf156e6b5b620f1 From 727997d5e0d9e699ea06959e2325e6a8ba27e6c6 Mon Sep 17 00:00:00 2001 From: Monokles Date: Mon, 15 Aug 2016 23:19:09 +0200 Subject: [PATCH 46/84] show true battery energy percentage --- widgets/bat.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index ec9a289..00d7183 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -131,7 +131,7 @@ local function worker(args) local hours = math.floor(rate_time) local minutes = math.floor((rate_time - hours) * 60) - bat_now.perc = tonumber(string.format("%d", math.floor(math.min(100, sum_energy_percentage / #batteries)))) + bat_now.perc = math.floor((sum_energy_now / sum_energy_full) * 100) bat_now.time = string.format("%02d:%02d", hours, minutes) bat_now.watt = tonumber(string.format("%.2f", sum_rate_energy / 1e6)) elseif bat_now.status == "Full" then From 0fd21874718daa76f4ffa0c3175397e04d2189b3 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Tue, 16 Aug 2016 12:31:50 +0200 Subject: [PATCH 47/84] #222 #223: readd math.min to catch #158 --- widgets/bat.lua | 2 +- wiki | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index 00d7183..43bb57f 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -131,7 +131,7 @@ local function worker(args) local hours = math.floor(rate_time) local minutes = math.floor((rate_time - hours) * 60) - bat_now.perc = math.floor((sum_energy_now / sum_energy_full) * 100) + bat_now.perc = math.floor(math.min(100, (sum_energy_now / sum_energy_full) * 100)) bat_now.time = string.format("%02d:%02d", hours, minutes) bat_now.watt = tonumber(string.format("%.2f", sum_rate_energy / 1e6)) elseif bat_now.status == "Full" then diff --git a/wiki b/wiki index 8d62fdf..427a9d6 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 8d62fdf794fe0d26802a7d0f7cf156e6b5b620f1 +Subproject commit 427a9d6acbf3b67ce7d61bb2313ff7a983a658b3 From ed8853a301813394e776c96ee4a276e2420dc593 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Tue, 16 Aug 2016 12:39:17 +0200 Subject: [PATCH 48/84] #222 #223: percentage shown for every battery --- widgets/bat.lua | 52 ++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index 43bb57f..e633e50 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -64,17 +64,17 @@ local function worker(args) bat_now.n_status = {} for i = 1, #batteries do bat_now.n_status[i] = "N/A" + bat_now.perc[i] = 0 end function update() - local sum_rate_current = 0 - local sum_rate_voltage = 0 - local sum_rate_power = 0 - local sum_rate_energy = 0 - local sum_energy_now = 0 - local sum_energy_full = 0 - local sum_energy_percentage = 0 - local pspath = "/sys/class/power_supply/" + local sum_rate_current = 0 + local sum_rate_voltage = 0 + local sum_rate_power = 0 + local sum_rate_energy = 0 + local sum_energy_now = 0 + local sum_energy_full = 0 + local pspath = "/sys/class/power_supply/" for i, battery in ipairs(batteries) do local bstr = pspath .. battery @@ -82,9 +82,9 @@ local function worker(args) if tonumber(present) == 1 then -- current_now(I)[uA], voltage_now(U)[uV], power_now(P)[uW] - local rate_current = tonumber(first_line(bstr .. "/current_now")) - local rate_voltage = tonumber(first_line(bstr .. "/voltage_now")) - local rate_power = tonumber(first_line(bstr .. "/power_now")) + local rate_current = tonumber(first_line(bstr .. "/current_now")) + local rate_voltage = tonumber(first_line(bstr .. "/voltage_now")) + local rate_power = tonumber(first_line(bstr .. "/power_now")) -- energy_now(P)[uWh], charge_now(I)[uAh] local energy_now = tonumber(first_line(bstr .. "/energy_now") or @@ -98,14 +98,14 @@ local function worker(args) math.floor((energy_now / energy_full) * 100) bat_now.n_status[i] = first_line(bstr .. "/status") or "N/A" + bat_now.perc[i] = energy_percentage or bat_now.perc[i] - sum_rate_current = sum_rate_current + (rate_current or 0) - sum_rate_voltage = sum_rate_voltage + (rate_voltage or 0) - sum_rate_power = sum_rate_power + (rate_power or 0) - sum_rate_energy = sum_rate_energy + (rate_power or (((rate_voltage or 0) * (rate_current or 0)) / 1e6)) - sum_energy_now = sum_energy_now + (energy_now or 0) - sum_energy_full = sum_energy_full + (energy_full or 0) - sum_energy_percentage = sum_energy_percentage + (energy_percentage or 0) + sum_rate_current = sum_rate_current + (rate_current or 0) + sum_rate_voltage = sum_rate_voltage + (rate_voltage or 0) + sum_rate_power = sum_rate_power + (rate_power or 0) + sum_rate_energy = sum_rate_energy + (rate_power or (((rate_voltage or 0) * (rate_current or 0)) / 1e6)) + sum_energy_now = sum_energy_now + (energy_now or 0) + sum_energy_full = sum_energy_full + (energy_full or 0) end end @@ -129,15 +129,15 @@ local function worker(args) rate_time = rate_time * 10^(rate_time_magnitude - 2) end - local hours = math.floor(rate_time) - local minutes = math.floor((rate_time - hours) * 60) - bat_now.perc = math.floor(math.min(100, (sum_energy_now / sum_energy_full) * 100)) - bat_now.time = string.format("%02d:%02d", hours, minutes) - bat_now.watt = tonumber(string.format("%.2f", sum_rate_energy / 1e6)) + local hours = math.floor(rate_time) + local minutes = math.floor((rate_time - hours) * 60) + bat_now.perc = math.floor(math.min(100, (sum_energy_now / sum_energy_full) * 100)) + bat_now.time = string.format("%02d:%02d", hours, minutes) + bat_now.watt = tonumber(string.format("%.2f", sum_rate_energy / 1e6)) elseif bat_now.status == "Full" then - bat_now.perc = 100 - bat_now.time = "00:00" - bat_now.watt = 0 + bat_now.perc = 100 + bat_now.time = "00:00" + bat_now.watt = 0 end end From 1eb2829cace5dbb35b7b9d5eb0df838296f21589 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Tue, 16 Aug 2016 12:40:51 +0200 Subject: [PATCH 49/84] #222 #223: percentage shown for every battery; fix typo --- widgets/bat.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index e633e50..54959eb 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -64,7 +64,7 @@ local function worker(args) bat_now.n_status = {} for i = 1, #batteries do bat_now.n_status[i] = "N/A" - bat_now.perc[i] = 0 + bat_now.n_perc[i] = 0 end function update() From f0deb3749f0188c31ac91f3308e8925275dcb290 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Tue, 16 Aug 2016 12:43:04 +0200 Subject: [PATCH 50/84] #222 #223: percentage shown for every battery; fix typo 2 --- widgets/bat.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index 54959eb..e43875f 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -98,7 +98,7 @@ local function worker(args) math.floor((energy_now / energy_full) * 100) bat_now.n_status[i] = first_line(bstr .. "/status") or "N/A" - bat_now.perc[i] = energy_percentage or bat_now.perc[i] + bat_now.n_perc[i] = energy_percentage or bat_now.n_perc[i] sum_rate_current = sum_rate_current + (rate_current or 0) sum_rate_voltage = sum_rate_voltage + (rate_voltage or 0) From 806182a0e80095c096ce1f59f6f6fa9c68e95448 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Tue, 16 Aug 2016 12:44:59 +0200 Subject: [PATCH 51/84] wiki updated; completes #223; closes #222 --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index 427a9d6..1bfbcb9 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 427a9d6acbf3b67ce7d61bb2313ff7a983a658b3 +Subproject commit 1bfbcb9581fb4f335b44a05e608dd759ea7552e1 From 10cb9a91278976aa2506f0cdd73376a6ce0da510 Mon Sep 17 00:00:00 2001 From: ikselven Date: Wed, 17 Aug 2016 13:52:47 +0200 Subject: [PATCH 52/84] fix: attempt to index a nil value (field 'n_perc') --- widgets/bat.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/widgets/bat.lua b/widgets/bat.lua index e43875f..9ab0cdc 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -62,6 +62,7 @@ local function worker(args) } bat_now.n_status = {} + bat_now.n_perc = {} for i = 1, #batteries do bat_now.n_status[i] = "N/A" bat_now.n_perc[i] = 0 From 0e37d220b793edbefb7064315cb7274fe5282862 Mon Sep 17 00:00:00 2001 From: Luke Bonham Date: Wed, 24 Aug 2016 17:14:06 +0200 Subject: [PATCH 53/84] #162 comment 241640965: fix magnitude check when 100% on AC --- widgets/bat.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index 9ab0cdc..d84a5d8 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -125,7 +125,7 @@ local function worker(args) rate_time = sum_energy_now / div end - if rate_time < 0.01 then -- check for magnitude discrepancies (#199) + if 0 < rate_time and rate_time < 0.01 then -- check for magnitude discrepancies (#199) rate_time_magnitude = math.abs(math.floor(math.log10(rate_time))) rate_time = rate_time * 10^(rate_time_magnitude - 2) end From 19b510cfc4ab3843f974aa494c58a477bb8ce508 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sun, 28 Aug 2016 13:57:58 +0200 Subject: [PATCH 54/84] alsa{bar}: togglechannel added (HDMI outputs) --- widgets/alsa.lua | 12 +++++++++--- widgets/alsabar.lua | 8 +++++++- wiki | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/widgets/alsa.lua b/widgets/alsa.lua index d85a080..7500097 100644 --- a/widgets/alsa.lua +++ b/widgets/alsa.lua @@ -26,14 +26,20 @@ local function worker(args) local timeout = args.timeout or 5 local settings = args.settings or function() end - alsa.cmd = args.cmd or "amixer" - alsa.channel = args.channel or "Master" - alsa.widget = wibox.widget.textbox('') + alsa.cmd = args.cmd or "amixer" + alsa.channel = args.channel or "Master" + alsa.togglechannel = args.togglechannel + alsa.widget = wibox.widget.textbox('') function alsa.update() mixer = read_pipe(string.format("%s get %s", alsa.cmd, alsa.channel)) l,s = string.match(mixer, "([%d]+)%%.*%[([%l]*)") + -- HDMIs can have a channel different from Master for toggling mute + if alsa.togglechannel then + s = string.match(read_pipe(string.format("%s get %s", alsa.cmd, alsa.togglechannel)), "%[(%a+)%]") + end + if alsa.last_level ~= l or alsa.last_status ~= s then volume_now = { level = l, status = s } alsa.last_level = l diff --git a/widgets/alsabar.lua b/widgets/alsabar.lua index 39bf394..b7c66b7 100644 --- a/widgets/alsabar.lua +++ b/widgets/alsabar.lua @@ -27,7 +27,7 @@ local setmetatable = setmetatable -- lain.widgets.alsabar local alsabar = { channel = "Master", - step = "2%", + step = "1%", colors = { background = beautiful.bg_normal, @@ -104,6 +104,7 @@ local function worker(args) alsabar.cmd = args.cmd or "amixer" alsabar.channel = args.channel or alsabar.channel + alsabar.togglechannel = args.togglechannel alsabar.step = args.step or alsabar.step alsabar.colors = args.colors or alsabar.colors alsabar.notifications = args.notifications or alsabar.notifications @@ -127,6 +128,11 @@ local function worker(args) -- Capture mixer control state: [5%] ... ... [on] local volu, mute = string.match(mixer, "([%d]+)%%.*%[([%l]*)") + -- HDMIs can have a channel different from Master for toggling mute + if alsabar.togglechannel then + mute = string.match(read_pipe(string.format("%s get %s", alsabar.cmd, alsabar.togglechannel)), "%[(%a+)%]") + end + if (volu and tonumber(volu) ~= alsabar._current_level) or (mute and string.match(mute, "on") ~= alsabar._muted) then alsabar._current_level = tonumber(volu) diff --git a/wiki b/wiki index 1bfbcb9..0612d01 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 1bfbcb9581fb4f335b44a05e608dd759ea7552e1 +Subproject commit 0612d0161aa8ea65ddeba84ca47bf5a60777fe46 From f47454f25adfb162172cf78bfc21ed276136cef6 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sun, 28 Aug 2016 13:58:18 +0200 Subject: [PATCH 55/84] wiki updated --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index 0612d01..450c0bb 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 0612d0161aa8ea65ddeba84ca47bf5a60777fe46 +Subproject commit 450c0bbf52d9ff9c3f13b634ff666dd352784498 From 2edf1241febe9ea7011892955fbdd444fc03f664 Mon Sep 17 00:00:00 2001 From: Kobe Lipkens Date: Sat, 3 Sep 2016 16:44:48 +0200 Subject: [PATCH 56/84] widget.base: Fix cached output --- widgets/base.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widgets/base.lua b/widgets/base.lua index e1ce297..cd84e36 100644 --- a/widgets/base.lua +++ b/widgets/base.lua @@ -26,8 +26,8 @@ local function worker(args) base.widget = wibox.widget.textbox('') function base.update() + output = read_pipe(cmd) if output ~= base.prev then - output = read_pipe(cmd) widget = base.widget settings() base.prev = output From 7e6f1336f26e8c36a1768ae1f7f076a30030a8a8 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Tue, 13 Sep 2016 16:29:17 +0200 Subject: [PATCH 57/84] net: specify ip path; #102 --- helpers.lua | 5 +++-- widgets/net.lua | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/helpers.lua b/helpers.lua index 309162e..b681cb0 100644 --- a/helpers.lua +++ b/helpers.lua @@ -8,6 +8,7 @@ local debug = require("debug") +local assert = assert local capi = { timer = (type(timer) == 'table' and timer or require ("gears.timer")) } local io = { open = io.open, lines = io.lines, @@ -61,9 +62,9 @@ end function helpers.lines_match(regexp, file) local lines = {} for index,line in pairs(helpers.lines_from(file)) do - if string.match(line, regexp) then + if string.match(line, regexp) then lines[index] = line - end + end end return lines end diff --git a/widgets/net.lua b/widgets/net.lua index 1883168..4dbacf5 100644 --- a/widgets/net.lua +++ b/widgets/net.lua @@ -24,7 +24,7 @@ local function worker(args) local net = { last_t = 0, last_r = 0, devices = {} } function net.get_first_device() - local ws = helpers.read_pipe("ip link show | cut -d' ' -f2,9") + local ws = helpers.read_pipe("/usr/sbin/ip link show | cut -d' ' -f2,9") ws = ws:match("%w+: UP") or ws:match("ppp%w+: UNKNOWN") if ws then return { ws:match("(%w+):") } else return {} end From ad4066caed02d9da2f3ec74a4648b96d3a7c3fa2 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Tue, 13 Sep 2016 21:58:19 +0200 Subject: [PATCH 58/84] net: ip: revert to default path; wiki updated; #102 --- widgets/net.lua | 2 +- wiki | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/widgets/net.lua b/widgets/net.lua index 4dbacf5..1883168 100644 --- a/widgets/net.lua +++ b/widgets/net.lua @@ -24,7 +24,7 @@ local function worker(args) local net = { last_t = 0, last_r = 0, devices = {} } function net.get_first_device() - local ws = helpers.read_pipe("/usr/sbin/ip link show | cut -d' ' -f2,9") + local ws = helpers.read_pipe("ip link show | cut -d' ' -f2,9") ws = ws:match("%w+: UP") or ws:match("ppp%w+: UNKNOWN") if ws then return { ws:match("(%w+):") } else return {} end diff --git a/wiki b/wiki index 450c0bb..4521f12 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 450c0bbf52d9ff9c3f13b634ff666dd352784498 +Subproject commit 4521f127d306b74538d7cde445796978aa1853cf From 366ba0c1b75a14e3740a4fe956dd5e0225a00fda Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Thu, 29 Sep 2016 10:48:27 +0200 Subject: [PATCH 59/84] alsabar: failsafe for ALSA configs not starting from init --- widgets/alsabar.lua | 2 +- wiki | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/widgets/alsabar.lua b/widgets/alsabar.lua index b7c66b7..eec3428 100644 --- a/widgets/alsabar.lua +++ b/widgets/alsabar.lua @@ -135,7 +135,7 @@ local function worker(args) if (volu and tonumber(volu) ~= alsabar._current_level) or (mute and string.match(mute, "on") ~= alsabar._muted) then - alsabar._current_level = tonumber(volu) + alsabar._current_level = tonumber(volu) or alsabar._current_level alsabar.bar:set_value(alsabar._current_level / 100) if not mute and tonumber(volu) == 0 or mute == "off" then diff --git a/wiki b/wiki index 450c0bb..4521f12 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 450c0bbf52d9ff9c3f13b634ff666dd352784498 +Subproject commit 4521f127d306b74538d7cde445796978aa1853cf From 4173f5bec3008deb306191fe7049e78e77763e5e Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Tue, 4 Oct 2016 11:02:43 +0200 Subject: [PATCH 60/84] bat: catch AC and discharging case; #199 comment 251025564 --- widgets/bat.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/widgets/bat.lua b/widgets/bat.lua index d84a5d8..991885a 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -135,6 +135,10 @@ local function worker(args) bat_now.perc = math.floor(math.min(100, (sum_energy_now / sum_energy_full) * 100)) bat_now.time = string.format("%02d:%02d", hours, minutes) bat_now.watt = tonumber(string.format("%.2f", sum_rate_energy / 1e6)) + elseif bat_now.status ~= "Full" and sum_rate_power == 0 and bat_now.ac_status == 1 then + bat_now.perc = math.floor(math.min(100, (sum_energy_now / sum_energy_full) * 100)) + bat_now.time = "00:00" + bat_now.watt = 0 elseif bat_now.status == "Full" then bat_now.perc = 100 bat_now.time = "00:00" From a566b721b960bdb75eb02d801639bf3282b2e271 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Wed, 12 Oct 2016 19:14:48 +0200 Subject: [PATCH 61/84] weather: weather_now check if table and not just nil --- widgets/weather.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/widgets/weather.lua b/widgets/weather.lua index d2ed300..545e6d1 100644 --- a/widgets/weather.lua +++ b/widgets/weather.lua @@ -108,7 +108,7 @@ local function worker(args) local pos, err weather_now, pos, err = json.decode(f, 1, nil) - if not err and weather_now and tonumber(weather_now["cod"]) == 200 then + if not err and type(weather_now) == "table" and tonumber(weather_now["cod"]) == 200 then weather.notification_text = '' for i = 1, weather_now["cnt"] do weather.notification_text = weather.notification_text .. @@ -128,7 +128,7 @@ local function worker(args) local pos, err, icon weather_now, pos, err = json.decode(f, 1, nil) - if not err and weather_now and tonumber(weather_now["cod"]) == 200 then + if not err and type(weather_now) == "table" and tonumber(weather_now["cod"]) == 200 then -- weather icon based on localtime local now = os.time() local sunrise = tonumber(weather_now["sys"]["sunrise"]) From fa9fb11a7c3eeb186a17c6d93c5da37eb6929d58 Mon Sep 17 00:00:00 2001 From: aajjbb Date: Sat, 22 Oct 2016 14:52:56 -0200 Subject: [PATCH 62/84] adding .rockspec file to generate a luarocks rock --- lain.rockspec | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 lain.rockspec diff --git a/lain.rockspec b/lain.rockspec new file mode 100644 index 0000000..9d5d5e2 --- /dev/null +++ b/lain.rockspec @@ -0,0 +1,22 @@ +package = "lain" +version = "1.0.0" +source = { + url = "https://github.com/copycat-killer/lain", + tag = "v.1.0.0" +} +description = { + summary = "A layoutm widget and utilities library for the Awesome Window Manager", + detailed = [[ + Successor of awesome-vain, this module provides new layouts, a set of widgets and utility functions, in order to improve Awesome usability and configurability. + ]], + homepage = "https://github.com/copycat-killer/lain", + license = "GPL v2" +} +dependencies = { + "lua >= 5.1" +} +supported_platforms = { "linux" } +build = { + type = "builtin", + modules = { lain = "init.lua" }, +} From 37e0169933aae37d661add99e13752ee70448d35 Mon Sep 17 00:00:00 2001 From: aajjbb Date: Sat, 22 Oct 2016 16:36:37 -0200 Subject: [PATCH 63/84] added awesome as dependency and changed version to git --- lain.rockspec | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lain.rockspec b/lain.rockspec index 9d5d5e2..97a2858 100644 --- a/lain.rockspec +++ b/lain.rockspec @@ -1,8 +1,8 @@ package = "lain" -version = "1.0.0" +version = "git" source = { url = "https://github.com/copycat-killer/lain", - tag = "v.1.0.0" + tag = "git" } description = { summary = "A layoutm widget and utilities library for the Awesome Window Manager", @@ -13,7 +13,8 @@ description = { license = "GPL v2" } dependencies = { - "lua >= 5.1" + "lua >= 5.1", + "awesome >= 3.5" } supported_platforms = { "linux" } build = { From c62c4d7816ebf0d99b2edda9e0df252699549f8f Mon Sep 17 00:00:00 2001 From: aajjbb Date: Sat, 22 Oct 2016 16:37:50 -0200 Subject: [PATCH 64/84] added optional optional dependencies in the detailed description --- lain.rockspec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lain.rockspec b/lain.rockspec index 97a2858..8c31764 100644 --- a/lain.rockspec +++ b/lain.rockspec @@ -8,6 +8,8 @@ description = { summary = "A layoutm widget and utilities library for the Awesome Window Manager", detailed = [[ Successor of awesome-vain, this module provides new layouts, a set of widgets and utility functions, in order to improve Awesome usability and configurability. + + Optional dependencies: alsa-utils, curl, imagemagick ]], homepage = "https://github.com/copycat-killer/lain", license = "GPL v2" From 1793f94b00c04639e97bad43b50bbc111a8f393d Mon Sep 17 00:00:00 2001 From: aajjbb Date: Sat, 22 Oct 2016 19:08:48 -0200 Subject: [PATCH 65/84] renaming rockspec file and adding optional dependencies as regular dependencies --- lain.rockspec => lain-git.rockspec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) rename lain.rockspec => lain-git.rockspec (91%) diff --git a/lain.rockspec b/lain-git.rockspec similarity index 91% rename from lain.rockspec rename to lain-git.rockspec index 8c31764..90c16d5 100644 --- a/lain.rockspec +++ b/lain-git.rockspec @@ -16,7 +16,10 @@ description = { } dependencies = { "lua >= 5.1", - "awesome >= 3.5" + "awesome >= 3.5", + "alsa-utils", + "curl", + "imagemagick" } supported_platforms = { "linux" } build = { From ebefc1e21d71c4b53e27e142cd199f3ec600da9c Mon Sep 17 00:00:00 2001 From: aajjbb Date: Sat, 22 Oct 2016 20:13:10 -0200 Subject: [PATCH 66/84] fixing typos --- lain-git.rockspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lain-git.rockspec b/lain-git.rockspec index 90c16d5..51f399e 100644 --- a/lain-git.rockspec +++ b/lain-git.rockspec @@ -5,7 +5,7 @@ source = { tag = "git" } description = { - summary = "A layoutm widget and utilities library for the Awesome Window Manager", + summary = "Layout, Widget and Utilities library for the Awesome Window Manager", detailed = [[ Successor of awesome-vain, this module provides new layouts, a set of widgets and utility functions, in order to improve Awesome usability and configurability. From 75df71f9a10b26522ff1b9e698f9f0b4ee56abef Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sun, 23 Oct 2016 10:26:21 +0200 Subject: [PATCH 67/84] rockspec: description like readme; closes #231 --- lain-git.rockspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lain-git.rockspec b/lain-git.rockspec index 51f399e..04dfe34 100644 --- a/lain-git.rockspec +++ b/lain-git.rockspec @@ -5,11 +5,11 @@ source = { tag = "git" } description = { - summary = "Layout, Widget and Utilities library for the Awesome Window Manager", + summary = "Layout, widgets and utilities for Awesome WM", detailed = [[ Successor of awesome-vain, this module provides new layouts, a set of widgets and utility functions, in order to improve Awesome usability and configurability. - Optional dependencies: alsa-utils, curl, imagemagick + Optional dependencies: alsa-utils (for alsamixer); curl; imagemagick. ]], homepage = "https://github.com/copycat-killer/lain", license = "GPL v2" From 2429e10cc1029d9ea7269d502bdbcc408c5a2894 Mon Sep 17 00:00:00 2001 From: Luke Bonham Date: Mon, 24 Oct 2016 10:58:47 +0200 Subject: [PATCH 68/84] Create LICENSE --- LICENSE | 339 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 339 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..23cb790 --- /dev/null +++ b/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. From 79687bad24e8b782fca0e4270e282a10f3bd56c3 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Thu, 27 Oct 2016 21:21:21 +0200 Subject: [PATCH 69/84] pulseaudio: add sink index, and fetch every channel; #234 --- widgets/pulseaudio.lua | 18 ++++++++++++++---- wiki | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/widgets/pulseaudio.lua b/widgets/pulseaudio.lua index c2686d8..4bda3c5 100644 --- a/widgets/pulseaudio.lua +++ b/widgets/pulseaudio.lua @@ -10,7 +10,8 @@ local read_pipe = require("lain.helpers").read_pipe local newtimer = require("lain.helpers").newtimer local wibox = require("wibox") -local string = { match = string.match, +local string = { gmatch = string.gmatch, + match = string.match, format = string.format } local setmetatable = setmetatable @@ -33,9 +34,18 @@ local function worker(args) local s = read_pipe(pulseaudio.cmd) volume_now = {} - volume_now.left = tonumber(string.match(s, ":.-(%d+)%%")) - volume_now.right = tonumber(string.match(s, ":.-(%d+)%%")) - volume_now.muted = string.match(s, "muted: (%S+)") + volume.now.index = string.match(s, "index: (%S+)") or "N/A" + volume_now.muted = string.match(s, "muted: (%S+)") or "N/A" + + local ch = 1 + volume_now.channel = {} + for v in string.gmatch(s, ":.-(%d+)%%") do + volume_now.channel[ch] = v + ch = ch + 1 + end + + volume_now.left = volume_now.channel[1] or "N/A" + volume_now.right = volume_now.channel[2] or "N/A" widget = pulseaudio.widget settings() diff --git a/wiki b/wiki index 4521f12..3f72c72 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 4521f127d306b74538d7cde445796978aa1853cf +Subproject commit 3f72c72c7e6e75e653869a5c354562bd0b1adf09 From 89390541d37002cb4ff99f19e48cefa986e6e17b Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Thu, 27 Oct 2016 21:24:00 +0200 Subject: [PATCH 70/84] wiki updated; #234 --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index 3f72c72..6a71e96 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 3f72c72c7e6e75e653869a5c354562bd0b1adf09 +Subproject commit 6a71e967c618af4d6e9892effd33d93832c65f20 From 42424334b26f3d8cea288663f67393545d27bafe Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Fri, 28 Oct 2016 13:44:47 +0200 Subject: [PATCH 71/84] pulseaudio: added sink name; fixed typo; #234 --- widgets/pulseaudio.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/widgets/pulseaudio.lua b/widgets/pulseaudio.lua index 4bda3c5..15bea8b 100644 --- a/widgets/pulseaudio.lua +++ b/widgets/pulseaudio.lua @@ -26,7 +26,7 @@ local function worker(args) local settings = args.settings or function() end local scallback = args.scallback - pulseaudio.cmd = args.cmd or string.format("pacmd list-sinks | sed -n -e '0,/*/d' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p'") + pulseaudio.cmd = args.cmd or string.format("pacmd list-sinks | sed -n -e '0,/*/d' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p' -e '/device\\.string/p'") pulseaudio.widget = wibox.widget.textbox('') function pulseaudio.update() @@ -34,7 +34,8 @@ local function worker(args) local s = read_pipe(pulseaudio.cmd) volume_now = {} - volume.now.index = string.match(s, "index: (%S+)") or "N/A" + volume_now.index = string.match(s, "index: (%S+)") or "N/A" + volume_now.sink = string.match(s, "device.string = \"(%S+)\"") or "N/A" volume_now.muted = string.match(s, "muted: (%S+)") or "N/A" local ch = 1 From 0727ed40e37f8b4ea10fa0a976dcd31e13eea443 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Fri, 28 Oct 2016 14:03:05 +0200 Subject: [PATCH 72/84] wiki updated; #234 --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index 6a71e96..ecd1b96 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 6a71e967c618af4d6e9892effd33d93832c65f20 +Subproject commit ecd1b96ca46ea4ca66e36acb62156ebe979e639d From 98bb2dc5ef25ce2b2ad330bca7e78d77125e7c72 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sun, 6 Nov 2016 12:18:34 +0100 Subject: [PATCH 73/84] wiki updated --- helpers.lua | 13 ++++++++++++- wiki | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/helpers.lua b/helpers.lua index b681cb0..6c0c3c4 100644 --- a/helpers.lua +++ b/helpers.lua @@ -106,7 +106,7 @@ end -- {{{ Pipe operations --- read the full output of a pipe (command) +-- read the full output of a command output function helpers.read_pipe(cmd) local f = assert(io.popen(cmd)) local output = f:read("*all") @@ -114,6 +114,16 @@ function helpers.read_pipe(cmd) return output end +-- return line iterator of a command output +function helpers.pipelines(...) + local f = assert(io.popen(...)) + return function () -- iterator + local data = f:read() + if data == nil then f:close() end + return data + end +end + -- }}} -- {{{ A map utility @@ -149,4 +159,5 @@ function helpers.spairs(t) end --}}} + return helpers diff --git a/wiki b/wiki index ecd1b96..2dced03 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit ecd1b96ca46ea4ca66e36acb62156ebe979e639d +Subproject commit 2dced03d48556fedc7113ea619efe686d92cc7fc From ce12475edea7c76fea7f7e020d83d340aa8f1d7c Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sat, 19 Nov 2016 10:30:58 +0100 Subject: [PATCH 74/84] bat: make update() available; #236 --- lain-git.rockspec | 2 +- widgets/bat.lua | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lain-git.rockspec b/lain-git.rockspec index 04dfe34..b8d7abb 100644 --- a/lain-git.rockspec +++ b/lain-git.rockspec @@ -24,5 +24,5 @@ dependencies = { supported_platforms = { "linux" } build = { type = "builtin", - modules = { lain = "init.lua" }, + modules = { lain = "init.lua" } } diff --git a/widgets/bat.lua b/widgets/bat.lua index 991885a..f63b1fa 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -68,7 +68,7 @@ local function worker(args) bat_now.n_perc[i] = 0 end - function update() + function bat.update() local sum_rate_current = 0 local sum_rate_voltage = 0 local sum_rate_power = 0 @@ -165,7 +165,7 @@ local function worker(args) end end - newtimer(battery, timeout, update) + newtimer(battery, timeout, bat.update) return setmetatable(bat, { __index = bat.widget }) end From bef7f37436e6d26b28c6fb528aeddf06eeba26a7 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sat, 19 Nov 2016 10:35:41 +0100 Subject: [PATCH 75/84] wiki updated; closes #236 --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index 2dced03..8555dd3 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 2dced03d48556fedc7113ea619efe686d92cc7fc +Subproject commit 8555dd328bbf444175fbfece962a50017b219a5e From 26ca86598fbdcf1363343323671145c7ebc24418 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sat, 19 Nov 2016 12:32:29 +0100 Subject: [PATCH 76/84] util.mc: check if client is still valid before setting geometry --- util/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/init.lua b/util/init.lua index 70d8e52..5fe8213 100644 --- a/util/init.lua +++ b/util/init.lua @@ -98,7 +98,7 @@ function util.mc(c) g.height = math.sqrt(mwfact) * mg.height g.x = mg.x + (mg.width - g.width) / 2 g.y = mg.y + (mg.height - g.height) / 2 - c:geometry(g) + if c then c:geometry(g) end -- if c is still a valid object end -- Read the nice value of pid from /proc. From 14d047eaa75fb760508e2e4aeb51b42f5fed31ed Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sun, 4 Dec 2016 11:59:08 +0100 Subject: [PATCH 77/84] pull #238: set step to 1%; added same middle click event to alsabar --- widgets/alsabar.lua | 4 ++++ widgets/pulsebar.lua | 2 +- wiki | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/widgets/alsabar.lua b/widgets/alsabar.lua index eec3428..c1d25d0 100644 --- a/widgets/alsabar.lua +++ b/widgets/alsabar.lua @@ -159,6 +159,10 @@ local function worker(args) awful.button ({}, 1, function() awful.util.spawn(alsabar.mixer) end), + awful.button ({}, 2, function() + awful.util.spawn(string.format("%s set %s 100%%", alsabar.cmd, alsabar.channel)) + pulsebar.update() + end), awful.button ({}, 3, function() awful.util.spawn(string.format("%s set %s toggle", alsabar.cmd, alsabar.channel)) alsabar.update() diff --git a/widgets/pulsebar.lua b/widgets/pulsebar.lua index 5b22684..cd153a1 100644 --- a/widgets/pulsebar.lua +++ b/widgets/pulsebar.lua @@ -27,7 +27,7 @@ local setmetatable = setmetatable -- lain.widgets.pulsebar local pulsebar = { sink = 0, - step = "5%", + step = "1%", colors = { background = beautiful.bg_normal, diff --git a/wiki b/wiki index 8555dd3..871d249 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 8555dd328bbf444175fbfece962a50017b219a5e +Subproject commit 871d249789aa00159943fc8553fe0cbfc2159cfd From 80763b314a117c60782daa13fe09e0dff6187630 Mon Sep 17 00:00:00 2001 From: Justin Endacott Date: Mon, 5 Dec 2016 03:03:08 +1000 Subject: [PATCH 78/84] Add additional mouse controls to pulsebar --- widgets/pulsebar.lua | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/widgets/pulsebar.lua b/widgets/pulsebar.lua index 5004be6..5b22684 100644 --- a/widgets/pulsebar.lua +++ b/widgets/pulsebar.lua @@ -27,6 +27,7 @@ local setmetatable = setmetatable -- lain.widgets.pulsebar local pulsebar = { sink = 0, + step = "5%", colors = { background = beautiful.bg_normal, @@ -105,6 +106,7 @@ local function worker(args) pulsebar.colors = args.colors or pulsebar.colors pulsebar.notifications = args.notifications or pulsebar.notifications pulsebar.sink = args.sink or 0 + pulsebar.step = args.step or pulsebar.step pulsebar.followmouse = args.followmouse or false pulsebar.bar = awful.widget.progressbar() @@ -151,7 +153,23 @@ local function worker(args) pulsebar.bar:buttons (awful.util.table.join ( awful.button ({}, 1, function() awful.util.spawn(pulsebar.mixer) - end) + end), + awful.button ({}, 2, function() + awful.util.spawn(string.format("pactl set-sink-lolume %d 100%%", pulsebar.sink)) + pulsebar.update() + end), + awful.button ({}, 3, function() + awful.util.spawn(string.format("pactl set-sink-mute %d toggle", pulsebar.sink)) + pulsebar.update() + end), + awful.button ({}, 4, function() + awful.util.spawn(string.format("pactl set-sink-volume %d +%s", pulsebar.sink, pulsebar.step)) + pulsebar.update() + end), + awful.button ({}, 5, function() + awful.util.spawn(string.format("pactl set-sink-volume %d -%s", pulsebar.sink, pulsebar.step)) + pulsebar.update() + end) )) timer_id = string.format("pulsebar-%s", pulsebar.sink) From ca0c1a666a0a6d17b89633332769618958d3e21d Mon Sep 17 00:00:00 2001 From: Justin Endacott Date: Mon, 5 Dec 2016 07:05:07 +1000 Subject: [PATCH 79/84] Fix typo in pactl command --- widgets/pulsebar.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widgets/pulsebar.lua b/widgets/pulsebar.lua index 5b22684..5852c39 100644 --- a/widgets/pulsebar.lua +++ b/widgets/pulsebar.lua @@ -155,7 +155,7 @@ local function worker(args) awful.util.spawn(pulsebar.mixer) end), awful.button ({}, 2, function() - awful.util.spawn(string.format("pactl set-sink-lolume %d 100%%", pulsebar.sink)) + awful.util.spawn(string.format("pactl set-sink-volume %d 100%%", pulsebar.sink)) pulsebar.update() end), awful.button ({}, 3, function() From 44864dba370a427a67a6f4bf20ec9097bf5bde91 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sun, 4 Dec 2016 12:42:39 +0100 Subject: [PATCH 80/84] pull #239; better implementation --- scripts/dfs | 12 +++++++++++- widgets/alsabar.lua | 12 ++++++------ widgets/calendar.lua | 14 +++++++------- widgets/contrib/kbdlayout.lua | 12 ++++++------ widgets/contrib/task.lua | 16 ++++++++-------- widgets/fs.lua | 9 +++++---- widgets/imap.lua | 3 +-- widgets/maildir.lua | 4 ++-- widgets/pulsebar.lua | 12 ++++++------ 9 files changed, 52 insertions(+), 42 deletions(-) diff --git a/scripts/dfs b/scripts/dfs index bc27b81..1de819a 100755 --- a/scripts/dfs +++ b/scripts/dfs @@ -11,10 +11,11 @@ # ------------------------------------------------------------------------- # Decoding options # ------------------------------------------------------------------------- -USAGE="Usage: $0 [-h(elp)] | [-n(arrow mode)] | [-w(eb output)]" +USAGE="Usage: $0 [-h(elp)] | [-n(arrow mode)] | [-w(eb output) | --type= | --exclude-type=]" NARROW_MODE=0 WEB_OUTPUT=0 +DF_OPTIONS="" while [ $# -gt 0 ]; do case "$1" in @@ -31,6 +32,12 @@ NARROW_MODE=1 "-w" ) WEB_OUTPUT=1 ;; +--type=*) +DF_OPTIONS+=" $1" +;; +--exclude-type=*) +DF_OPTIONS+=" $1" +;; * ) echo $USAGE exit @@ -58,6 +65,9 @@ AWK_COMMAND="/usr/bin/env gawk" ;; esac +# Add additional df options +DF_COMMAND+=$DF_OPTIONS + # ------------------------------------------------------------------------- # Grabbing "df" result # ------------------------------------------------------------------------- diff --git a/widgets/alsabar.lua b/widgets/alsabar.lua index c1d25d0..b20bc40 100644 --- a/widgets/alsabar.lua +++ b/widgets/alsabar.lua @@ -155,23 +155,23 @@ local function worker(args) end end - alsabar.bar:buttons (awful.util.table.join ( - awful.button ({}, 1, function() + alsabar.bar:buttons(awful.util.table.join ( + awful.button({}, 1, function() awful.util.spawn(alsabar.mixer) end), - awful.button ({}, 2, function() + awful.button({}, 2, function() awful.util.spawn(string.format("%s set %s 100%%", alsabar.cmd, alsabar.channel)) pulsebar.update() end), - awful.button ({}, 3, function() + awful.button({}, 3, function() awful.util.spawn(string.format("%s set %s toggle", alsabar.cmd, alsabar.channel)) alsabar.update() end), - awful.button ({}, 4, function() + awful.button({}, 4, function() awful.util.spawn(string.format("%s set %s %s+", alsabar.cmd, alsabar.channel, alsabar.step)) alsabar.update() end), - awful.button ({}, 5, function() + awful.button({}, 5, function() awful.util.spawn(string.format("%s set %s %s-", alsabar.cmd, alsabar.channel, alsabar.step)) alsabar.update() end) diff --git a/widgets/calendar.lua b/widgets/calendar.lua index 1a481ca..a38a142 100644 --- a/widgets/calendar.lua +++ b/widgets/calendar.lua @@ -27,15 +27,15 @@ local setmetatable = setmetatable local calendar = {} local cal_notification = nil -function calendar:hide() +function calendar.hide() if cal_notification ~= nil then naughty.destroy(cal_notification) cal_notification = nil end end -function calendar:show(t_out, inc_offset, scr) - calendar:hide() +function calendar.show(t_out, inc_offset, scr) + calendar.hide() local f, c_text local offs = inc_offset or 0 @@ -96,7 +96,7 @@ function calendar:show(t_out, inc_offset, scr) }) end -function calendar:attach(widget, args) +function calendar.attach(widget, args) local args = args or {} calendar.cal = args.cal or "/usr/bin/cal" @@ -119,11 +119,11 @@ function calendar:attach(widget, args) widget:connect_signal("mouse::enter", function () calendar:show(0, 0, calendar.scr_pos) end) widget:connect_signal("mouse::leave", function () calendar:hide() end) widget:buttons(awful.util.table.join(awful.button({ }, 1, function () - calendar:show(0, -1, calendar.scr_pos) end), + calendar.show(0, -1, calendar.scr_pos) end), awful.button({ }, 3, function () - calendar:show(0, 1, calendar.scr_pos) end), + calendar.show(0, 1, calendar.scr_pos) end), awful.button({ }, 4, function () - calendar:show(0, -1, calendar.scr_pos) end), + calendar.show(0, -1, calendar.scr_pos) end), awful.button({ }, 5, function () calendar:show(0, 1, calendar.scr_pos) end))) end diff --git a/widgets/contrib/kbdlayout.lua b/widgets/contrib/kbdlayout.lua index 64ea6b3..23dc6e3 100644 --- a/widgets/contrib/kbdlayout.lua +++ b/widgets/contrib/kbdlayout.lua @@ -19,7 +19,7 @@ local setmetatable = setmetatable -- Keyboard layout switcher -- lain.widgets.contrib.kblayout -local function worker (args) +local function worker(args) local kbdlayout = {} kbdlayout.widget = wibox.widget.textbox('') @@ -36,21 +36,21 @@ local function worker (args) awful.button({ }, 1, function () kbdlayout.next() end), awful.button({ }, 3, function () kbdlayout.prev() end))) - local function run_settings (layout, variant) + local function run_settings(layout, variant) widget = kbdlayout.widget kbdlayout_now = { layout=string.match(layout, "[^,]+"), -- Make sure to match the primary layout only. variant=variant } settings() end - function kbdlayout.update () + function kbdlayout.update() local status = read_pipe('setxkbmap -query') run_settings(string.match(status, "layout:%s*([^\n]*)"), string.match(status, "variant:%s*([^\n]*)")) end - function kbdlayout.set (i) + function kbdlayout.set(i) idx = ((i - 1) % #layouts) + 1 -- Make sure to wrap around as needed. local to_execute = 'setxkbmap ' .. layouts[idx].layout @@ -67,11 +67,11 @@ local function worker (args) end end - function kbdlayout.next () + function kbdlayout.next() kbdlayout.set(idx + 1) end - function kbdlayout.prev () + function kbdlayout.prev() kbdlayout.set(idx - 1) end diff --git a/widgets/contrib/task.lua b/widgets/contrib/task.lua index 27061b9..fc438d9 100644 --- a/widgets/contrib/task.lua +++ b/widgets/contrib/task.lua @@ -30,15 +30,15 @@ function findLast(haystack, needle) if i==nil then return nil else return i-1 end end -function task:hide() +function task.hide() if task_notification ~= nil then naughty.destroy(task_notification) task_notification = nil end end -function task:show(scr_pos) - task:hide() +function task.show(scr_pos) + task.hide() local f, c_text, scrp @@ -67,7 +67,7 @@ function task:show(scr_pos) }) end -function task:prompt_add() +function task.prompt_add() awful.prompt.run({ prompt = "Add task: " }, mypromptbox[mouse.screen].widget, function (...) @@ -92,7 +92,7 @@ function task:prompt_add() awful.util.getdir("cache") .. "/history_task_add") end -function task:prompt_search() +function task.prompt_search() awful.prompt.run({ prompt = "Search task: " }, mypromptbox[mouse.screen].widget, function (...) @@ -126,7 +126,7 @@ function task:prompt_search() awful.util.getdir("cache") .. "/history_task") end -function task:attach(widget, args) +function task.attach(widget, args) local args = args or {} task.font_size = tonumber(args.font_size) or 12 @@ -143,8 +143,8 @@ function task:attach(widget, args) task.notify_icon = icons_dir .. "/taskwarrior/task.png" task.notify_icon_small = icons_dir .. "/taskwarrior/tasksmall.png" - widget:connect_signal("mouse::enter", function () task:show(task.scr_pos) end) - widget:connect_signal("mouse::leave", function () task:hide() end) + widget:connect_signal("mouse::enter", function () task.show(task.scr_pos) end) + widget:connect_signal("mouse::leave", function () task.hide() end) end return setmetatable(task, { __call = function(_, ...) return create(...) end }) diff --git a/widgets/fs.lua b/widgets/fs.lua index 5215c86..ad5b204 100644 --- a/widgets/fs.lua +++ b/widgets/fs.lua @@ -28,17 +28,18 @@ local setmetatable = setmetatable local fs = {} local fs_notification = nil -function fs:hide() +function fs.hide() if fs_notification ~= nil then naughty.destroy(fs_notification) fs_notification = nil end end -function fs:show(t_out) - fs:hide() +function fs.show(t_out, fs_args) + fs.hide() - local ws = helpers.read_pipe(helpers.scripts_dir .. "dfs"):gsub("\n*$", "") + local cmd = (fs_args and string.format("dfs %s", fs_args)) or "dfs" + local ws = helpers.read_pipe(helpers.scripts_dir .. cmd):gsub("\n*$", "") if fs.followmouse then fs.notification_preset.screen = mouse.screen diff --git a/widgets/imap.lua b/widgets/imap.lua index ea763df..de2f7b4 100644 --- a/widgets/imap.lua +++ b/widgets/imap.lua @@ -41,8 +41,7 @@ local function worker(args) helpers.set_map(mail, 0) - if not is_plain - then + if not is_plain then password = helpers.read_pipe(password):gsub("\n", "") end diff --git a/widgets/maildir.lua b/widgets/maildir.lua index c9937b4..e963fc6 100644 --- a/widgets/maildir.lua +++ b/widgets/maildir.lua @@ -39,8 +39,7 @@ local function worker(args) maildir.widget = wibox.widget.textbox('') function update() - if ext_mail_cmd ~= nil - then + if ext_mail_cmd then awful.util.spawn(ext_mail_cmd) end @@ -75,6 +74,7 @@ local function worker(args) p:close() newmail = "no mail" + -- Count the total number of mails irrespective of where it was found total = 0 diff --git a/widgets/pulsebar.lua b/widgets/pulsebar.lua index cd153a1..51de3a7 100644 --- a/widgets/pulsebar.lua +++ b/widgets/pulsebar.lua @@ -150,23 +150,23 @@ local function worker(args) end end - pulsebar.bar:buttons (awful.util.table.join ( - awful.button ({}, 1, function() + pulsebar.bar:buttons(awful.util.table.join ( + awful.button({}, 1, function() awful.util.spawn(pulsebar.mixer) end), - awful.button ({}, 2, function() + awful.button({}, 2, function() awful.util.spawn(string.format("pactl set-sink-lolume %d 100%%", pulsebar.sink)) pulsebar.update() end), - awful.button ({}, 3, function() + awful.button({}, 3, function() awful.util.spawn(string.format("pactl set-sink-mute %d toggle", pulsebar.sink)) pulsebar.update() end), - awful.button ({}, 4, function() + awful.button({}, 4, function() awful.util.spawn(string.format("pactl set-sink-volume %d +%s", pulsebar.sink, pulsebar.step)) pulsebar.update() end), - awful.button ({}, 5, function() + awful.button({}, 5, function() awful.util.spawn(string.format("pactl set-sink-volume %d -%s", pulsebar.sink, pulsebar.step)) pulsebar.update() end) From b5c2c4cab580d63be5b6e7e54b8c445b87fffaa5 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sun, 4 Dec 2016 13:06:12 +0100 Subject: [PATCH 81/84] small fixes to calls; wiki updated --- widgets/fs.lua | 8 +++++--- widgets/pulsebar.lua | 3 +-- wiki | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/widgets/fs.lua b/widgets/fs.lua index ad5b204..6038746 100644 --- a/widgets/fs.lua +++ b/widgets/fs.lua @@ -35,20 +35,22 @@ function fs.hide() end end -function fs.show(t_out, fs_args) +function fs.show(seconds, options, scr) fs.hide() - local cmd = (fs_args and string.format("dfs %s", fs_args)) or "dfs" + local cmd = (options and string.format("dfs %s", options)) or "dfs" local ws = helpers.read_pipe(helpers.scripts_dir .. cmd):gsub("\n*$", "") if fs.followmouse then fs.notification_preset.screen = mouse.screen + elseif scr then + fs.notification_preset.screen = scr end fs_notification = naughty.notify({ preset = fs.notification_preset, text = ws, - timeout = t_out + timeout = seconds or 5 }) end diff --git a/widgets/pulsebar.lua b/widgets/pulsebar.lua index 51de3a7..006515c 100644 --- a/widgets/pulsebar.lua +++ b/widgets/pulsebar.lua @@ -155,8 +155,7 @@ local function worker(args) awful.util.spawn(pulsebar.mixer) end), awful.button({}, 2, function() - awful.util.spawn(string.format("pactl set-sink-lolume %d 100%%", pulsebar.sink)) - pulsebar.update() + awful.util.spawn(string.format("pactl set-sink-volume %d 100%%", pulsebar.sink)) end), awful.button({}, 3, function() awful.util.spawn(string.format("pactl set-sink-mute %d toggle", pulsebar.sink)) diff --git a/wiki b/wiki index 871d249..d0df450 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 871d249789aa00159943fc8553fe0cbfc2159cfd +Subproject commit d0df450d05655c5d8f724c42dc6b5d18b3676a60 From 7d431ef9c41f66e885dbace27e0843395940f1bd Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sun, 4 Dec 2016 13:27:52 +0100 Subject: [PATCH 82/84] calendar: fixed typos --- widgets/calendar.lua | 6 +++--- widgets/pulsebar.lua | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/widgets/calendar.lua b/widgets/calendar.lua index a38a142..1728dfc 100644 --- a/widgets/calendar.lua +++ b/widgets/calendar.lua @@ -116,8 +116,8 @@ function calendar.attach(widget, args) calendar.offset = 0 calendar.notify_icon = nil - widget:connect_signal("mouse::enter", function () calendar:show(0, 0, calendar.scr_pos) end) - widget:connect_signal("mouse::leave", function () calendar:hide() end) + widget:connect_signal("mouse::enter", function () calendar.show(0, 0, calendar.scr_pos) end) + widget:connect_signal("mouse::leave", function () calendar.hide() end) widget:buttons(awful.util.table.join(awful.button({ }, 1, function () calendar.show(0, -1, calendar.scr_pos) end), awful.button({ }, 3, function () @@ -125,7 +125,7 @@ function calendar.attach(widget, args) awful.button({ }, 4, function () calendar.show(0, -1, calendar.scr_pos) end), awful.button({ }, 5, function () - calendar:show(0, 1, calendar.scr_pos) end))) + calendar.show(0, 1, calendar.scr_pos) end))) end return setmetatable(calendar, { __call = function(_, ...) return create(...) end }) diff --git a/widgets/pulsebar.lua b/widgets/pulsebar.lua index 006515c..fc2951b 100644 --- a/widgets/pulsebar.lua +++ b/widgets/pulsebar.lua @@ -178,4 +178,4 @@ local function worker(args) return pulsebar end -return setmetatable(pulsebar, { __call = function(_, ...) return worker(...) end }) +eturn setmetatable(pulsebar, { __call = function(_, ...) return worker(...) end }) From 36767762270a9ec0f510e4573e0b40f77597aa32 Mon Sep 17 00:00:00 2001 From: Justin Endacott Date: Tue, 6 Dec 2016 18:40:40 +1000 Subject: [PATCH 83/84] Fix typo in return statement --- widgets/pulsebar.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widgets/pulsebar.lua b/widgets/pulsebar.lua index fc2951b..006515c 100644 --- a/widgets/pulsebar.lua +++ b/widgets/pulsebar.lua @@ -178,4 +178,4 @@ local function worker(args) return pulsebar end -eturn setmetatable(pulsebar, { __call = function(_, ...) return worker(...) end }) +return setmetatable(pulsebar, { __call = function(_, ...) return worker(...) end }) From 7a26917b93ee53ec7ea665cbc557bd476586ced2 Mon Sep 17 00:00:00 2001 From: Justin Endacott Date: Wed, 7 Dec 2016 03:48:18 +1000 Subject: [PATCH 84/84] Update pulsebar after setting volume to 100% --- widgets/pulsebar.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/widgets/pulsebar.lua b/widgets/pulsebar.lua index 006515c..7f22642 100644 --- a/widgets/pulsebar.lua +++ b/widgets/pulsebar.lua @@ -156,6 +156,7 @@ local function worker(args) end), awful.button({}, 2, function() awful.util.spawn(string.format("pactl set-sink-volume %d 100%%", pulsebar.sink)) + pulsebar.update() end), awful.button({}, 3, function() awful.util.spawn(string.format("pactl set-sink-mute %d toggle", pulsebar.sink))