mirror of https://github.com/lcpz/lain.git
#126 extended to every supported widget
This commit is contained in:
parent
f291bd62b7
commit
52deb69119
|
@ -15,6 +15,7 @@ local naughty = require("naughty")
|
|||
|
||||
local io = { popen = io.popen }
|
||||
local math = { modf = math.modf }
|
||||
local mouse = mouse
|
||||
local string = { format = string.format,
|
||||
match = string.match,
|
||||
rep = string.rep }
|
||||
|
@ -75,6 +76,10 @@ function alsabar.notify()
|
|||
.. string.rep(" ", alsabar.notifications.bar_size - int)
|
||||
.. "]"
|
||||
|
||||
if alsabar.followmouse then
|
||||
preset.screen = mouse.screen
|
||||
end
|
||||
|
||||
if alsabar._notify ~= nil then
|
||||
alsabar._notify = naughty.notify ({
|
||||
replaces_id = alsabar._notify.id,
|
||||
|
@ -102,6 +107,7 @@ local function worker(args)
|
|||
alsabar.step = args.step or alsabar.step
|
||||
alsabar.colors = args.colors or alsabar.colors
|
||||
alsabar.notifications = args.notifications or alsabar.notifications
|
||||
alsabar.followmouse = args.followmouse or false
|
||||
|
||||
alsabar.bar = awful.widget.progressbar()
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ local naughty = require("naughty")
|
|||
|
||||
local io = { popen = io.popen }
|
||||
local os = { date = os.date }
|
||||
local mouse = mouse
|
||||
local tonumber = tonumber
|
||||
|
||||
local setmetatable = setmetatable
|
||||
|
@ -89,6 +90,12 @@ function calendar:show(t_out, inc_offset, scr)
|
|||
.. "</span></tt>"
|
||||
f:close()
|
||||
|
||||
if calendar.followmouse then
|
||||
local scrp = mouse.screen
|
||||
else
|
||||
local scrp = scr or calendar.scr_pos
|
||||
end
|
||||
|
||||
cal_notification = naughty.notify({
|
||||
text = c_text,
|
||||
icon = calendar.notify_icon,
|
||||
|
@ -96,36 +103,38 @@ function calendar:show(t_out, inc_offset, scr)
|
|||
fg = calendar.fg,
|
||||
bg = calendar.bg,
|
||||
timeout = tims,
|
||||
screen = scr or 1
|
||||
screen = scrp
|
||||
})
|
||||
end
|
||||
|
||||
function calendar:attach(widget, args)
|
||||
local args = args or {}
|
||||
calendar.cal = args.cal or "/usr/bin/cal"
|
||||
calendar.post_cal = args.post_cal or ""
|
||||
calendar.icons = args.icons or icons_dir .. "cal/white/"
|
||||
calendar.font = args.font or beautiful.font:sub(beautiful.font:find(""),
|
||||
beautiful.font:find(" "))
|
||||
calendar.font_size = tonumber(args.font_size) or 11
|
||||
calendar.fg = args.fg or beautiful.fg_normal or "#FFFFFF"
|
||||
calendar.bg = args.bg or beautiful.bg_normal or "#FFFFFF"
|
||||
calendar.position = args.position or "top_right"
|
||||
calendar.scr_pos = args.scr_pos or mouse.screen
|
||||
|
||||
calendar.offset = 0
|
||||
calendar.cal = args.cal or "/usr/bin/cal"
|
||||
calendar.post_cal = args.post_cal or ""
|
||||
calendar.icons = args.icons or icons_dir .. "cal/white/"
|
||||
calendar.font = args.font or beautiful.font:sub(beautiful.font:find(""),
|
||||
beautiful.font:find(" "))
|
||||
calendar.font_size = tonumber(args.font_size) or 11
|
||||
calendar.fg = args.fg or beautiful.fg_normal or "#FFFFFF"
|
||||
calendar.bg = args.bg or beautiful.bg_normal or "#FFFFFF"
|
||||
calendar.position = args.position or "top_right"
|
||||
calendar.scr_pos = args.scr_pos or 1
|
||||
calendar.followmouse = args.followmouse or false
|
||||
|
||||
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:buttons(awful.util.table.join( awful.button({ }, 1, function ()
|
||||
calendar:show(0, -1, calendar.scr_pos) end),
|
||||
awful.button({ }, 3, function ()
|
||||
calendar:show(0, 1, calendar.scr_pos) end),
|
||||
awful.button({ }, 4, function ()
|
||||
calendar:show(0, -1, calendar.scr_pos) end),
|
||||
awful.button({ }, 5, function ()
|
||||
calendar:show(0, 1, calendar.scr_pos) end)))
|
||||
widget:buttons(awful.util.table.join(awful.button({ }, 1, function ()
|
||||
calendar:show(0, -1, calendar.scr_pos) end),
|
||||
awful.button({ }, 3, function ()
|
||||
calendar:show(0, 1, calendar.scr_pos) end),
|
||||
awful.button({ }, 4, function ()
|
||||
calendar:show(0, -1, calendar.scr_pos) end),
|
||||
awful.button({ }, 5, function ()
|
||||
calendar:show(0, 1, calendar.scr_pos) end)))
|
||||
end
|
||||
|
||||
return setmetatable(calendar, { __call = function(_, ...) return create(...) end })
|
||||
|
|
|
@ -29,6 +29,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 followmouse = args.followmouse or false
|
||||
local settings = args.settings or function() end
|
||||
|
||||
local mpdcover = helpers.scripts_dir .. "mpdcover"
|
||||
|
@ -82,6 +83,10 @@ local function worker(args)
|
|||
os.execute(string.format("%s %q %q %d %q", mpdcover, "",
|
||||
moc_now.file, cover_size, default_art))
|
||||
|
||||
if followmouse then
|
||||
moc_notification_preset.screen = mouse.screen
|
||||
end
|
||||
|
||||
moc.id = naughty.notify({
|
||||
preset = moc_notification_preset,
|
||||
icon = "/tmp/mpdcover.png",
|
||||
|
|
|
@ -12,6 +12,7 @@ local awful = require("awful")
|
|||
local beautiful = require("beautiful")
|
||||
local naughty = require("naughty")
|
||||
|
||||
local mouse = mouse
|
||||
local io = io
|
||||
local string = { len = string.len }
|
||||
local tonumber = tonumber
|
||||
|
@ -36,6 +37,12 @@ function task:show(scr_pos)
|
|||
|
||||
local f, c_text
|
||||
|
||||
if task.followmouse then
|
||||
local scrp = mouse.screen
|
||||
else
|
||||
local scrp = scr_pos or task.scr_pos
|
||||
end
|
||||
|
||||
f = io.popen('task')
|
||||
c_text = "<span font='"
|
||||
.. task.font .. " "
|
||||
|
@ -51,7 +58,7 @@ function task:show(scr_pos)
|
|||
fg = task.fg,
|
||||
bg = task.bg,
|
||||
timeout = task.timeout,
|
||||
screen = scr_pos or 1
|
||||
screen = scrp
|
||||
})
|
||||
end
|
||||
|
||||
|
@ -115,21 +122,22 @@ function task:prompt_search()
|
|||
end
|
||||
|
||||
function task:attach(widget, args)
|
||||
local args = args or {}
|
||||
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.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"
|
||||
task.timeout = args.timeout or 7
|
||||
task.scr_pos = args.scr_pos or 1
|
||||
task.font_size = tonumber(args.font_size) or 12
|
||||
task.font = beautiful.font:sub(beautiful.font:find(""),
|
||||
beautiful.font:find(" "))
|
||||
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"
|
||||
task.timeout = args.timeout or 7
|
||||
task.scr_pos = args.scr_pos or 1
|
||||
task.followmouse = args.followmouse or false
|
||||
|
||||
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(scr_pos) end)
|
||||
widget:connect_signal("mouse::enter", function () task:show(task.scr_pos) end)
|
||||
widget:connect_signal("mouse::leave", function () task:hide() end)
|
||||
end
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ local naughty = require("naughty")
|
|||
|
||||
local io = { popen = io.popen }
|
||||
local pairs = pairs
|
||||
local mouse = mouse
|
||||
local string = { match = string.match,
|
||||
format = string.format }
|
||||
local tonumber = tonumber
|
||||
|
@ -25,9 +26,7 @@ local setmetatable = setmetatable
|
|||
-- File system disk space usage
|
||||
-- lain.widgets.fs
|
||||
local fs = {}
|
||||
|
||||
local fs_notification = nil
|
||||
fs_notification_preset = { fg = beautiful.fg_normal }
|
||||
|
||||
function fs:hide()
|
||||
if fs_notification ~= nil then
|
||||
|
@ -39,14 +38,16 @@ end
|
|||
function fs:show(t_out)
|
||||
fs:hide()
|
||||
|
||||
naughty.notify({text=fs_notification_preset.screen})
|
||||
|
||||
local f = io.popen(helpers.scripts_dir .. "dfs")
|
||||
ws = f:read("*all"):gsub("\n*$", "")
|
||||
f:close()
|
||||
|
||||
if fs.followmouse then
|
||||
fs.notification_preset.screen = mouse.screen
|
||||
end
|
||||
|
||||
notification = naughty.notify({
|
||||
preset = fs_notification_preset,
|
||||
preset = fs.notification_preset,
|
||||
text = ws,
|
||||
timeout = t_out
|
||||
})
|
||||
|
@ -56,10 +57,13 @@ end
|
|||
local unit = { ["mb"] = 1024, ["gb"] = 1024^2 }
|
||||
|
||||
local function worker(args)
|
||||
local args = args or {}
|
||||
local timeout = args.timeout or 600
|
||||
local partition = args.partition or "/"
|
||||
local settings = args.settings or function() end
|
||||
local args = args or {}
|
||||
local timeout = args.timeout or 600
|
||||
local partition = args.partition or "/"
|
||||
local settings = args.settings or function() end
|
||||
|
||||
fs.followmouse = args.followmouse or false
|
||||
fs.notification_preset = args.notification_preset or { fg = beautiful.fg_normal }
|
||||
|
||||
fs.widget = wibox.widget.textbox('')
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ local async = require("lain.asyncshell")
|
|||
local naughty = require("naughty")
|
||||
local wibox = require("wibox")
|
||||
|
||||
local mouse = mouse
|
||||
local string = { format = string.format,
|
||||
gsub = string.gsub }
|
||||
local tonumber = tonumber
|
||||
|
@ -22,17 +23,18 @@ local setmetatable = setmetatable
|
|||
-- lain.widgets.imap
|
||||
|
||||
local function worker(args)
|
||||
local imap = {}
|
||||
local args = args or {}
|
||||
local imap = {}
|
||||
local args = args or {}
|
||||
|
||||
local server = args.server
|
||||
local mail = args.mail
|
||||
local password = args.password
|
||||
local server = args.server
|
||||
local mail = args.mail
|
||||
local password = args.password
|
||||
|
||||
local port = args.port or 993
|
||||
local timeout = args.timeout or 60
|
||||
local is_plain = args.is_plain or false
|
||||
local settings = args.settings or function() end
|
||||
local port = args.port or 993
|
||||
local timeout = args.timeout or 60
|
||||
local is_plain = args.is_plain or false
|
||||
local followmouse = args.followmouse or false
|
||||
local settings = args.settings or function() end
|
||||
|
||||
local head_command = "curl --connect-timeout 3 -fsm 3"
|
||||
local request = "-X 'SEARCH (UNSEEN)'"
|
||||
|
@ -54,6 +56,10 @@ local function worker(args)
|
|||
position = "top_left"
|
||||
}
|
||||
|
||||
if followmouse then
|
||||
mail_notification_preset.screen = mouse.screen
|
||||
end
|
||||
|
||||
curl = string.format("%s --url imaps://%s:%s/INBOX -u %s:%q %s -k",
|
||||
head_command, server, port, mail, password, request)
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ local wibox = require("wibox")
|
|||
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 }
|
||||
|
@ -36,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 followmouse = args.followmouse or false
|
||||
local settings = args.settings or function() end
|
||||
|
||||
local mpdcover = helpers.scripts_dir .. "mpdcover"
|
||||
|
@ -98,6 +100,10 @@ local function worker(args)
|
|||
current_icon = default_art
|
||||
end
|
||||
|
||||
if followmouse then
|
||||
mpd_notification_preset.screen = mouse.screen
|
||||
end
|
||||
|
||||
mpd.id = naughty.notify({
|
||||
preset = mpd_notification_preset,
|
||||
icon = current_icon,
|
||||
|
|
|
@ -14,6 +14,7 @@ local naughty = require("naughty")
|
|||
local wibox = require("wibox")
|
||||
|
||||
local math = { floor = math.floor }
|
||||
local mouse = mouse
|
||||
local string = { format = string.format,
|
||||
gsub = string.gsub }
|
||||
|
||||
|
@ -24,31 +25,37 @@ local setmetatable = setmetatable
|
|||
-- lain.widgets.weather
|
||||
|
||||
local function worker(args)
|
||||
local weather = {}
|
||||
local args = args or {}
|
||||
local timeout = args.timeout or 900 -- 15 min
|
||||
local timeout_forecast = args.timeout or 86400 -- 24 hrs
|
||||
local current_call = "curl -s 'http://api.openweathermap.org/data/2.5/weather?id=%s&units=%s&lang=%s'"
|
||||
local forecast_call = "curl -s 'http://api.openweathermap.org/data/2.5/forecast/daily?id=%s&units=%s&lang=%s&cnt=%s'"
|
||||
local city_id = args.city_id or 0 -- placeholder
|
||||
local units = args.units or "metric"
|
||||
local lang = args.lang or "en"
|
||||
local cnt = args.cnt or 7
|
||||
local date_cmd = args.date_cmd or "date -u -d @%d +'%%a %%d'"
|
||||
local icons_path = args.icons_path or lain_icons .. "openweathermap/"
|
||||
local w_notification_preset = args.w_notification_preset or {}
|
||||
local settings = args.settings or function() end
|
||||
local weather = {}
|
||||
local args = args or {}
|
||||
local timeout = args.timeout or 900 -- 15 min
|
||||
local timeout_forecast = args.timeout or 86400 -- 24 hrs
|
||||
local current_call = "curl -s 'http://api.openweathermap.org/data/2.5/weather?id=%s&units=%s&lang=%s'"
|
||||
local forecast_call = "curl -s 'http://api.openweathermap.org/data/2.5/forecast/daily?id=%s&units=%s&lang=%s&cnt=%s'"
|
||||
local city_id = args.city_id or 0 -- placeholder
|
||||
local units = args.units or "metric"
|
||||
local lang = args.lang or "en"
|
||||
local cnt = args.cnt or 7
|
||||
local date_cmd = args.date_cmd or "date -u -d @%d +'%%a %%d'"
|
||||
local icons_path = args.icons_path or lain_icons .. "openweathermap/"
|
||||
local notification_preset = args.notification_preset or {}
|
||||
local followmouse = args.followmouse or false
|
||||
local settings = args.settings or function() end
|
||||
|
||||
weather.widget = wibox.widget.textbox('')
|
||||
weather.icon = wibox.widget.imagebox()
|
||||
|
||||
function weather.show(t_out)
|
||||
weather.hide()
|
||||
|
||||
if followmouse then
|
||||
notification_preset.screen = mouse.screen
|
||||
end
|
||||
|
||||
weather.notification = naughty.notify({
|
||||
text = weather.notification_text,
|
||||
icon = weather.icon_path,
|
||||
timeout = t_out,
|
||||
preset = w_notification_preset
|
||||
preset = notification_preset
|
||||
})
|
||||
end
|
||||
|
||||
|
|
2
wiki
2
wiki
|
@ -1 +1 @@
|
|||
Subproject commit 1544177cc083a62e40d93dfc29e545dcafae40be
|
||||
Subproject commit 1b310ca2f9277d66d285b9ef89e38eb5106535fb
|
Loading…
Reference in New Issue