mirror of https://github.com/lcpz/lain.git
Fix async update calls in fs widget
- Use `gears.protected_call` in order to get errors logged. - Fix `fs.show` not waiting for update to complete.
This commit is contained in:
parent
a2e2e7194e
commit
bdb19e827e
|
@ -12,6 +12,7 @@ local Gio = require("lgi").Gio
|
||||||
local focused = require("awful.screen").focused
|
local focused = require("awful.screen").focused
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
local naughty = require("naughty")
|
local naughty = require("naughty")
|
||||||
|
local gears = require("gears")
|
||||||
local math = math
|
local math = math
|
||||||
local string = string
|
local string = string
|
||||||
local tconcat = table.concat
|
local tconcat = table.concat
|
||||||
|
@ -43,12 +44,14 @@ local function factory(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
function fs.show(seconds, scr)
|
function fs.show(seconds, scr)
|
||||||
fs.hide(); fs.update()
|
fs.hide()
|
||||||
|
fs.update(function()
|
||||||
fs.notification_preset.screen = fs.followtag and focused() or scr or 1
|
fs.notification_preset.screen = fs.followtag and focused() or scr or 1
|
||||||
fs.notification = naughty.notify {
|
fs.notification = naughty.notify {
|
||||||
preset = fs.notification_preset,
|
preset = fs.notification_preset,
|
||||||
timeout = type(seconds) == "number" and seconds or 5
|
timeout = type(seconds) == "number" and seconds or 5
|
||||||
}
|
}
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
local timeout = args.timeout or 600
|
local timeout = args.timeout or 600
|
||||||
|
@ -131,8 +134,13 @@ local function factory(args)
|
||||||
fs.notification_preset.text = tconcat(notifytable)
|
fs.notification_preset.text = tconcat(notifytable)
|
||||||
end
|
end
|
||||||
|
|
||||||
function fs.update()
|
function fs.update(callback)
|
||||||
Gio.Async.start(update_synced)()
|
Gio.Async.start(gears.protected_call.call)(function()
|
||||||
|
update_synced()
|
||||||
|
if callback then
|
||||||
|
callback()
|
||||||
|
end
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
if showpopup == "on" then
|
if showpopup == "on" then
|
||||||
|
|
Loading…
Reference in New Issue