mirror of https://github.com/lcpz/lain.git
Merge branch 'unisgn-master'
This commit is contained in:
commit
613263e0d3
|
@ -60,6 +60,8 @@ function quake:display()
|
|||
client.floating = true
|
||||
client.border_width = self.border
|
||||
client.size_hints_honor = false
|
||||
local maximized = client.maximized
|
||||
local fullscreen = client.fullscreen
|
||||
client:geometry(self.geometry[self.screen.index] or self:compute_size())
|
||||
|
||||
-- Set not sticky and on top
|
||||
|
@ -74,11 +76,17 @@ function quake:display()
|
|||
-- Toggle display
|
||||
if self.visible then
|
||||
client.hidden = false
|
||||
client.maximized = self.maximized
|
||||
client.fullscreen = self.fullscreen
|
||||
client:raise()
|
||||
self.last_tag = self.screen.selected_tag
|
||||
client:tags({self.screen.selected_tag})
|
||||
capi.client.focus = client
|
||||
else
|
||||
else
|
||||
self.maximized = maximized
|
||||
self.fullscreen = fullscreen
|
||||
client.maximized = false
|
||||
client.fullscreen = false
|
||||
client.hidden = true
|
||||
local ctags = client:tags()
|
||||
for i, t in pairs(ctags) do
|
||||
|
@ -135,6 +143,9 @@ function quake:new(config)
|
|||
conf.horiz = conf.horiz or "left" -- left, right or center
|
||||
conf.geometry = {} -- internal use
|
||||
|
||||
conf.maximized = false
|
||||
conf.fullscreen = false
|
||||
|
||||
local dropdown = setmetatable(conf, { __index = quake })
|
||||
|
||||
capi.client.connect_signal("manage", function(c)
|
||||
|
|
|
@ -15,8 +15,8 @@ local string = string
|
|||
-- lain.widget.alsa
|
||||
|
||||
local function factory(args)
|
||||
local alsa = { widget = wibox.widget.textbox() }
|
||||
local args = args or {}
|
||||
local alsa = { widget = args.widget or wibox.widget.textbox() }
|
||||
local timeout = args.timeout or 5
|
||||
local settings = args.settings or function() end
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ local function factory(args)
|
|||
return
|
||||
end
|
||||
|
||||
local bat = { widget = wibox.widget.textbox() }
|
||||
local args = args or {}
|
||||
local bat = { widget = args.widget or wibox.widget.textbox() }
|
||||
local timeout = args.timeout or 30
|
||||
local notify = args.notify or "on"
|
||||
local full_notify = args.full_notify or notify
|
||||
|
@ -136,7 +136,7 @@ local function factory(args)
|
|||
-- "Full", "Unknown" or "Charging". When the laptop is not plugged in,
|
||||
-- one or more of the batteries may be full, but only one battery
|
||||
-- discharging suffices to set global status to "Discharging".
|
||||
bat_now.status = bat_now.n_status[1]
|
||||
bat_now.status = bat_now.n_status[1] or "N/A"
|
||||
for _,status in ipairs(bat_now.n_status) do
|
||||
if status == "Discharging" or status == "Charging" then
|
||||
bat_now.status = status
|
||||
|
|
|
@ -126,14 +126,14 @@ local function factory(args)
|
|||
end
|
||||
|
||||
function cal.show(seconds, month, year, scr)
|
||||
cal.notification_preset.text = tconcat(cal.build(month, year))
|
||||
local text = tconcat(cal.build(month, year))
|
||||
|
||||
if cal.three then
|
||||
local current_month, current_year = cal.month, cal.year
|
||||
local prev_month, prev_year = cal.getdate(cal.month, cal.year, -1)
|
||||
local next_month, next_year = cal.getdate(cal.month, cal.year, 1)
|
||||
cal.notification_preset.text = string.format("%s\n\n%s\n\n%s",
|
||||
tconcat(cal.build(prev_month, prev_year)), cal.notification_preset.text,
|
||||
text = string.format("%s\n\n%s\n\n%s",
|
||||
tconcat(cal.build(prev_month, prev_year)), text,
|
||||
tconcat(cal.build(next_month, next_year)))
|
||||
cal.month, cal.year = current_month, current_year
|
||||
end
|
||||
|
@ -143,7 +143,8 @@ local function factory(args)
|
|||
preset = cal.notification_preset,
|
||||
screen = cal.followtag and awful.screen.focused() or scr or 1,
|
||||
icon = cal.icon,
|
||||
timeout = type(seconds) == "number" and seconds or cal.notification_preset.timeout or 5
|
||||
timeout = type(seconds) == "number" and seconds or cal.notification_preset.timeout or 5,
|
||||
text = text
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ local string = string
|
|||
-- lain.widget.contrib.moc
|
||||
|
||||
local function factory(args)
|
||||
local moc = { widget = wibox.widget.textbox() }
|
||||
local args = args or {}
|
||||
local moc = { widget = args.widget or wibox.widget.textbox() }
|
||||
local timeout = args.timeout or 2
|
||||
local music_dir = args.music_dir or os.getenv("HOME") .. "/Music"
|
||||
local cover_pattern = args.cover_pattern or "*\\.(jpg|jpeg|png|gif)$"
|
||||
|
|
|
@ -16,8 +16,8 @@ local tostring = tostring
|
|||
-- lain.widget.cpu
|
||||
|
||||
local function factory(args)
|
||||
local cpu = { core = {}, widget = wibox.widget.textbox() }
|
||||
local args = args or {}
|
||||
local cpu = { core = {}, widget = args.widget or wibox.widget.textbox() }
|
||||
local timeout = args.timeout or 2
|
||||
local settings = args.settings or function() end
|
||||
|
||||
|
|
|
@ -26,8 +26,9 @@ local query = query_size .. "," .. query_free .. "," .. query_used
|
|||
-- lain.widget.fs
|
||||
|
||||
local function factory(args)
|
||||
local args = args or {}
|
||||
local fs = {
|
||||
widget = wibox.widget.textbox(),
|
||||
widget = args.widget or wibox.widget.textbox(),
|
||||
units = {
|
||||
[1] = "Kb", [2] = "Mb", [3] = "Gb",
|
||||
[4] = "Tb", [5] = "Pb", [6] = "Eb",
|
||||
|
@ -50,7 +51,6 @@ local function factory(args)
|
|||
}
|
||||
end
|
||||
|
||||
local args = args or {}
|
||||
local timeout = args.timeout or 600
|
||||
local partition = args.partition
|
||||
local threshold = args.threshold or 99
|
||||
|
@ -69,11 +69,10 @@ local function factory(args)
|
|||
end
|
||||
|
||||
function fs.update()
|
||||
local notifytable = { [1] = string.format("%-10s %4s\t%6s\t%6s\t\n", "path", "used", "free", "size") }
|
||||
local pathlen = 10
|
||||
local maxpathidx = 1
|
||||
fs_now = {}
|
||||
|
||||
local notifypaths = {}
|
||||
for _, mount in ipairs(Gio.unix_mounts_get()) do
|
||||
local path = Gio.unix_mount_get_mount_path(mount)
|
||||
local root = Gio.File.new_for_path(path)
|
||||
|
@ -90,19 +89,16 @@ local function factory(args)
|
|||
fs_now[path] = {
|
||||
units = fs.units[units],
|
||||
percentage = math.floor(100 * used / size), -- used percentage
|
||||
size = size / math.pow(1024, math.floor(units)),
|
||||
used = used / math.pow(1024, math.floor(units)),
|
||||
free = free / math.pow(1024, math.floor(units))
|
||||
size = size / math.pow(1024, units),
|
||||
used = used / math.pow(1024, units),
|
||||
free = free / math.pow(1024, units)
|
||||
}
|
||||
|
||||
if fs_now[path].percentage > 0 then -- don't notify unused file systems
|
||||
notifytable[#notifytable+1] = string.format("\n%-10s %3s%%\t%6.2f\t%6.2f\t%s", path,
|
||||
math.floor(fs_now[path].percentage), fs_now[path].free, fs_now[path].size,
|
||||
fs_now[path].units)
|
||||
notifypaths[#notifypaths+1] = path
|
||||
|
||||
if #path > pathlen then
|
||||
pathlen = #path
|
||||
maxpathidx = #notifytable
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -125,14 +121,11 @@ local function factory(args)
|
|||
end
|
||||
end
|
||||
|
||||
if pathlen > 10 then -- if are there paths longer than 10 chars, reformat first column accordingly
|
||||
local pathspaces
|
||||
for i = 1, #notifytable do
|
||||
pathspaces = notifytable[i]:match("[ ]+")
|
||||
if i ~= maxpathidx and pathspaces then
|
||||
notifytable[i] = notifytable[i]:gsub(pathspaces, pathspaces .. string.rep(" ", pathlen - 10))
|
||||
end
|
||||
end
|
||||
local fmt = "%-" .. tostring(pathlen) .. "s %4s\t%6s\t%6s\n"
|
||||
local notifytable = { [1] = string.format(fmt, "path", "used", "free", "size") }
|
||||
fmt = "\n%-" .. tostring(pathlen) .. "s %3s%%\t%6.2f\t%6.2f %s"
|
||||
for _, path in ipairs(notifypaths) do
|
||||
notifytable[#notifytable+1] = string.format(fmt, path, fs_now[path].percentage, fs_now[path].free, fs_now[path].size, fs_now[path].units)
|
||||
end
|
||||
|
||||
fs.notification_preset.text = tconcat(notifytable)
|
||||
|
|
|
@ -17,8 +17,8 @@ local tonumber = tonumber
|
|||
-- lain.widget.imap
|
||||
|
||||
local function factory(args)
|
||||
local imap = { widget = wibox.widget.textbox() }
|
||||
local args = args or {}
|
||||
local imap = { widget = args.widget or wibox.widget.textbox() }
|
||||
local server = args.server
|
||||
local mail = args.mail
|
||||
local password = args.password
|
||||
|
|
|
@ -14,8 +14,8 @@ local gmatch, lines, floor = string.gmatch, io.lines, math.floor
|
|||
-- lain.widget.mem
|
||||
|
||||
local function factory(args)
|
||||
local mem = { widget = wibox.widget.textbox() }
|
||||
local args = args or {}
|
||||
local mem = { widget = args.widget or wibox.widget.textbox() }
|
||||
local timeout = args.timeout or 2
|
||||
local settings = args.settings or function() end
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ local string = string
|
|||
-- lain.widget.mpd
|
||||
|
||||
local function factory(args)
|
||||
local mpd = { widget = wibox.widget.textbox() }
|
||||
local args = args or {}
|
||||
local mpd = { widget = args.widget or wibox.widget.textbox() }
|
||||
local timeout = args.timeout or 2
|
||||
local password = (args.password and #args.password > 0 and string.format("password %s\\n", args.password)) or ""
|
||||
local host = args.host or os.getenv("MPD_HOST") or "127.0.0.1"
|
||||
|
|
|
@ -15,8 +15,8 @@ local string = string
|
|||
-- lain.widget.net
|
||||
|
||||
local function factory(args)
|
||||
local net = { widget = wibox.widget.textbox(), devices = {} }
|
||||
local args = args or {}
|
||||
local net = { widget = args.widget or wibox.widget.textbox(), devices = {} }
|
||||
local timeout = args.timeout or 2
|
||||
local units = args.units or 1024 -- KB
|
||||
local notify = args.notify or "on"
|
||||
|
@ -29,13 +29,14 @@ local function factory(args)
|
|||
net.iface = (args.iface and (type(args.iface) == "string" and {args.iface}) or
|
||||
(type(args.iface) == "table" and args.iface)) or {}
|
||||
|
||||
function net.get_device()
|
||||
function net.get_devices()
|
||||
net.iface = {} -- reset at every call
|
||||
helpers.line_callback("ip link", function(line)
|
||||
net.iface[#net.iface + 1] = not string.match(line, "LOOPBACK") and string.match(line, "(%w+): <") or nil
|
||||
end)
|
||||
end
|
||||
|
||||
if #net.iface == 0 then net.get_device() end
|
||||
if #net.iface == 0 then net.get_devices() end
|
||||
|
||||
function net.update()
|
||||
-- These are the totals over all specified interfaces
|
||||
|
@ -67,13 +68,19 @@ local function factory(args)
|
|||
dev_now.last_t = now_t
|
||||
dev_now.last_r = now_r
|
||||
|
||||
if wifi_state == "on" and helpers.first_line(string.format("/sys/class/net/%s/uevent", dev)) == "DEVTYPE=wlan" and string.match(dev_now.carrier, "1") then
|
||||
if wifi_state == "on" and helpers.first_line(string.format("/sys/class/net/%s/uevent", dev)) == "DEVTYPE=wlan" then
|
||||
dev_now.wifi = true
|
||||
dev_now.signal = tonumber(string.match(helpers.lines_from("/proc/net/wireless")[3], "(%-%d+%.)")) or nil
|
||||
if string.match(dev_now.carrier, "1") then
|
||||
dev_now.signal = tonumber(string.match(helpers.lines_from("/proc/net/wireless")[3], "(%-%d+%.)")) or nil
|
||||
end
|
||||
else
|
||||
dev_now.wifi = false
|
||||
end
|
||||
|
||||
if eth_state == "on" and helpers.first_line(string.format("/sys/class/net/%s/uevent", dev)) ~= "DEVTYPE=wlan" and string.match(dev_now.carrier, "1") then
|
||||
if eth_state == "on" and helpers.first_line(string.format("/sys/class/net/%s/uevent", dev)) ~= "DEVTYPE=wlan" then
|
||||
dev_now.ethernet = true
|
||||
else
|
||||
dev_now.ethernet = false
|
||||
end
|
||||
|
||||
net.devices[dev] = dev_now
|
||||
|
|
|
@ -15,8 +15,8 @@ local type = type
|
|||
-- lain.widget.pulse
|
||||
|
||||
local function factory(args)
|
||||
local pulse = { widget = wibox.widget.textbox(), device = "N/A" }
|
||||
local args = args or {}
|
||||
local pulse = { widget = args.widget or wibox.widget.textbox(), device = "N/A" }
|
||||
local timeout = args.timeout or 5
|
||||
local settings = args.settings or function() end
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ local open, match = io.open, string.match
|
|||
-- lain.widget.sysload
|
||||
|
||||
local function factory(args)
|
||||
local sysload = { widget = wibox.widget.textbox() }
|
||||
local args = args or {}
|
||||
local sysload = { widget = args.widget or wibox.widget.textbox() }
|
||||
local timeout = args.timeout or 2
|
||||
local settings = args.settings or function() end
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ local tonumber = tonumber
|
|||
-- lain.widget.temp
|
||||
|
||||
local function factory(args)
|
||||
local temp = { widget = wibox.widget.textbox() }
|
||||
local args = args or {}
|
||||
local temp = { widget = args.widget or wibox.widget.textbox() }
|
||||
local timeout = args.timeout or 30
|
||||
local tempfile = args.tempfile or "/sys/devices/virtual/thermal/thermal_zone0/temp"
|
||||
local settings = args.settings or function() end
|
||||
|
|
|
@ -21,13 +21,13 @@ local tonumber = tonumber
|
|||
-- lain.widget.weather
|
||||
|
||||
local function factory(args)
|
||||
local weather = { widget = wibox.widget.textbox() }
|
||||
local args = args or {}
|
||||
local weather = { widget = args.widget or wibox.widget.textbox() }
|
||||
local APPID = args.APPID or "3e321f9414eaedbfab34983bda77a66e" -- lain's default
|
||||
local timeout = args.timeout or 60 * 15 -- 15 min
|
||||
local timeout_forecast = args.timeout or 60 * 60 * 24 -- 24 hrs
|
||||
local current_call = args.current_call or "curl -s 'http://api.openweathermap.org/data/2.5/weather?id=%s&units=%s&lang=%s&APPID=%s'"
|
||||
local forecast_call = args.forecast_call or "curl -s 'http://api.openweathermap.org/data/2.5/forecast/daily?id=%s&units=%s&lang=%s&cnt=%s&APPID=%s'"
|
||||
local current_call = args.current_call or "curl -s 'https://api.openweathermap.org/data/2.5/weather?id=%s&units=%s&lang=%s&APPID=%s'"
|
||||
local forecast_call = args.forecast_call or "curl -s 'https://api.openweathermap.org/data/2.5/forecast/daily?id=%s&units=%s&lang=%s&cnt=%s&APPID=%s'"
|
||||
local city_id = args.city_id or 0 -- placeholder
|
||||
local units = args.units or "metric"
|
||||
local lang = args.lang or "en"
|
||||
|
|
Loading…
Reference in New Issue