Взял я виджет от ram и вставил в него другие cmd. На максимальной загрузке io значек показывает 50% красного, а не 100%, а при клике показывает 100% красного. Где я ошибся? Вроде по аналогии из ram виджета делаю:)
cat ~/.config/awesome/test.sh
device_name=/dev/sda
col_num=`iostat -xd | fgrep '%util' | sed -r 's/\s+/\n/g' | cat -n | fgrep '%util' | egrep -o '[0-9]+'`
LANG=C iostat -xd "$device_name" 1 2 | grep "^${device_name##*/}[[:space:]]" | tail -n 1 | awk '{print($'$col_num');}'
local awful = require("awful")
local beautiful = require("beautiful")
local gears = require("gears")
local watch = require("awful.widget.watch")
local wibox = require("wibox")
local ramgraph_widget = {}
local function worker(user_args)
local args = user_args or {}
local timeout = args.timeout or 1
local color_used = args.color_used or beautiful.bg_urgent
local color_free = args.color_free or beautiful.fg_normal
local color_buf = args.color_buf or beautiful.border_color_active
local widget_show_buf = args.widget_show_buf or false
--- Main ram widget shown on wibar
ramgraph_widget = wibox.widget {
border_width = 0,
colors = {
color_used,
color_free,
color_buf,
},
display_labels = false,
forced_width = 25,
widget = wibox.widget.piechart
}
--- Widget which is shown when user clicks on the ram widget
local popup = awful.popup{
ontop = true,
visible = false,
widget = {
widget = wibox.widget.piechart,
forced_height = 200,
forced_width = 400,
colors = {
color_used,
color_free,
color_buf, -- buf_cache
},
},
shape = gears.shape.rounded_rect,
border_color = beautiful.border_color_active,
border_width = 1,
offset = { y = 5 },
}
--luacheck:ignore 231
local total, used, free, shared, buff_cache, available, total_swap, used_swap, free_swap
local function getPercentage(value)
return math.floor(value / (total+total_swap) * 100 + 0.5) .. '%'
end
-- res = awful.spawn.with_shell("~/.config/awesome/test.sh")
watch('bash -c "~/.config/awesome/test.sh"', timeout,
function(widget, stdout)
used = stdout:match('(%S+)')
if widget_show_buf then
widget.data = { used }
else
widget.data = { used, 100.00 }
end
if popup.visible then
popup:get_widget().data_list = {
{'used ' .. used, 100.00}
}
end
end,
ramgraph_widget
)
ramgraph_widget:buttons(
awful.util.table.join(
awful.button({}, 1, function()
popup:get_widget().data_list = {
{'used ' .. used, 100.00}
}
if popup.visible then
popup.visible = not popup.visible
else
popup:move_next_to(mouse.current_widget_geometry)
end
end)
)
)
return ramgraph_widget
end
return setmetatable(ramgraph_widget, { __call = function(_, ...)
return worker(...)
end })