Skip to content

Commit

Permalink
#424: assert that timeout seconds in every naughty notification are n…
Browse files Browse the repository at this point in the history
…umbers
  • Loading branch information
lcpz committed Apr 8, 2019
1 parent 013654c commit fd2e616
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
5 changes: 3 additions & 2 deletions widget/cal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ local os = os
local pairs = pairs
local string = string
local tconcat = table.concat
local type = type
local tonumber = tonumber
local tostring = tostring

Expand Down Expand Up @@ -80,7 +81,7 @@ local function factory(args)
cal.notification = nil
end

function cal.show(timeout, month, year, scr)
function cal.show(seconds, month, year, scr)
cal.notification_preset.text = tconcat(cal.build(month, year))

if cal.three then
Expand All @@ -98,7 +99,7 @@ local function factory(args)
preset = cal.notification_preset,
screen = cal.followtag and awful.screen.focused() or scr or 1,
icon = cal.icon,
timeout = timeout or cal.notification_preset.timeout or 5
timeout = type(seconds) == "number" and seconds or cal.notification_preset.timeout or 5
}
end

Expand Down
3 changes: 2 additions & 1 deletion widget/contrib/tp_smapi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local gears = require("gears")
local naughty = require("naughty")
local wibox = require("wibox")
local string = string
local type = type

-- ThinkPad battery infos and widget creator
-- http://www.thinkwiki.org/wiki/Tp_smapi
Expand Down Expand Up @@ -73,7 +74,7 @@ local function factory(apipath)
tp_smapi.notification = naughty.notify {
title = string.format("%s: %s %s (%s)", batid, mfgr, model, chem),
text = msg,
timeout = seconds or 0,
timeout = type(seconds) == "number" and seconds or 0,
screen = scr or focused()
}
end
Expand Down
3 changes: 2 additions & 1 deletion widget/fs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ local naughty = require("naughty")
local math = math
local string = string
local tconcat = table.concat
local type = type
local tonumber = tonumber
local query_size = Gio.FILE_ATTRIBUTE_FILESYSTEM_SIZE
local query_free = Gio.FILE_ATTRIBUTE_FILESYSTEM_FREE
Expand Down Expand Up @@ -45,7 +46,7 @@ local function factory(args)
fs.notification_preset.screen = fs.followtag and focused() or scr or 1
fs.notification = naughty.notify {
preset = fs.notification_preset,
timeout = seconds or 5
timeout = type(seconds) == "number" and seconds or 5
}
end

Expand Down
11 changes: 6 additions & 5 deletions widget/weather.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local wibox = require("wibox")
local math = math
local os = os
local string = string
local type = type
local tonumber = tonumber

-- OpenWeatherMap
Expand Down Expand Up @@ -51,7 +52,7 @@ local function factory(args)
weather.icon_path = icons_path .. "na.png"
weather.icon = wibox.widget.imagebox(weather.icon_path)

function weather.show(t_out)
function weather.show(seconds)
weather.hide()

if followtag then
Expand All @@ -63,12 +64,12 @@ local function factory(args)
weather.forecast_update()
end

weather.notification = naughty.notify({
weather.notification = naughty.notify {
preset = notification_preset,
text = weather.notification_text,
icon = weather.icon_path,
timeout = t_out,
preset = notification_preset
})
timeout = type(seconds == "number") and seconds or notification_preset.timeout
}
end

function weather.hide()
Expand Down
2 changes: 1 addition & 1 deletion wiki
Submodule wiki updated from 7a9945 to 50fc0e

0 comments on commit fd2e616

Please sign in to comment.