Skip to content
dodo edited this page Apr 7, 2012 · 4 revisions

install it

clone the repository into your awesomerc folder:

cd $XDG_CONFIG_HOME/awesome/
git clone http://git.sysphere.org/vicious
git clone git://github.com/dodo/uzful.git

in the awesome/rc.lua

import it:

-- utils Library
require("uzful")

enable vicious auto-caching:

uzful.util.patch.vicious()

uzful widgets overview

note: i use myinfobox = { net = {}, cpu = {}, cal = {}, bat = {} } as container for all my infoboxes.

cpu graphs

create it:

mycpugraphs = uzful.widget.cpugraphs({
    fgcolor = "#D0752A", bgcolor = theme.bg_normal,
    load = { interval = 20,
        text = ' <span size="x-small"><span color="#666666">$1</span>' ..
               '  <span color="#9A9A9A">$2</span>' ..
               '  <span color="#DDDDDD">$3</span></span>' },
    big = { width = 161, height = 42, interval = 1 },
    small = { width = 42, height = theme.menu_height, interval = 1 } })

bring it on a screen:

myinfobox.cpu = uzful.widget.infobox({
        position = "top", align = "right",
        widget = mycpugraphs.big.layout,
        height = mycpugraphs.big.height,
        width = mycpugraphs.big.width })

