From c7cd13e93c1a8d693ea524cc0642064cebf6fb44 Mon Sep 17 00:00:00 2001 From: Son Pham Date: Tue, 20 Aug 2013 23:50:33 -0500 Subject: [PATCH] fshwidget: fallback to / if /home is not a separate partition --- rc.lua.blackburn | 10 ++++++---- rc.lua.dremora | 10 ++++++---- rc.lua.holo | 10 ++++++---- rc.lua.multicolor | 14 ++++++++------ rc.lua.powerarrow-darker | 14 ++++++++------ rc.lua.rainbow | 8 +++++--- rc.lua.steamburn | 8 +++++--- 7 files changed, 44 insertions(+), 30 deletions(-) diff --git a/rc.lua.blackburn b/rc.lua.blackburn index ff4be96..1e0455e 100755 --- a/rc.lua.blackburn +++ b/rc.lua.blackburn @@ -369,16 +369,18 @@ fshwidget = wibox.widget.textbox() too_much = false vicious.register(fshwidget, vicious.widgets.fs, function (widget, args) - if ( args["{/home used_p}"] >= 90 ) then - if ( args["{/home used_p}"] >= 99 and too_much == false ) then - naughty.notify({ title = "Warning", text = "/home partition ran out!\nmake some room", + -- used percent of /home if it is on a separate partition, else fallback to / + used_percent = args["{/home used_p}"] or args["{/ used_p}"] + if ( used_percent >= 90 ) then + if ( used_percent >= 99 and too_much == false ) then + naughty.notify({ title = "Warning", text = "hdd ran out!\nmake some room", timeout = 7, position = "top_right", fg = beautiful.fg_urgent, bg = beautiful.bg_urgent }) too_much = true end - return gray .. " Hdd " .. coldef .. white .. args["{/home used_p}"] .. coldef .. " " + return gray .. " Hdd " .. coldef .. white .. used_percent .. coldef .. " " else return "" end diff --git a/rc.lua.dremora b/rc.lua.dremora index dd9bf78..fe2ed7d 100755 --- a/rc.lua.dremora +++ b/rc.lua.dremora @@ -295,16 +295,18 @@ fshwidget = wibox.widget.textbox() too_much = false vicious.register(fshwidget, vicious.widgets.fs, function (widget, args) - if ( args["{/home used_p}"] >= 90 ) then - if ( args["{/home used_p}"] >= 99 and too_much == false ) then - naughty.notify({ title = "warning", text = "/home partition ran out!\nmake some room", + -- used percent of /home if it is on a separate partition, else fallback to / + used_percent = args["{/home used_p}"] or args["{/ used_p}"] + if ( used_percent >= 90 ) then + if ( used_percent >= 99 and too_much == false ) then + naughty.notify({ title = "warning", text = "hdd ran out!\nmake some room", timeout = 7, position = "top_right", fg = beautiful.fg_urgent, bg = beautiful.bg_urgent }) too_much = true end - return gray .. " Hdd " .. coldef .. white .. args["{/home used_p}"] .. coldef .. " " + return gray .. " Hdd " .. coldef .. white .. used_percent .. coldef .. " " else return "" end diff --git a/rc.lua.holo b/rc.lua.holo index 6f2ff60..73e8b7b 100755 --- a/rc.lua.holo +++ b/rc.lua.holo @@ -356,16 +356,18 @@ fshwidget = wibox.widget.textbox() too_much = false vicious.register(fshwidget, vicious.widgets.fs, function (widget, args) - if ( args["{/home used_p}"] >= 90 ) then - if ( args["{/home used_p}"] >= 99 and too_much == false ) then - naughty.notify({ title = "warning", text = "/home partition ran out!\nmake some room", + -- used percent of /home if it is on a separate partition, else fallback to / + used_percent = args["{/home used_p}"] or args["{/ used_p}"] + if ( used_percent >= 90 ) then + if ( used_percent >= 99 and too_much == false ) then + naughty.notify({ title = "warning", text = "hdd ran out!\nmake some room", timeout = 7, position = "top_right", fg = beautiful.fg_urgent, bg = beautiful.bg_urgent }) too_much = true end - return white .. " Hdd " .. coldef .. blue .. args["{/home used_p}"] .. coldef .. " " + return white .. " Hdd " .. coldef .. blue .. used_percent .. coldef .. " " else return "" end diff --git a/rc.lua.multicolor b/rc.lua.multicolor index 8e1653e..2477d25 100755 --- a/rc.lua.multicolor +++ b/rc.lua.multicolor @@ -303,17 +303,19 @@ fshicon:set_image(theme.confdir .. "/widgets/fs.png") fshwidget = wibox.widget.textbox() vicious.register(fshwidget, vicious.widgets.fs, function (widget, args) - if args["{/home used_p}"] >= 95 and args["{/home used_p}"] < 99 then - return colwhi .. args["{/home used_p}"] .. "%" .. coldef - elseif args["{/home used_p}"] >= 99 and args["{/home used_p}"] <= 100 then - naughty.notify({ title = "warning", text = "/home partition ran out!\nmake some room", + -- used percent of /home if it is on a separate partition, else fallback to / + used_percent = args["{/home used_p}"] or args["{/ used_p}"] + if used_percent >= 95 and used_percent < 99 then + return colwhi .. used_percent .. "%" .. coldef + elseif used_percent >= 99 and used_percent <= 100 then + naughty.notify({ title = "warning", text = "hdd ran out!\nmake some room", timeout = 10, position = "top_right", fg = beautiful.fg_urgent, bg = beautiful.bg_urgent }) - return colwhi .. args["{/home used_p}"] .. "%" .. coldef + return colwhi .. used_percent .. "%" .. coldef else - return azure .. args["{/home used_p}"] .. "%" .. coldef + return azure .. used_percent .. "%" .. coldef end end, 620) diff --git a/rc.lua.powerarrow-darker b/rc.lua.powerarrow-darker index 67bb73c..2145e70 100755 --- a/rc.lua.powerarrow-darker +++ b/rc.lua.powerarrow-darker @@ -353,17 +353,19 @@ fshicon:set_image(beautiful.widget_hdd) fshwidget = wibox.widget.textbox() vicious.register(fshwidget, vicious.widgets.fs, function (widget, args) - if args["{/home used_p}"] >= 95 and args["{/home used_p}"] < 99 then - return ' ' .. args["{/home used_p}"] .. '% ' - elseif args["{/home used_p}"] >= 99 and args["{/home used_p}"] <= 100 then - naughty.notify({ title = "warning", text = "/home partition ran out!\nmake some room", + -- used percent of /home if it is on a separate partition, else fallback to / + used_percent = args["{/home used_p}"] or args["{/ used_p}"] + if used_percent >= 95 and used_percent < 99 then + return ' ' .. used_percent .. '% ' + elseif used_percent >= 99 and used_percent <= 100 then + naughty.notify({ title = "warning", text = "hdd ran out!\nmake some room", timeout = 10, position = "top_right", fg = beautiful.fg_urgent, bg = beautiful.bg_urgent }) - return ' ' .. args["{/home used_p}"] .. '% ' + return ' ' .. used_percent .. '% ' else - return ' ' .. args["{/home used_p}"] .. '% ' + return ' ' .. used_percent .. '% ' end end, 600) diff --git a/rc.lua.rainbow b/rc.lua.rainbow index 83b6a44..ee662ed 100755 --- a/rc.lua.rainbow +++ b/rc.lua.rainbow @@ -331,8 +331,10 @@ fshwidget = wibox.widget.textbox() too_much = false vicious.register(fshwidget, vicious.widgets.fs, function (widget, args) - if ( args["{/home used_p}"] >= 90 ) then - if ( args["{/home used_p}"] >= 99 and too_much == false ) then + -- used percent of /home if it is on a separate partition, else fallback to / + used_percent = args["{/home used_p}"] or args["{/ used_p}"] + if ( used_percent >= 90 ) then + if ( used_percent >= 99 and too_much == false ) then naughty.notify({ title = "Attenzione", text = "Partizione /home esaurita!\nFa' un po' di spazio.", timeout = 7, position = "top_right", @@ -340,7 +342,7 @@ function (widget, args) bg = beautiful.bg_urgent }) too_much = true end - return gray .. " Hdd " .. coldef .. white .. args["{/home used_p}"] .. coldef .. " " + return gray .. " Hdd " .. coldef .. white .. used_percent .. coldef .. " " else return "" end diff --git a/rc.lua.steamburn b/rc.lua.steamburn index 967dd32..edbac95 100755 --- a/rc.lua.steamburn +++ b/rc.lua.steamburn @@ -340,14 +340,16 @@ vicious.register(tempwidget, vicious.widgets.thermal, gray .. "Temp " .. coldef fshwidget = wibox.widget.textbox() vicious.register(fshwidget, vicious.widgets.fs, function (widget, args) - if ( args["{/home used_p}"] >= 99 ) then - naughty.notify({ title = "warning", text = "/home partition ran out!\nmake some room", + -- used percent of /home if it is on a separate partition, else fallback to / + used_percent = args["{/home used_p}"] or args["{/ used_p}"] + if ( used_percent >= 99 ) then + naughty.notify({ title = "warning", text = "hdd ran out!\nmake some room", timeout = 10, position = "top_right", fg = beautiful.fg_urgent, bg = beautiful.bg_urgent }) end - return gray .. "Hdd " .. coldef .. white .. args["{/home used_p}"] .. coldef + return gray .. "Hdd " .. coldef .. white .. used_percent .. coldef end, 600) local infos = nil