widget.fs: assure that each processed partition has non nil infos; awesome-copycats #225

This commit is contained in:
Luca CPZ 2018-02-25 23:17:09 +01:00
parent 92d17d289c
commit be9ae6862f

View file

@ -74,6 +74,8 @@ local function factory(args)
local path = Gio.unix_mount_get_mount_path(mount) local path = Gio.unix_mount_get_mount_path(mount)
local root = Gio.File.new_for_path(path) local root = Gio.File.new_for_path(path)
local info = root:query_filesystem_info(query) local info = root:query_filesystem_info(query)
if info then
local size = info:get_attribute_uint64(query_size) local size = info:get_attribute_uint64(query_size)
local used = info:get_attribute_uint64(query_used) local used = info:get_attribute_uint64(query_used)
local free = info:get_attribute_uint64(query_free) local free = info:get_attribute_uint64(query_free)
@ -89,14 +91,14 @@ local function factory(args)
free = free / math.pow(1024, math.floor(units)) free = free / math.pow(1024, math.floor(units))
} }
-- don't notify unused file systems if fs_now[path].percentage > 0 then -- don't notify unused file systems
if fs_now[path].percentage > 0 then
notifytable[#notifytable+1] = sformat("\n%-10s %-5s %3.2f\t%3.2f\t%s", path, notifytable[#notifytable+1] = sformat("\n%-10s %-5s %3.2f\t%3.2f\t%s", path,
fs_now[path].percentage .. "%", fs_now[path].free, fs_now[path].size, fs_now[path].percentage .. "%", fs_now[path].free, fs_now[path].size,
fs_now[path].units) fs_now[path].units)
end end
end end
end end
end
widget = fs.widget widget = fs.widget
settings() settings()