(don't forget to add mycpugraphs.small.widget to the wibox layout)

toggle visibility:

mycpugraphs.small.widget:connect_signal("mouse::enter", function ()
    if detailed_graphs.visible() then
        myinfobox.cpu:update()
        myinfobox.cpu:show()
    end
end)
mycpugraphs.small.widget:connect_signal("mouse::leave", myinfobox.cpu.hide)

net graphs

create it:

-- net usage graphs
mynetgraphs = uzful.widget.netgraphs({ default = "wlan0",
    up_fgcolor = "#D00003", down_fgcolor = "#95D043",
    highlight = ' <span size="x-small"><b>$1</b></span>',
    normal    = ' <span color="#666666" size="x-small">$1</span>',
    big = { width = 161, height = 42, interval = 2, scale = "kb" },
    small = { width = 23, height = theme.menu_height, interval = 2 } })

mynetgraphs.small.layout:connect_signal("button::release", mynetgraphs.switch)

bring it to a screen:

myinfobox.net = uzful.widget.infobox({
        position = "top", align = "right",
        widget = mynetgraphs.big.layout,
        height = mynetgraphs.big.height,
        width = mynetgraphs.big.width })

(don't forget to add mynetgraphs.small.layout to the wibox layout)

toggle visibility:

mynetgraphs.small.layout:connect_signal("mouse::enter", function ()
    if detailed_graphs.visible() then
        myinfobox.net:update()
        myinfobox.net:show()
    end
end)
mynetgraphs.small.widget:connect_signal("mouse::leave", myinfobox.net.hide)

battery progressbar

create it:

-- Battery Progressbar
mybat = uzful.widget.progressimage(
    { x = 3, y = 4, width = 3, height = 7, image = theme.battery })
uzful.widget.set_properties(mybat.progress, {
    ticks = true, ticks_gap = 1,  ticks_size = 1,
    vertical = true, background_color = theme.bg_normal,
    border_color = nil, color = "#FFFFFF" })
vicious.register(mybat.progress, vicious.widgets.bat, "$2", 45, "BAT0")

myimgbat = uzful.util.listen.vicious("text", function (val)
        if val == "-" then
            mybat.draw_image_first()
        elseif val == "+" or val == "" then
            mybat.draw_progress_first()
        end
    end )
vicious.register(myimgbat, vicious.widgets.bat, "$1", 90, "BAT0")

local mynotibat, mycritbat_old_val = nil, nil
mycritbat = uzful.util.threshold(0.2,
    function (val)
        mycritbat_old_val = val
        mybat.progress:set_background_color(theme.bg_normal)
        if mynotibat ~= nil then  naughty.destroy(mynotibat)  end
    end,
    function (val)
        mybat.progress:set_background_color("#8C0000")
        if val < 0.1 and val <= mycritbat_old_val then
            if mynotibat ~= nil then  naughty.destroy(mynotibat)  end
            mynotibat = naughty.notify({
                preset = naughty.config.presets.critical,
                title = "Critical Battery Charge",
                text =  "only " .. (val*100) .. "% remaining."})
        end
        mycritbat_old_val = val
    end)
vicious.register(mycritbat, vicious.widgets.bat, "$2", 90, "BAT0")


-- Battery Text
mybtxt = wibox.widget.textbox()
vicious.register(mybtxt, vicious.widgets.bat,
    '<span size="small">$1$3 $2%</span>', 60, "BAT0")

bring it to a screen:

myinfobox.bat = uzful.widget.infobox({
        size = function () return mybtxt:fit(-1, -1) end,
        position = "top", align = "right",
        widget = mybtxt })

(don't forget to add mybat to the wibox layout)

toggle visibility:

mybat:connect_signal("mouse::enter", function ()
    myinfobox.bat:update()
    myinfobox.bat:show()
end)
mybat:connect_signal("mouse::leave", myinfobox.bat.hide)

calendar

create it:

-- Create a textclock and calendar widget
mytextclock = awful.widget.textclock('<span size="x-small"> %H:%M </span>')
mycal = uzful.widget.calendar({
    all = '<span size="small">$1</span>',
    head = '<span color="#666666">$1</span>',
    week = '<span color="#999999">$1</span>',
    day  = '<span color="#BBBBBB">$1</span>',
    number  = '<span color="#EEEEEE">$1</span>',
    current = '<span color="green">$1</span>',
})

add mouse controlling:

mytextclock:buttons(awful.util.table.join(
    awful.button({         }, 1, function()  mycal:switch_month(-1)  end),
    awful.button({         }, 2, function()  mycal:now()             end),
    awful.button({         }, 3, function()  mycal:switch_month( 1)  end),
    awful.button({         }, 4, function()  mycal:switch_month(-1)  end),
    awful.button({         }, 5, function()  mycal:switch_month( 1)  end),
    awful.button({ 'Shift' }, 1, function()  mycal:switch_year(-1)  end),
    awful.button({ 'Shift' }, 2, function()  mycal:now()             end),
    awful.button({ 'Shift' }, 3, function()  mycal:switch_year( 1)  end),
    awful.button({ 'Shift' }, 4, function()  mycal:switch_year(-1)  end),
    awful.button({ 'Shift' }, 5, function()  mycal:switch_year( 1)  end)
))

bring it to a screen:

myinfobox.cal = uzful.widget.infobox({
        size = function () return mycal.width,mycal.height end,
        position = "top", align = "right",
        widget = mycal.widget })

(don't forget to add mytextclock to the wibox layout)

toggle visibility:

mytextclock:connect_signal("mouse::enter", function ()
    mycal:update()
    myinfobox.cal:update()
    myinfobox.cal:show()
end)
mytextclock:connect_signal("mouse::leave", myinfobox.cal.hide)

layout menu

create it:

mylayoutmenu = uzful.menu.layouts(layouts)

toggle visibility:

mylayoutbox[s]:buttons(awful.util.table.join(
                        awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
                        awful.button({ }, 2, function () mylayoutmenu:toggle() end), -- <<< this line <<< --
                        awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
                        awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
                        awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))

memory progressbar

create it:

-- Memory Progressbar
mymem = uzful.widget.progressimage({
    x = 2, y = 2, width = 5, height = 10,
    image = theme.memory, draw_image_first = false })
uzful.widget.set_properties(mymem.progress, {
    vertical = true, background_color = theme.bg_normal,
    border_color = nil, color = "#0173FF" })
vicious.register(mymem.progress, vicious.widgets.mem, "$1", 13)

(don't forget to add mymem to the wibox layout)