mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-23 10:18:34 +02:00
widgets: guess display name for a given mountpoint
This commit is contained in:
parent
98a8885069
commit
9de7485159
1 changed files with 11 additions and 7 deletions
|
@ -188,25 +188,29 @@ volwidget:buttons(awful.util.table.join(
|
||||||
awful.button({ }, 5, volume.decrease)))
|
awful.button({ }, 5, volume.decrease)))
|
||||||
|
|
||||||
-- File systems
|
-- File systems
|
||||||
local fs = { ["/"] = "root",
|
local fs = { "/",
|
||||||
["/home"] = "home",
|
"/home",
|
||||||
["/var"] = "var",
|
"/var",
|
||||||
["/usr"] = "usr",
|
"/usr",
|
||||||
["/tmp"] = "tmp",
|
"/tmp",
|
||||||
["/var/cache/build"] = "pbuilder" }
|
"/var/cache/build",
|
||||||
|
"/var/lib/mongodb",
|
||||||
|
"/var/lib/systems" }
|
||||||
local fsicon = widget({ type = "imagebox" })
|
local fsicon = widget({ type = "imagebox" })
|
||||||
fsicon.image = image(beautiful.icons .. "/widgets/disk.png")
|
fsicon.image = image(beautiful.icons .. "/widgets/disk.png")
|
||||||
local fswidget = widget({ type = "textbox" })
|
local fswidget = widget({ type = "textbox" })
|
||||||
vicious.register(fswidget, vicious.widgets.fs,
|
vicious.register(fswidget, vicious.widgets.fs,
|
||||||
function (widget, args)
|
function (widget, args)
|
||||||
local result = ""
|
local result = ""
|
||||||
for path, name in pairs(fs) do
|
for _, path in pairs(fs) do
|
||||||
local used = args["{" .. path .. " used_p}"]
|
local used = args["{" .. path .. " used_p}"]
|
||||||
local color = beautiful.fg_widget_value
|
local color = beautiful.fg_widget_value
|
||||||
if used then
|
if used then
|
||||||
if used > 90 then
|
if used > 90 then
|
||||||
color = beautiful.fg_widget_value_important
|
color = beautiful.fg_widget_value_important
|
||||||
end
|
end
|
||||||
|
local name = string.gsub(path, "[%w/]*/(%w+)", "%1")
|
||||||
|
if name == "/" then name = "root" end
|
||||||
result = string.format(
|
result = string.format(
|
||||||
'%s%s<span color="' .. beautiful.fg_widget_label .. '">%s: </span>' ..
|
'%s%s<span color="' .. beautiful.fg_widget_label .. '">%s: </span>' ..
|
||||||
'<span color="' .. color .. '">%2d%%</span>',
|
'<span color="' .. color .. '">%2d%%</span>',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue