#126 extended to every supported widget

This commit is contained in:
luke bonham 2015-07-29 13:21:59 +02:00 committed by copycat-killer
parent f291bd62b7
commit 52deb69119
9 changed files with 116 additions and 65 deletions

View File

@ -15,6 +15,7 @@ local naughty = require("naughty")
local io = { popen = io.popen } local io = { popen = io.popen }
local math = { modf = math.modf } local math = { modf = math.modf }
local mouse = mouse
local string = { format = string.format, local string = { format = string.format,
match = string.match, match = string.match,
rep = string.rep } rep = string.rep }
@ -75,6 +76,10 @@ function alsabar.notify()
.. string.rep(" ", alsabar.notifications.bar_size - int) .. string.rep(" ", alsabar.notifications.bar_size - int)
.. "]" .. "]"
if alsabar.followmouse then
preset.screen = mouse.screen
end
if alsabar._notify ~= nil then if alsabar._notify ~= nil then
alsabar._notify = naughty.notify ({ alsabar._notify = naughty.notify ({
replaces_id = alsabar._notify.id, replaces_id = alsabar._notify.id,
@ -102,6 +107,7 @@ local function worker(args)
alsabar.step = args.step or alsabar.step alsabar.step = args.step or alsabar.step
alsabar.colors = args.colors or alsabar.colors alsabar.colors = args.colors or alsabar.colors
alsabar.notifications = args.notifications or alsabar.notifications alsabar.notifications = args.notifications or alsabar.notifications
alsabar.followmouse = args.followmouse or false
alsabar.bar = awful.widget.progressbar() alsabar.bar = awful.widget.progressbar()

View File

@ -14,6 +14,7 @@ local naughty = require("naughty")
local io = { popen = io.popen } local io = { popen = io.popen }
local os = { date = os.date } local os = { date = os.date }
local mouse = mouse
local tonumber = tonumber local tonumber = tonumber
local setmetatable = setmetatable local setmetatable = setmetatable
@ -89,6 +90,12 @@ function calendar:show(t_out, inc_offset, scr)
.. "</span></tt>" .. "</span></tt>"
f:close() f:close()
if calendar.followmouse then
local scrp = mouse.screen
else
local scrp = scr or calendar.scr_pos
end
cal_notification = naughty.notify({ cal_notification = naughty.notify({
text = c_text, text = c_text,
icon = calendar.notify_icon, icon = calendar.notify_icon,
@ -96,12 +103,13 @@ function calendar:show(t_out, inc_offset, scr)
fg = calendar.fg, fg = calendar.fg,
bg = calendar.bg, bg = calendar.bg,
timeout = tims, timeout = tims,
screen = scr or 1 screen = scrp
}) })
end end
function calendar:attach(widget, args) function calendar:attach(widget, args)
local args = args or {} local args = args or {}
calendar.cal = args.cal or "/usr/bin/cal" calendar.cal = args.cal or "/usr/bin/cal"
calendar.post_cal = args.post_cal or "" calendar.post_cal = args.post_cal or ""
calendar.icons = args.icons or icons_dir .. "cal/white/" calendar.icons = args.icons or icons_dir .. "cal/white/"
@ -111,7 +119,8 @@ function calendar:attach(widget, args)
calendar.fg = args.fg or beautiful.fg_normal or "#FFFFFF" calendar.fg = args.fg or beautiful.fg_normal or "#FFFFFF"
calendar.bg = args.bg or beautiful.bg_normal or "#FFFFFF" calendar.bg = args.bg or beautiful.bg_normal or "#FFFFFF"
calendar.position = args.position or "top_right" calendar.position = args.position or "top_right"
calendar.scr_pos = args.scr_pos or mouse.screen calendar.scr_pos = args.scr_pos or 1
calendar.followmouse = args.followmouse or false
calendar.offset = 0 calendar.offset = 0
calendar.notify_icon = nil calendar.notify_icon = nil

View File

@ -29,6 +29,7 @@ local function worker(args)
local music_dir = args.music_dir or os.getenv("HOME") .. "/Music" local music_dir = args.music_dir or os.getenv("HOME") .. "/Music"
local cover_size = args.cover_size or 100 local cover_size = args.cover_size or 100
local default_art = args.default_art or "" local default_art = args.default_art or ""
local followmouse = args.followmouse or false
local settings = args.settings or function() end local settings = args.settings or function() end
local mpdcover = helpers.scripts_dir .. "mpdcover" local mpdcover = helpers.scripts_dir .. "mpdcover"
@ -82,6 +83,10 @@ local function worker(args)
os.execute(string.format("%s %q %q %d %q", mpdcover, "", os.execute(string.format("%s %q %q %d %q", mpdcover, "",
moc_now.file, cover_size, default_art)) moc_now.file, cover_size, default_art))
if followmouse then
moc_notification_preset.screen = mouse.screen
end
moc.id = naughty.notify({ moc.id = naughty.notify({
preset = moc_notification_preset, preset = moc_notification_preset,
icon = "/tmp/mpdcover.png", icon = "/tmp/mpdcover.png",

View File

@ -12,6 +12,7 @@ local awful = require("awful")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local naughty = require("naughty") local naughty = require("naughty")
local mouse = mouse
local io = io local io = io
local string = { len = string.len } local string = { len = string.len }
local tonumber = tonumber local tonumber = tonumber
@ -36,6 +37,12 @@ function task:show(scr_pos)
local f, c_text 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') f = io.popen('task')
c_text = "<span font='" c_text = "<span font='"
.. task.font .. " " .. task.font .. " "
@ -51,7 +58,7 @@ function task:show(scr_pos)
fg = task.fg, fg = task.fg,
bg = task.bg, bg = task.bg,
timeout = task.timeout, timeout = task.timeout,
screen = scr_pos or 1 screen = scrp
}) })
end end
@ -125,11 +132,12 @@ function task:attach(widget, args)
task.position = args.position or "top_right" task.position = args.position or "top_right"
task.timeout = args.timeout or 7 task.timeout = args.timeout or 7
task.scr_pos = args.scr_pos or 1 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 = icons_dir .. "/taskwarrior/task.png"
task.notify_icon_small = icons_dir .. "/taskwarrior/tasksmall.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) widget:connect_signal("mouse::leave", function () task:hide() end)
end end

View File

@ -16,6 +16,7 @@ local naughty = require("naughty")
local io = { popen = io.popen } local io = { popen = io.popen }
local pairs = pairs local pairs = pairs
local mouse = mouse
local string = { match = string.match, local string = { match = string.match,
format = string.format } format = string.format }
local tonumber = tonumber local tonumber = tonumber
@ -25,9 +26,7 @@ local setmetatable = setmetatable
-- File system disk space usage -- File system disk space usage
-- lain.widgets.fs -- lain.widgets.fs
local fs = {} local fs = {}
local fs_notification = nil local fs_notification = nil
fs_notification_preset = { fg = beautiful.fg_normal }
function fs:hide() function fs:hide()
if fs_notification ~= nil then if fs_notification ~= nil then
@ -39,14 +38,16 @@ end
function fs:show(t_out) function fs:show(t_out)
fs:hide() fs:hide()
naughty.notify({text=fs_notification_preset.screen})
local f = io.popen(helpers.scripts_dir .. "dfs") local f = io.popen(helpers.scripts_dir .. "dfs")
ws = f:read("*all"):gsub("\n*$", "") ws = f:read("*all"):gsub("\n*$", "")
f:close() f:close()
if fs.followmouse then
fs.notification_preset.screen = mouse.screen
end
notification = naughty.notify({ notification = naughty.notify({
preset = fs_notification_preset, preset = fs.notification_preset,
text = ws, text = ws,
timeout = t_out timeout = t_out
}) })
@ -61,6 +62,9 @@ local function worker(args)
local partition = args.partition or "/" local partition = args.partition or "/"
local settings = args.settings or function() end 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('') fs.widget = wibox.widget.textbox('')
helpers.set_map(partition, false) helpers.set_map(partition, false)

View File

@ -12,6 +12,7 @@ local async = require("lain.asyncshell")
local naughty = require("naughty") local naughty = require("naughty")
local wibox = require("wibox") local wibox = require("wibox")
local mouse = mouse
local string = { format = string.format, local string = { format = string.format,
gsub = string.gsub } gsub = string.gsub }
local tonumber = tonumber local tonumber = tonumber
@ -32,6 +33,7 @@ local function worker(args)
local port = args.port or 993 local port = args.port or 993
local timeout = args.timeout or 60 local timeout = args.timeout or 60
local is_plain = args.is_plain or false local is_plain = args.is_plain or false
local followmouse = args.followmouse or false
local settings = args.settings or function() end local settings = args.settings or function() end
local head_command = "curl --connect-timeout 3 -fsm 3" local head_command = "curl --connect-timeout 3 -fsm 3"
@ -54,6 +56,10 @@ local function worker(args)
position = "top_left" 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", curl = string.format("%s --url imaps://%s:%s/INBOX -u %s:%q %s -k",
head_command, server, port, mail, password, request) head_command, server, port, mail, password, request)

View File

@ -17,6 +17,7 @@ local wibox = require("wibox")
local os = { execute = os.execute, local os = { execute = os.execute,
getenv = os.getenv } getenv = os.getenv }
local math = { floor = math.floor } local math = { floor = math.floor }
local mouse = mouse
local string = { format = string.format, local string = { format = string.format,
match = string.match, match = string.match,
gmatch = string.gmatch } gmatch = string.gmatch }
@ -36,6 +37,7 @@ local function worker(args)
local music_dir = args.music_dir or os.getenv("HOME") .. "/Music" local music_dir = args.music_dir or os.getenv("HOME") .. "/Music"
local cover_size = args.cover_size or 100 local cover_size = args.cover_size or 100
local default_art = args.default_art or "" local default_art = args.default_art or ""
local followmouse = args.followmouse or false
local settings = args.settings or function() end local settings = args.settings or function() end
local mpdcover = helpers.scripts_dir .. "mpdcover" local mpdcover = helpers.scripts_dir .. "mpdcover"
@ -98,6 +100,10 @@ local function worker(args)
current_icon = default_art current_icon = default_art
end end
if followmouse then
mpd_notification_preset.screen = mouse.screen
end
mpd.id = naughty.notify({ mpd.id = naughty.notify({
preset = mpd_notification_preset, preset = mpd_notification_preset,
icon = current_icon, icon = current_icon,

View File

@ -14,6 +14,7 @@ local naughty = require("naughty")
local wibox = require("wibox") local wibox = require("wibox")
local math = { floor = math.floor } local math = { floor = math.floor }
local mouse = mouse
local string = { format = string.format, local string = { format = string.format,
gsub = string.gsub } gsub = string.gsub }
@ -36,7 +37,8 @@ local function worker(args)
local cnt = args.cnt or 7 local cnt = args.cnt or 7
local date_cmd = args.date_cmd or "date -u -d @%d +'%%a %%d'" local date_cmd = args.date_cmd or "date -u -d @%d +'%%a %%d'"
local icons_path = args.icons_path or lain_icons .. "openweathermap/" local icons_path = args.icons_path or lain_icons .. "openweathermap/"
local w_notification_preset = args.w_notification_preset or {} local notification_preset = args.notification_preset or {}
local followmouse = args.followmouse or false
local settings = args.settings or function() end local settings = args.settings or function() end
weather.widget = wibox.widget.textbox('') weather.widget = wibox.widget.textbox('')
@ -44,11 +46,16 @@ local function worker(args)
function weather.show(t_out) function weather.show(t_out)
weather.hide() weather.hide()
if followmouse then
notification_preset.screen = mouse.screen
end
weather.notification = naughty.notify({ weather.notification = naughty.notify({
text = weather.notification_text, text = weather.notification_text,
icon = weather.icon_path, icon = weather.icon_path,
timeout = t_out, timeout = t_out,
preset = w_notification_preset preset = notification_preset
}) })
end end

2
wiki

@ -1 +1 @@
Subproject commit 1544177cc083a62e40d93dfc29e545dcafae40be Subproject commit 1b310ca2f9277d66d285b9ef89e38eb5106535fb