Skip to content

Instantly share code, notes, and snippets.

@imabuddha
Created January 18, 2021 08:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imabuddha/1bdd1b0950860646fc914bd4e1d8fb70 to your computer and use it in GitHub Desktop.
Save imabuddha/1bdd1b0950860646fc914bd4e1d8fb70 to your computer and use it in GitHub Desktop.
awful.widget.watch use case examples from: https://awesomewm.org/recipes/watch/

iostat

-- disk I/O using iostat from sysstat utilities
local iotable = {}
local iostat = awful.widget.watch("iostat -dk", 2, -- in Kb, use -dm for Mb
    function(widget, stdout)
        for line in stdout:match("(sd.*)\n"):gmatch("(.-)\n") do
            local device, tps, read_s, wrtn_s, read, wrtn =
            line:match("(%w+)%s*(%d+,?%d*)%s*(%d+,?%d*)%s*(%d+,?%d*)%s*(%d+,?%d*)%s*(%d+,?%d*)")
            --                  [1]  [2]     [3]     [4]   [5]
            iotable[device] = { tps, read_s, wrtn_s, read, wrtn }
        end

        -- customize here
        widget:set_text("sda: "..iotable["sda"][2].."/"..iotable["sda"][3]) -- read_s/wrtn_s
    end
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment