updated awesome extention
This commit is contained in:
parent
82772b3ae9
commit
3b55c94cc9
@ -12,7 +12,8 @@ local io = { lines = io.lines,
|
|||||||
open = io.open }
|
open = io.open }
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local rawget = rawget
|
local rawget = rawget
|
||||||
local table = { sort = table.sort }
|
local table = { sort = table.sort, unpack = table.unpack }
|
||||||
|
local unpack = unpack or table.unpack -- lua 5.1 retro-compatibility
|
||||||
|
|
||||||
-- Lain helper functions for internal use
|
-- Lain helper functions for internal use
|
||||||
-- lain.helpers
|
-- lain.helpers
|
||||||
|
@ -8,9 +8,7 @@
|
|||||||
|
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
local math = { ceil = math.ceil,
|
local math = math
|
||||||
floor = math.floor,
|
|
||||||
max = math.max }
|
|
||||||
local screen = screen
|
local screen = screen
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
|
|
||||||
|
@ -158,9 +158,10 @@ end
|
|||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- On the fly useless gaps change
|
-- On the fly useless gaps change
|
||||||
function util.useless_gaps_resize(thatmuch)
|
function util.useless_gaps_resize(thatmuch, s, t)
|
||||||
local scr = awful.screen.focused()
|
local scr = s or awful.screen.focused()
|
||||||
scr.selected_tag.gap = scr.selected_tag.gap + tonumber(thatmuch)
|
local tag = t or scr.selected_tag
|
||||||
|
tag.gap = tag.gap + tonumber(thatmuch)
|
||||||
awful.layout.arrange(scr)
|
awful.layout.arrange(scr)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,12 +11,13 @@
|
|||||||
-- lain.util.menu_iterator
|
-- lain.util.menu_iterator
|
||||||
|
|
||||||
local naughty = require("naughty")
|
local naughty = require("naughty")
|
||||||
|
local helpers = require("lain.helpers")
|
||||||
local util = require("lain.util")
|
local util = require("lain.util")
|
||||||
local atable = require("awful.util").table
|
local atable = require("awful.util").table
|
||||||
local assert = assert
|
local assert = assert
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local tconcat = table.concat
|
local tconcat = table.concat
|
||||||
local unpack = unpack
|
local unpack = unpack or table.unpack -- lua 5.1 retro-compatibility
|
||||||
|
|
||||||
local state = { cid = nil }
|
local state = { cid = nil }
|
||||||
|
|
||||||
|
@ -8,13 +8,10 @@
|
|||||||
|
|
||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
local capi = { client = client }
|
local capi = { client = client }
|
||||||
|
local math = math
|
||||||
local math = { floor = math.floor }
|
local string = string
|
||||||
local string = { format = string.format }
|
|
||||||
|
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local screen = screen
|
local screen = screen
|
||||||
|
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
|
|
||||||
-- Quake-like Dropdown application spawn
|
-- Quake-like Dropdown application spawn
|
||||||
|
@ -9,8 +9,7 @@
|
|||||||
local helpers = require("lain.helpers")
|
local helpers = require("lain.helpers")
|
||||||
local shell = require("awful.util").shell
|
local shell = require("awful.util").shell
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
local string = { match = string.match,
|
local string = string
|
||||||
format = string.format }
|
|
||||||
|
|
||||||
-- ALSA volume
|
-- ALSA volume
|
||||||
-- lain.widget.alsa
|
-- lain.widget.alsa
|
||||||
|
@ -10,8 +10,10 @@ local helpers = require("lain.helpers")
|
|||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
local naughty = require("naughty")
|
local naughty = require("naughty")
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
|
local math = math
|
||||||
local math, string, type, tonumber = math, string, type, tonumber
|
local string = string
|
||||||
|
local type = type
|
||||||
|
local tonumber = tonumber
|
||||||
|
|
||||||
-- ALSA volume bar
|
-- ALSA volume bar
|
||||||
-- lain.widget.alsabar
|
-- lain.widget.alsabar
|
||||||
|
@ -30,6 +30,7 @@ local function factory(args)
|
|||||||
local args = args or {}
|
local args = args or {}
|
||||||
local timeout = args.timeout or 30
|
local timeout = args.timeout or 30
|
||||||
local notify = args.notify or "on"
|
local notify = args.notify or "on"
|
||||||
|
local full_notify = args.full_notify or notify
|
||||||
local n_perc = args.n_perc or { 5, 15 }
|
local n_perc = args.n_perc or { 5, 15 }
|
||||||
local batteries = args.batteries or (args.battery and {args.battery}) or {}
|
local batteries = args.batteries or (args.battery and {args.battery}) or {}
|
||||||
local ac = args.ac or "AC0"
|
local ac = args.ac or "AC0"
|
||||||
@ -198,7 +199,7 @@ local function factory(args)
|
|||||||
}).id
|
}).id
|
||||||
end
|
end
|
||||||
fullnotification = false
|
fullnotification = false
|
||||||
elseif bat_now.status == "Full" and not fullnotification then
|
elseif bat_now.status == "Full" and full_notify == "on" and not fullnotification then
|
||||||
bat.id = naughty.notify({
|
bat.id = naughty.notify({
|
||||||
preset = bat_notification_charged_preset,
|
preset = bat_notification_charged_preset,
|
||||||
replaces_id = bat.id
|
replaces_id = bat.id
|
||||||
|
@ -19,6 +19,7 @@ local tostring = tostring
|
|||||||
|
|
||||||
-- Calendar notification
|
-- Calendar notification
|
||||||
-- lain.widget.cal
|
-- lain.widget.cal
|
||||||
|
|
||||||
local function factory(args)
|
local function factory(args)
|
||||||
args = args or {}
|
args = args or {}
|
||||||
local cal = {
|
local cal = {
|
||||||
@ -47,6 +48,7 @@ local function factory(args)
|
|||||||
strx = string.format("%s%s", string.rep(" ", 3 - tostring(x):len()), strx)
|
strx = string.format("%s%s", string.rep(" ", 3 - tostring(x):len()), strx)
|
||||||
notifytable[#notifytable+1] = string.format("%-4s%s", strx, (x+st_day)%7==0 and x ~= mth_days and "\n" or "")
|
notifytable[#notifytable+1] = string.format("%-4s%s", strx, (x+st_day)%7==0 and x ~= mth_days and "\n" or "")
|
||||||
end
|
end
|
||||||
|
if string.len(cal.icons or "") > 0 and today then cal.icon = cal.icons .. today .. ".png" end
|
||||||
cal.month, cal.year = d.month, d.year
|
cal.month, cal.year = d.month, d.year
|
||||||
return notifytable
|
return notifytable
|
||||||
end
|
end
|
||||||
@ -78,7 +80,7 @@ local function factory(args)
|
|||||||
cal.notification = nil
|
cal.notification = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function cal.show(timeout, month, year)
|
function cal.show(timeout, month, year, scr)
|
||||||
cal.notification_preset.text = tconcat(cal.build(month, year))
|
cal.notification_preset.text = tconcat(cal.build(month, year))
|
||||||
|
|
||||||
if cal.three then
|
if cal.three then
|
||||||
@ -94,6 +96,7 @@ local function factory(args)
|
|||||||
cal.hide()
|
cal.hide()
|
||||||
cal.notification = naughty.notify {
|
cal.notification = naughty.notify {
|
||||||
preset = cal.notification_preset,
|
preset = cal.notification_preset,
|
||||||
|
screen = cal.followtag and awful.screen.focused() or scr or 1,
|
||||||
icon = cal.icon,
|
icon = cal.icon,
|
||||||
timeout = timeout or cal.notification_preset.timeout or 5
|
timeout = timeout or cal.notification_preset.timeout or 5
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,8 @@ local focused = require("awful.screen").focused
|
|||||||
local escape_f = require("awful.util").escape
|
local escape_f = require("awful.util").escape
|
||||||
local naughty = require("naughty")
|
local naughty = require("naughty")
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
local os = { getenv = os.getenv }
|
local os = os
|
||||||
local string = { format = string.format,
|
local string = string
|
||||||
gmatch = string.gmatch }
|
|
||||||
|
|
||||||
-- MOC audio player
|
-- MOC audio player
|
||||||
-- lain.widget.contrib.moc
|
-- lain.widget.contrib.moc
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
--[[
|
--[[
|
||||||
|
|
||||||
Licensed under GNU General Public License v2
|
Licensed under GNU General Public License v2
|
||||||
|
* (c) 2017, Luca CPZ
|
||||||
* (c) 2014, blueluke <http://github.com/blueluke>
|
* (c) 2014, blueluke <http://github.com/blueluke>
|
||||||
|
|
||||||
--]]
|
--]]
|
||||||
|
@ -10,7 +10,7 @@ local markup = require("lain.util").markup
|
|||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
local naughty = require("naughty")
|
local naughty = require("naughty")
|
||||||
local mouse = mouse
|
local mouse = mouse
|
||||||
local string = { format = string.format, gsub = string.gsub }
|
local string = string
|
||||||
|
|
||||||
-- Taskwarrior notification
|
-- Taskwarrior notification
|
||||||
-- lain.widget.contrib.task
|
-- lain.widget.contrib.task
|
||||||
@ -23,11 +23,7 @@ function task.hide()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function task.show(scr)
|
function task.show(scr)
|
||||||
if task.followtag then
|
task.notification_preset.screen = task.followtag and awful.screen.focused() or scr or 1
|
||||||
task.notification_preset.screen = awful.screen.focused()
|
|
||||||
elseif scr then
|
|
||||||
task.notification_preset.screen = scr
|
|
||||||
end
|
|
||||||
|
|
||||||
helpers.async({ awful.util.shell, "-c", task.show_cmd }, function(f)
|
helpers.async({ awful.util.shell, "-c", task.show_cmd }, function(f)
|
||||||
local widget_focused = true
|
local widget_focused = true
|
||||||
@ -44,12 +40,12 @@ function task.show(scr)
|
|||||||
|
|
||||||
if widget_focused then
|
if widget_focused then
|
||||||
task.hide()
|
task.hide()
|
||||||
task.notification = naughty.notify({
|
task.notification = naughty.notify {
|
||||||
preset = task.notification_preset,
|
preset = task.notification_preset,
|
||||||
title = "task next",
|
title = "task next",
|
||||||
text = markup.font(task.notification_preset.font,
|
text = markup.font(task.notification_preset.font,
|
||||||
awful.util.escape(f:gsub("\n*$", "")))
|
awful.util.escape(f:gsub("\n*$", "")))
|
||||||
})
|
}
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
@ -1,163 +0,0 @@
|
|||||||
--[[
|
|
||||||
|
|
||||||
tpbat.lua
|
|
||||||
Battery status widget for ThinkPad laptops that use SMAPI
|
|
||||||
lain.widget.contrib.tpbat
|
|
||||||
|
|
||||||
More on tp_smapi: http://www.thinkwiki.org/wiki/Tp_smapi
|
|
||||||
|
|
||||||
Licensed under GNU General Public License v2
|
|
||||||
* (c) 2013, Conor Heine
|
|
||||||
* (c) 2013, Luca CPZ
|
|
||||||
* (c) 2010-2012, Peter Hofmann
|
|
||||||
|
|
||||||
--]]
|
|
||||||
|
|
||||||
local debug = { getinfo = debug.getinfo }
|
|
||||||
local newtimer = require("lain.helpers").newtimer
|
|
||||||
local first_line = require("lain.helpers").first_line
|
|
||||||
local naughty = require("naughty")
|
|
||||||
local wibox = require("wibox")
|
|
||||||
local string = { format = string.format }
|
|
||||||
local math = { floor = math.floor }
|
|
||||||
local tostring = tostring
|
|
||||||
local setmetatable = setmetatable
|
|
||||||
package.path = debug.getinfo(1,"S").source:match[[^@?(.*[\/])[^\/]-$]] .. "?.lua;" .. package.path
|
|
||||||
local smapi = require("smapi")
|
|
||||||
|
|
||||||
-- ThinkPad SMAPI-enabled battery info widget
|
|
||||||
-- lain.widget.contrib.tpbat
|
|
||||||
local tpbat = {}
|
|
||||||
|
|
||||||
function tpbat.hide()
|
|
||||||
if not tpbat.notification then return end
|
|
||||||
naughty.destroy(tpbat.notification)
|
|
||||||
tpbat.notification = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
function tpbat.show(t_out)
|
|
||||||
tpbat.hide()
|
|
||||||
|
|
||||||
local bat = tpbat.bat
|
|
||||||
|
|
||||||
if bat == nil or not bat:installed() then return end
|
|
||||||
|
|
||||||
local t_out = t_out or 0
|
|
||||||
local mfgr = bat:get('manufacturer') or "no_mfgr"
|
|
||||||
local model = bat:get('model') or "no_model"
|
|
||||||
local chem = bat:get('chemistry') or "no_chem"
|
|
||||||
local status = bat:get('state') or "nil"
|
|
||||||
local time = bat:remaining_time()
|
|
||||||
local msg = "\t"
|
|
||||||
|
|
||||||
if status ~= "idle" and status ~= "nil" then
|
|
||||||
if time == "N/A" then
|
|
||||||
msg = "...Calculating time remaining..."
|
|
||||||
else
|
|
||||||
msg = time .. (status == "charging" and " until charged" or " remaining")
|
|
||||||
end
|
|
||||||
else
|
|
||||||
msg = "On AC Power"
|
|
||||||
end
|
|
||||||
|
|
||||||
local str = string.format("%s : %s %s (%s)\n", bat.name, mfgr, model, chem)
|
|
||||||
.. string.format("\n%s \t\t\t %s", status:upper(), msg)
|
|
||||||
|
|
||||||
tpbat.notification = naughty.notify({
|
|
||||||
text = str,
|
|
||||||
timeout = t_out,
|
|
||||||
screen = client.focus and client.focus.screen or 1
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
function tpbat.register(args)
|
|
||||||
local args = args or {}
|
|
||||||
local timeout = args.timeout or 30
|
|
||||||
local battery = args.battery or "BAT0"
|
|
||||||
local bat_low_perc = args.bat_low_perc or 15
|
|
||||||
local bat_critical_perc = args.bat_critical_perc or 5
|
|
||||||
local settings = args.settings or function() end
|
|
||||||
|
|
||||||
tpbat.bat = smapi:battery(battery) -- Create a new battery
|
|
||||||
local bat = tpbat.bat
|
|
||||||
|
|
||||||
tpbat.widget = wibox.widget.textbox()
|
|
||||||
|
|
||||||
bat_notification_low_preset = {
|
|
||||||
title = "Battery low",
|
|
||||||
text = "Plug the cable!",
|
|
||||||
timeout = 15,
|
|
||||||
fg = "#202020",
|
|
||||||
bg = "#CDCDCD"
|
|
||||||
}
|
|
||||||
|
|
||||||
bat_notification_critical_preset = {
|
|
||||||
title = "Battery exhausted",
|
|
||||||
text = "Shutdown imminent",
|
|
||||||
timeout = 15,
|
|
||||||
fg = "#000000",
|
|
||||||
bg = "#FFFFFF"
|
|
||||||
}
|
|
||||||
|
|
||||||
if bat:get('state') == nil
|
|
||||||
then
|
|
||||||
local n = naughty.notify({
|
|
||||||
preset = bat_notification_low_preset,
|
|
||||||
title = "SMAPI Battery Warning: Unable to read battery state!",
|
|
||||||
text = "This widget is intended for ThinkPads. Is tp_smapi installed? Check your configs & paths.",
|
|
||||||
screen = client.focus and client.focus.screen or 1
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
function tpbat.update()
|
|
||||||
bat_now = {
|
|
||||||
status = "Not present",
|
|
||||||
perc = "N/A",
|
|
||||||
time = "N/A",
|
|
||||||
watt = "N/A"
|
|
||||||
}
|
|
||||||
|
|
||||||
if bat:installed()
|
|
||||||
then
|
|
||||||
bat_now.status = bat:status() or "N/A"
|
|
||||||
bat_now.perc = bat:percent()
|
|
||||||
bat_now.time = bat:remaining_time()
|
|
||||||
-- bat_now.watt = string.format("%.2fW", (VOLTS * AMPS) / 1e12)
|
|
||||||
|
|
||||||
-- notifications for low and critical states (when discharging)
|
|
||||||
if bat_now.status == "discharging"
|
|
||||||
then
|
|
||||||
if bat_now.perc <= bat_critical_perc
|
|
||||||
then
|
|
||||||
tpbat.id = naughty.notify({
|
|
||||||
preset = bat_notification_critical_preset,
|
|
||||||
replaces_id = tpbat.id,
|
|
||||||
screen = client.focus and client.focus.screen or 1
|
|
||||||
}).id
|
|
||||||
elseif bat_now.perc <= bat_low_perc
|
|
||||||
then
|
|
||||||
tpbat.id = naughty.notify({
|
|
||||||
preset = bat_notification_low_preset,
|
|
||||||
replaces_id = tpbat.id,
|
|
||||||
screen = client.focus and client.focus.screen or 1
|
|
||||||
}).id
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
bat_now.perc = tostring(bat_now.perc)
|
|
||||||
end
|
|
||||||
|
|
||||||
widget = tpbat.widget
|
|
||||||
|
|
||||||
settings()
|
|
||||||
end
|
|
||||||
|
|
||||||
newtimer("tpbat-" .. bat.name, timeout, tpbat.update)
|
|
||||||
|
|
||||||
widget:connect_signal('mouse::enter', function () tpbat.show() end)
|
|
||||||
widget:connect_signal('mouse::leave', function () tpbat.hide() end)
|
|
||||||
|
|
||||||
return tpbat
|
|
||||||
end
|
|
||||||
|
|
||||||
return setmetatable(tpbat, { __call = function(_, ...) return tpbat.register(...) end })
|
|
@ -1,98 +0,0 @@
|
|||||||
--[[
|
|
||||||
|
|
||||||
smapi.lua
|
|
||||||
Interface with thinkpad battery information
|
|
||||||
|
|
||||||
Licensed under GNU General Public License v2
|
|
||||||
* (c) 2013, Conor Heine
|
|
||||||
|
|
||||||
--]]
|
|
||||||
|
|
||||||
local first_line = require("lain.helpers").first_line
|
|
||||||
|
|
||||||
local string = { format = string.format }
|
|
||||||
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?)
|
|
||||||
local readable = {
|
|
||||||
barcoding = true,
|
|
||||||
charging_max_current = true,
|
|
||||||
charging_max_voltage = true,
|
|
||||||
chemistry = true,
|
|
||||||
current_avg = true,
|
|
||||||
current_now = true,
|
|
||||||
cycle_count = true,
|
|
||||||
design_capacity = true,
|
|
||||||
design_voltage = true,
|
|
||||||
dump = true,
|
|
||||||
first_use_date = true,
|
|
||||||
force_discharge = false,
|
|
||||||
group0_voltage = true,
|
|
||||||
group1_voltage = true,
|
|
||||||
group2_voltage = true,
|
|
||||||
group3_voltage = true,
|
|
||||||
inhibit_charge_minutes = false,
|
|
||||||
installed = true,
|
|
||||||
last_full_capacity = true,
|
|
||||||
manufacture_date = true,
|
|
||||||
manufacturer = true,
|
|
||||||
model = true,
|
|
||||||
power_avg = true,
|
|
||||||
power_now = true,
|
|
||||||
remaining_capacity = true,
|
|
||||||
remaining_charging_time = true,
|
|
||||||
remaining_percent = true,
|
|
||||||
remaining_percent_error = true,
|
|
||||||
remaining_running_time = true,
|
|
||||||
remaining_running_time_now = true,
|
|
||||||
serial = true,
|
|
||||||
start_charge_thresh = false,
|
|
||||||
state = true,
|
|
||||||
stop_charge_thresh = false,
|
|
||||||
temperature = true,
|
|
||||||
voltage = true
|
|
||||||
}
|
|
||||||
|
|
||||||
function smapi:battery(name)
|
|
||||||
local bat = {}
|
|
||||||
|
|
||||||
bat.name = name
|
|
||||||
bat.path = apipath .. "/" .. name
|
|
||||||
|
|
||||||
function bat:get(item)
|
|
||||||
return self.path ~= nil and readable[item] and first_line(self.path .. "/" .. item) or nil
|
|
||||||
end
|
|
||||||
|
|
||||||
function bat:installed()
|
|
||||||
return self:get("installed") == "1"
|
|
||||||
end
|
|
||||||
|
|
||||||
function bat:status()
|
|
||||||
return self:get('state')
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Remaining time can either be time until battery dies or time until charging completes
|
|
||||||
function bat:remaining_time()
|
|
||||||
local time_val = bat_now.status == 'discharging' and 'remaining_running_time' or 'remaining_charging_time'
|
|
||||||
local mins_left = self:get(time_val)
|
|
||||||
|
|
||||||
if not mins_left:find("^%d+") then return "N/A" end
|
|
||||||
|
|
||||||
local hrs = math.floor(mins_left / 60)
|
|
||||||
local min = mins_left % 60
|
|
||||||
|
|
||||||
return string.format("%02d:%02d", hrs, min)
|
|
||||||
end
|
|
||||||
|
|
||||||
function bat:percent()
|
|
||||||
return tonumber(self:get("remaining_percent"))
|
|
||||||
end
|
|
||||||
|
|
||||||
return setmetatable(bat, {__metatable = false, __newindex = false})
|
|
||||||
end
|
|
||||||
|
|
||||||
return smapi
|
|
@ -8,9 +8,8 @@
|
|||||||
|
|
||||||
local helpers = require("lain.helpers")
|
local helpers = require("lain.helpers")
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
local math = { ceil = math.ceil }
|
local math = math
|
||||||
local string = { format = string.format,
|
local string = string
|
||||||
gmatch = string.gmatch }
|
|
||||||
local tostring = tostring
|
local tostring = tostring
|
||||||
|
|
||||||
-- CPU usage
|
-- CPU usage
|
||||||
|
@ -52,6 +52,7 @@ local function factory(args)
|
|||||||
local args = args or {}
|
local args = args or {}
|
||||||
local timeout = args.timeout or 600
|
local timeout = args.timeout or 600
|
||||||
local partition = args.partition
|
local partition = args.partition
|
||||||
|
local threshold = args.threshold or 99
|
||||||
local showpopup = args.showpopup or "on"
|
local showpopup = args.showpopup or "on"
|
||||||
local settings = args.settings or function() end
|
local settings = args.settings or function() end
|
||||||
|
|
||||||
@ -106,12 +107,12 @@ local function factory(args)
|
|||||||
widget = fs.widget
|
widget = fs.widget
|
||||||
settings()
|
settings()
|
||||||
|
|
||||||
if partition and fs_now[partition] and fs_now[partition].used >= 99 then
|
if partition and fs_now[partition] and fs_now[partition].percentage >= threshold then
|
||||||
if not helpers.get_map(partition) then
|
if not helpers.get_map(partition) then
|
||||||
naughty.notify {
|
naughty.notify {
|
||||||
preset = naughty.config.presets.critical,
|
preset = naughty.config.presets.critical,
|
||||||
title = "Warning",
|
title = "Warning",
|
||||||
text = partition .. " is full",
|
text = string.format("%s is above %d%% (%d%%)", partition, threshold, fs_now[partition].percentage)
|
||||||
}
|
}
|
||||||
helpers.set_map(partition, true)
|
helpers.set_map(partition, true)
|
||||||
else
|
else
|
||||||
|
@ -24,56 +24,68 @@ local function factory(args)
|
|||||||
local password = args.password
|
local password = args.password
|
||||||
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 pwdtimeout = args.pwdtimeout or 10
|
||||||
local is_plain = args.is_plain or false
|
local is_plain = args.is_plain or false
|
||||||
local followtag = args.followtag or false
|
local followtag = args.followtag or false
|
||||||
local notify = args.notify or "on"
|
local notify = args.notify or "on"
|
||||||
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"
|
||||||
local request = "-X 'SEARCH (UNSEEN)'"
|
local request = "-X 'STATUS INBOX (MESSAGES RECENT UNSEEN)'"
|
||||||
|
|
||||||
if not server or not mail or not password then return end
|
if not server or not mail or not password then return end
|
||||||
|
|
||||||
|
mail_notification_preset = {
|
||||||
|
icon = helpers.icons_dir .. "mail.png",
|
||||||
|
position = "top_left"
|
||||||
|
}
|
||||||
|
|
||||||
helpers.set_map(mail, 0)
|
helpers.set_map(mail, 0)
|
||||||
|
|
||||||
if not is_plain then
|
if not is_plain then
|
||||||
if type(password) == "string" or type(password) == "table" then
|
if type(password) == "string" or type(password) == "table" then
|
||||||
helpers.async(password, function(f) password = f:gsub("\n", "") end)
|
helpers.async(password, function(f) password = f:gsub("\n", "") end)
|
||||||
elseif type(password) == "function" then
|
elseif type(password) == "function" then
|
||||||
local p = password()
|
imap.pwdtimer = helpers.newtimer(mail .. "-password", pwdtimeout, function()
|
||||||
|
local retrieved_password, try_again = password()
|
||||||
|
if not try_again then
|
||||||
|
imap.pwdtimer:stop() -- stop trying to retrieve
|
||||||
|
password = retrieved_password or "" -- failsafe
|
||||||
|
end
|
||||||
|
end, true, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function update()
|
function imap.update()
|
||||||
mail_notification_preset = {
|
-- do not update if the password has not been retrieved yet
|
||||||
icon = helpers.icons_dir .. "mail.png",
|
if type(password) ~= "string" then return end
|
||||||
position = "top_left"
|
|
||||||
}
|
|
||||||
|
|
||||||
if followtag then
|
local curl = string.format("%s --url imaps://%s:%s/INBOX -u %s:'%s' %s -k",
|
||||||
mail_notification_preset.screen = awful.screen.focused()
|
|
||||||
end
|
|
||||||
|
|
||||||
local 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)
|
||||||
|
|
||||||
helpers.async(curl, function(f)
|
helpers.async(curl, function(f)
|
||||||
mailcount = tonumber(f:match("UNSEEN (%d+)"))
|
imap_now = { ["MESSAGES"] = 0, ["RECENT"] = 0, ["UNSEEN"] = 0 }
|
||||||
|
|
||||||
|
for s,d in f:gmatch("(%w+)%s+(%d+)") do imap_now[s] = tonumber(d) end
|
||||||
|
mailcount = imap_now["UNSEEN"] -- backwards compatibility
|
||||||
widget = imap.widget
|
widget = imap.widget
|
||||||
|
|
||||||
settings()
|
settings()
|
||||||
|
|
||||||
if notify == "on" and mailcount and mailcount >= 1 and mailcount > helpers.get_map(mail) then
|
if notify == "on" and mailcount and mailcount >= 1 and mailcount > helpers.get_map(mail) then
|
||||||
local nt = mail .. " has <b>" .. mailcount .. "</b> new message"
|
if followtag then mail_notification_preset.screen = awful.screen.focused() end
|
||||||
if mailcount >= 1 then nt = nt .. "s" end
|
naughty.notify {
|
||||||
naughty.notify { preset = mail_notification_preset, text = nt }
|
preset = mail_notification_preset,
|
||||||
|
text = string.format("%s has <b>%d</b> new message%s", mail, mailcount, mailcount == 1 and "" or "s")
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
helpers.set_map(mail, mailcount)
|
helpers.set_map(mail, imap_now["UNSEEN"])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
imap.timer = helpers.newtimer(mail, timeout, update, true, true)
|
imap.timer = helpers.newtimer(mail, timeout, imap.update, true, true)
|
||||||
|
|
||||||
return imap
|
return imap
|
||||||
end
|
end
|
||||||
|
@ -12,10 +12,8 @@ local escape_f = require("awful.util").escape
|
|||||||
local focused = require("awful.screen").focused
|
local focused = require("awful.screen").focused
|
||||||
local naughty = require("naughty")
|
local naughty = require("naughty")
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
local os = { getenv = os.getenv }
|
local os = os
|
||||||
local string = { format = string.format,
|
local string = string
|
||||||
gmatch = string.gmatch,
|
|
||||||
match = string.match }
|
|
||||||
|
|
||||||
-- MPD infos
|
-- MPD infos
|
||||||
-- lain.widget.mpd
|
-- lain.widget.mpd
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
local helpers = require("lain.helpers")
|
local helpers = require("lain.helpers")
|
||||||
local naughty = require("naughty")
|
local naughty = require("naughty")
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
local string = { format = string.format, match = string.match }
|
local string = string
|
||||||
|
|
||||||
-- Network infos
|
-- Network infos
|
||||||
-- lain.widget.net
|
-- lain.widget.net
|
||||||
|
@ -8,9 +8,7 @@
|
|||||||
local helpers = require("lain.helpers")
|
local helpers = require("lain.helpers")
|
||||||
local shell = require("awful.util").shell
|
local shell = require("awful.util").shell
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
local string = { gmatch = string.gmatch,
|
local string = string
|
||||||
match = string.match,
|
|
||||||
format = string.format }
|
|
||||||
local type = type
|
local type = type
|
||||||
|
|
||||||
-- PulseAudio volume
|
-- PulseAudio volume
|
||||||
|
@ -10,8 +10,10 @@ local helpers = require("lain.helpers")
|
|||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
local naughty = require("naughty")
|
local naughty = require("naughty")
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
|
local math = math
|
||||||
local math, string, type, tonumber = math, string, type, tonumber
|
local string = string
|
||||||
|
local type = type
|
||||||
|
local tonumber = tonumber
|
||||||
|
|
||||||
-- PulseAudio volume bar
|
-- PulseAudio volume bar
|
||||||
-- lain.widget.pulsebar
|
-- lain.widget.pulsebar
|
||||||
|
@ -10,8 +10,10 @@ local json = require("lain.util").dkjson
|
|||||||
local focused = require("awful.screen").focused
|
local focused = require("awful.screen").focused
|
||||||
local naughty = require("naughty")
|
local naughty = require("naughty")
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
|
local math = math
|
||||||
local math, os, string, tonumber = math, os, string, tonumber
|
local os = os
|
||||||
|
local string = string
|
||||||
|
local tonumber = tonumber
|
||||||
|
|
||||||
-- OpenWeatherMap
|
-- OpenWeatherMap
|
||||||
-- current weather and X-days forecast
|
-- current weather and X-days forecast
|
||||||
|
@ -93,11 +93,11 @@ local revelation = {
|
|||||||
is_excluded = false,
|
is_excluded = false,
|
||||||
curr_tag_only = false,
|
curr_tag_only = false,
|
||||||
font = "monospace 20",
|
font = "monospace 20",
|
||||||
fg = beautiful.fg_normal or "#DCDCCC",
|
fg = beautiful.revelation_fg_normal or beautiful.fg_normal or "#DCDCCC",
|
||||||
bg = beautiful.bg_normal or "#000000",
|
bg = beautiful.revelation_bg_normal or beautiful.bg_normal or "#000000",
|
||||||
border_color=beautiful.border_focus or "#DCDCCC",
|
border_color = beautiful.revelation_border_color or beautiful.border_focus or "#DCDCCC",
|
||||||
border_width=beautiful.border_width or 2,
|
border_width = beautiful.revelation_border_width or beautiful.border_width or 2,
|
||||||
hintsize = (type(beautiful.xresources) == 'table' and beautiful.xresources.apply_dpi(50) or 60)
|
hintsize = (type(beautiful.xresources) == 'table' and beautiful.xresources.apply_dpi(beautiful.revelation_hintsize or 50) or 60)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user