mirror of
https://github.com/elenapan/dotfiles.git
synced 2026-01-10 11:12:37 +08:00
Former-commit-id: 9d27077226ed0b65d857184ac61d556aae929eca Former-commit-id: 6683c18030af3da534b8d010b44fea577d5f1ab2 Former-commit-id: 12f11729e4f0f1fc343fe76c7ee2a8b5bf4491a0 Former-commit-id: 56fea3fbf6f672c41a2fc08936762dd67cfa0d73
23 lines
796 B
Lua
23 lines
796 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
|
|
-- TODO output of free is affected by system language. The following command
|
|
-- works for any language:
|
|
-- free -m | sed -n '2p' | awk '{printf "%d available out of %d\n", $7, $2}'
|
|
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)
|