mirror of
https://github.com/elenapan/dotfiles.git
synced 2025-12-26 15:14:58 +08:00
20 lines
615 B
Lua
20 lines
615 B
Lua
-- Provides:
|
|
-- evil::ram
|
|
-- used (integer - mega bytes)
|
|
-- total (integer - mega bytes)
|
|
local awful = require("awful")
|
|
|
|
local update_interval = 20
|
|
-- Returns the used amount of ram in percentage
|
|
local ram_script = [[
|
|
sh -c "
|
|
free -m | grep 'Mem:' | awk '{printf \"%d@@%d@\", $7, $2}'
|
|
"]]
|
|
|
|
-- Periodically get ram info
|
|
awful.widget.watch(ram_script, update_interval, function(widget, stdout)
|
|
local available = stdout:match('(.*)@@')
|
|
local total = stdout:match('@@(.*)@')
|
|
local used = tonumber(total) - tonumber(available)
|
|
awesome.emit_signal("evil::ram", used, tonumber(total))
|
|
end)
|