-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fs: pure dfs implementation #272
Comments
By 'pure Lua' implementation you mean "No parsing |
No parsing at all, but using Lua and Awesome APIs. I was thinking about a wibox to toggle, filled with progress bars. |
I'm not yet sure how to get a list of mount points, but at least this is how you can get some disk usage: gio = require("lgi").Gio
file = gio.File.new_for_path(".")
size, free, used = gio.FILE_ATTRIBUTE_FILESYSTEM_SIZE, gio.FILE_ATTRIBUTE_FILESYSTEM_FREE, gio.FILE_ATTRIBUTE_FILESYSTEM_USED
query = size..","..free..","..used
info = file:query_filesystem_info(query)
print(info:get_attribute_uint64(size), info:get_attribute_uint64(free), info:get_attribute_uint64(used)) |
I can only offer the following, but it does not list all mount points, only some (yes, I know that this queries free but does not use it): local Gio = require("lgi").Gio
local volume_monitor = Gio.VolumeMonitor.get()
local query_size = Gio.FILE_ATTRIBUTE_FILESYSTEM_SIZE
local query_free = Gio.FILE_ATTRIBUTE_FILESYSTEM_FREE
local query_used = Gio.FILE_ATTRIBUTE_FILESYSTEM_USED
local query = query_size .. "," .. query_free .. "," .. query_used
for _, mount in ipairs(volume_monitor:get_mounts()) do
local root = mount:get_root()
local info = root:query_filesystem_info(query)
local size = info:get_attribute_uint64(query_size)
local free = info:get_attribute_uint64(query_free)
local used = info:get_attribute_uint64(query_used)
local percentage = 100 * used / size
print(string.format("%s '%s' has %.3f%% used", root:get_path(), mount:get_name(), percentage))
end Output:
|
Do we have any progress on this? Currently I'm experiencing problems with the notification pop-up.
|
@copycat-killer this started happening after upgrading to awesome 4.0. Don't know why yet. I'll open another issue on it. |
The `sh` on e.g. Debian is `dash`, but the script requires bash features by using `+=`. Until lcpz#272 is complete I think this is the best way to ensure that dfs works by default (excluding the gawk requirement).
There's also this API local Gio = require("lgi").Gio
for _, m in ipairs(Gio.unix_mounts_get()) do
print(Gio.unix_mount_get_mount_path(m))
end which seems to return everything
Contrast that to #272 (comment) which outputs nothing for me for some reason. |
@otommod Thanks for finding that. Here is it incorporated into the script from my last comment: local Gio = require("lgi").Gio
local query_size = Gio.FILE_ATTRIBUTE_FILESYSTEM_SIZE
local query_free = Gio.FILE_ATTRIBUTE_FILESYSTEM_FREE
local query_used = Gio.FILE_ATTRIBUTE_FILESYSTEM_USED
local query = query_size .. "," .. query_free .. "," .. query_used
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)
local info = root:query_filesystem_info(query)
local size = info:get_attribute_uint64(query_size)
local free = info:get_attribute_uint64(query_free)
local used = info:get_attribute_uint64(query_used)
local percentage = 100 * used / size
print(string.format("%s has %.3f%% used (%d used of %d)", path, percentage, used, size))
end |
Closed by mistake. Reopening. |
Done. Also, new API introduced. Read the wiki. |
Remove
scripts/
definitely and switch to a pure Lua implementation.The text was updated successfully, but these errors were encountered: