Module giblets.gizmos.diskusage
DiskUsage gizmo.
Displays an icon that when clicked shows a floating wibox populated with a
configurable set of mount points and their usage stats. The icon itself is
a wibox.widget so all the standard functions are available.
Info:
- Copyright: 2015 Nathan Lundquist
- Author: Nathan Lundquist (atatsu)
Functions
| DiskUsage.new (icon, mounts[, opts]) | Create a new diskusage gizmo. |
| DiskUsage:hide () | Hide the diskusage window. |
| DiskUsage:refresh () | Refreshes the mount point stats. |
| DiskUsage:set_background_color (color) | Set the background color of the diskusage window. |
| DiskUsage:set_border_color ([color="#000000"]) | Set the border color of the diskusage window. |
| DiskUsage:set_border_width ([width=0]) | Set the border width of the diskusage window. |
| DiskUsage:set_foreground_color (color) | Set the foreground color of the diskusage window. |
| DiskUsage:set_height ([height=400]) | Set the height of the diskusage window. |
| DiskUsage:set_progressbar ([progressbar=giblets.widgets.progressbar]) | Set the type of progressbar that gets used for representing the use % of the mount point. |
| DiskUsage:set_stats_format (format) | Set the format of the stats text display. |
| DiskUsage:set_width ([width=400]) | Set the width of the diskusage window. |
| DiskUsage:show () | Show the diskusage window. |
| DiskUsage:toggle () | Show the diskusage window if it is hidden, or hide it if it is shown. |
| DiskUsage:tune_progressbars (callback) | Allows you to tweak the properties of the diskusage progressbars. |
Tables
| opts | DiskUsage options. |
Functions
- DiskUsage.new (icon, mounts[, opts])
-
Create a new diskusage gizmo.
Parameters:
- icon string or cairoimage Either the path to an image file or a cairo image surface.
- mounts
table
A table of tables containing the keys
mountandlabel, withlabelbeing optional. If nolabelis supplied the mount point itself will be used. For instance,{{mount = "/home/me", label = "home"}, {mount = "/var", label = "var"}}. - opts table Options for controlling the look of the diskusage gizmo. For a break down of all available options and their default values see opts. There are corresponding methods for each option, if you'd rather use those. (optional)
Returns:
-
DiskUsage
A new DiskUsage instance.
Raises:
- 'mounts' argument must be a table
- Invalid 'mounts' argument supplied
- Not a progressbar constructor
See also:
Usage:
local giblets = require("giblets") local du = giblets.gizmos.diskusage( beautiful.du_icon, {{mount = "/home", label = "home"}, {mount = "/var", label = "var"}} )
- DiskUsage:hide ()
-
Hide the diskusage window.
Signals:
-
property::visible
Returns:
-
The diskusage instance.
Usage:
du:hide()
- DiskUsage:refresh ()
-
Refreshes the mount point stats.
Returns:
-
The diskusage instance.
Usage:
du:refresh()
- DiskUsage:set_background_color (color)
-
Set the background color of the diskusage window.
Since the diskusage "window" is merely a wibox the background color will
default to
bg_normalif set in your theme file.Signals:
-
property::background_color
Parameters:
- color string Background color of the diskusage window.
Returns:
-
The diskusage instance.
Usage:
du:set_background_color("#222222") - DiskUsage:set_border_color ([color="#000000"])
-
Set the border color of the diskusage window.
Signals:
-
property::border_color
Parameters:
- color string Color of the border. (default "#000000")
Returns:
-
The diskusage instance.
Usage:
du:set_border_color("#ff0000") - DiskUsage:set_border_width ([width=0])
-
Set the border width of the diskusage window.
Signals:
-
property::border_width
Parameters:
- width int Pixel width of the border. (default 0)
Returns:
-
The diskusage instance.
Usage:
du:set_border_width(2) - DiskUsage:set_foreground_color (color)
-
Set the foreground color of the diskusage window.
Since the diskusage "window" is merely a wibox the foreground color will
default to
fg_normalif set in your theme file.Signals:
-
property::foreground_color
Parameters:
- color string Foreground color of the diskusage window.
Returns:
-
The diskusage instance.
Usage:
du:set_foreground_color("ffffff") - DiskUsage:set_height ([height=400])
-
Set the height of the diskusage window.
Signals:
-
property::height
Parameters:
- height int Pixel height of the diskusage window. (default 400)
Returns:
-
The diskusage instance.
Usage:
du:set_height(350) - DiskUsage:set_progressbar ([progressbar=giblets.widgets.progressbar])
-
Set the type of progressbar that gets used for representing the use % of the mount point.
Remember this must be a progressbar constructor. Not an instantiated progressbar.
Signals:
-
property::progressbar
Parameters:
- progressbar
table
The progressbar constructor supporting
all functions provided by
awful.widget.progressbar. (default giblets.widgets.progressbar)
Returns:
-
The diskusage instance.
Raises:
Not a progressbar constructorUsage:
du:set_progressbar(awful.widget.progressbar)
- progressbar
table
The progressbar constructor supporting
all functions provided by
- DiskUsage:set_stats_format (format)
-
Set the format of the stats text display.
The available replacement tokens and their corresponding stat is as follows:$1- Mount point (or label if a label was specified$2- Total size of the mount point$3- Used amount of the mount point$4- Available space remaining on the mount point
Signals:
-
property::stats_format
Parameters:
- format string Format string. (default "$1 -- $4 free of $2, $3 used")
Returns:
-
The diskusage instance.
Usage:
du:set_stats_format("$1 - $3/$2 ($4)") - DiskUsage:set_width ([width=400])
-
Set the width of the diskusage window.
Signals:
-
property::width
Parameters:
- width int Pixel width of the diskusage window. (default 400)
Returns:
-
The diskusage instance.
Usage:
du:set_width(600) - DiskUsage:show ()
-
Show the diskusage window.
Signals:
-
property::visible
Returns:
-
The diskusage instance.
Usage:
du:show()
- DiskUsage:toggle ()
-
Show the diskusage window if it is hidden, or hide it if it is shown.
Signals:
-
property::visible
Returns:
-
The diskusage instance.
Usage:
du:toggle()
- DiskUsage:tune_progressbars (callback)
-
Allows you to tweak the properties of the diskusage progressbars.
Invokes the provided callback for every configured mount point, passing the
progressbar and mount path, respectively.
Parameters:
- callback
func
A callback function that the progressbar widget and mount path
will be passed to. Callback signature:
function(progressbar, mount_path).
Returns:
-
The diskusage instance.
Raises:
'callback' must be a functionUsage:
du:tune_progressbars(function(progressbar, mount_path) if mount_path == "/home" then progressbar:set_background_color("#ff0000") else progressbar:set_background_color("#000000") end end)
- callback
func
A callback function that the progressbar widget and mount path
will be passed to. Callback signature:
Tables
- opts
-
DiskUsage options.
Fields:
- width int Width of the diskusage window. (default 400)
- height int Height of the diskusage window. (default 400)
- progressbar
table
The constructor for a progressbar widget
supporting the functions provided by
awful.widget.progressbar. This is used to represent the use % of the mount point. (default giblets.widgets.progressbar) - border_width int Sets the border width of the diskusage window. (default 0)
- border_color string Sets the color of the diskusage window border. (default "#000000")
- background_color string Sets the background color of the diskusage window. (optional)
- foreground_color string Sets the foreground color of the diskusage window. (optional)
- stats_format
string
Sets the format of the
stats text display. The available replacement tokens and their corresponding
stat is as follows:
$1- Mount point (or label if a label was specified$2- Total size of the mount point$3- Used amount of the mount point$4- Available space remaining on the mount point
(default "$1 -- $4 free of $2, $3 used") (optional)