widgets: add many icons

This commit is contained in:
Vincent Bernat 2012-07-29 16:36:31 +02:00
parent 548ed82f2d
commit 2d5c5892b1
17 changed files with 57 additions and 35 deletions

BIN
icons/dev.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

BIN
icons/im.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

BIN
icons/main.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 B

BIN
icons/web.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

BIN
icons/widgets/clock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

BIN
icons/widgets/cpu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

BIN
icons/widgets/disk.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

BIN
icons/widgets/down.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

BIN
icons/widgets/left.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B

BIN
icons/widgets/mem.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

BIN
icons/widgets/right.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

BIN
icons/widgets/spacer.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

BIN
icons/widgets/up.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

BIN
icons/widgets/vol.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

8
rc.lua
View file

@ -50,10 +50,10 @@ config.layouts = {
awful.layout.suit.floating, awful.layout.suit.floating,
} }
config.tags = { config.tags = {
{ layout = awful.layout.suit.fair }, -- 1 { layout = awful.layout.suit.fair, icon = "main" }, -- 1
{ name = "emacs", mwfact = 0.6 }, { name = "emacs", mwfact = 0.6, icon = "dev" },
{ name = "www", mwfact = 0.7 }, { name = "www", mwfact = 0.7, icon = "web" },
{ name = "im" , mwfact = 0.2 }, { name = "im" , mwfact = 0.2, icon = "im" },
{ }, -- 5 { }, -- 5
{ }, -- 6 { }, -- 6
{ }, -- 7 { }, -- 7

View file

@ -35,7 +35,9 @@ for i = 1, #tags do
-- Properties -- Properties
for pname, pvalue in pairs(otags[i]) do for pname, pvalue in pairs(otags[i]) do
if pname ~= "name" and pname ~= "layout" then if pname == "icon" then
awful.tag.seticon(awful.util.getdir("config") .. "/icons/" .. pvalue .. ".png", tags[i])
elseif pname ~= "name" and pname ~= "layout" then
awful.tag.setproperty(tags[i], pname, pvalue) awful.tag.setproperty(tags[i], pname, pvalue)
end end
end end

View file

@ -3,23 +3,30 @@
require("vicious") require("vicious")
local icons = loadrc("icons", "vbe/icons") local icons = loadrc("icons", "vbe/icons")
-- Separator -- Separators
local separator = widget({ type = "textbox" }) local sepopen = widget({ type = "imagebox" })
separator.text = ' <span color="' .. beautiful.fg_widget_sep .. '" size="small">⋆</span> ' sepopen.image = image(awful.util.getdir("config") .. "/icons/widgets/left.png")
local sepclose = widget({ type = "imagebox" })
sepclose.image = image(awful.util.getdir("config") .. "/icons/widgets/right.png")
local spacer = widget({ type = "imagebox" })
spacer.image = image(awful.util.getdir("config") .. "/icons/widgets/spacer.png")
-- Date -- Date
local datewidget = widget({ type = "textbox" }) local datewidget = widget({ type = "textbox" })
vicious.register(datewidget, vicious.widgets.date, vicious.register(datewidget, vicious.widgets.date,
'<span color="' .. beautiful.fg_widget_clock .. '">%a %d/%m, %H:%M</span>', 61) '<span color="' .. beautiful.fg_widget_clock .. '">%a %d/%m, %H:%M</span>', 61)
local dateicon = widget({ type = "imagebox" })
dateicon.image = image(awful.util.getdir("config") .. "/icons/widgets/clock.png")
-- CPU usage -- CPU usage
local cpuwidget = widget({ type = "textbox" }) local cpuwidget = widget({ type = "textbox" })
vicious.register(cpuwidget, vicious.widgets.cpu, vicious.register(cpuwidget, vicious.widgets.cpu,
function (widget, args) function (widget, args)
return string.format('<span color="' .. beautiful.fg_widget_label .. '">CPU: </span>' .. return string.format('<span color="' .. beautiful.fg_widget_value .. '">%2d%%</span>',
'<span color="' .. beautiful.fg_widget_value .. '">%3d%%</span>',
args[1]) args[1])
end, 2) end, 2)
local cpuicon = widget({ type = "imagebox" })
cpuicon.image = image(awful.util.getdir("config") .. "/icons/widgets/cpu.png")
-- Battery -- Battery
local batwidget = { widget = "" } local batwidget = { widget = "" }
@ -56,14 +63,20 @@ if config.hostname == "guybrush" then
end end
-- Network -- Network
local netwidget = widget({ type = "textbox" }) local netup = widget({ type = "textbox" })
local netdown = widget({ type = "textbox" })
local netupicon = widget({ type = "imagebox" })
netupicon.image = image(awful.util.getdir("config") .. "/icons/widgets/up.png")
local netdownicon = widget({ type = "imagebox" })
netdownicon.image = image(awful.util.getdir("config") .. "/icons/widgets/down.png")
local netgraph = awful.widget.graph() local netgraph = awful.widget.graph()
netgraph:set_width(80):set_height(14) netgraph:set_width(80):set_height(16)
netgraph:set_stack(true):set_scale(true) netgraph:set_stack(true):set_scale(true)
netgraph:set_border_color(beautiful.fg_widget_border) netgraph:set_border_color(beautiful.fg_widget_border)
netgraph:set_stack_colors({ "#FF0000", "#0000FF" }) netgraph:set_stack_colors({ "#FF0000", "#0000FF" })
netgraph:set_background_color("#00000000") netgraph:set_background_color("#00000000")
vicious.register(netwidget, vicious.widgets.net, vicious.register(netup, vicious.widgets.net,
function (widget, args) function (widget, args)
-- We sum up/down value for all interfaces -- We sum up/down value for all interfaces
local up = 0 local up = 0
@ -87,22 +100,25 @@ vicious.register(netwidget, vicious.widgets.net,
end end
return string.format("%d B", val) return string.format("%d B", val)
end end
return string.format( -- Down
'<span color="' .. beautiful.fg_widget_label .. netdown.text = string.format('<span color="' .. beautiful.fg_widget_value ..
'">Up/Down: </span><span color="' .. beautiful.fg_widget_value .. '">%08s</span>', format(down))
'">%08s</span><span color="' .. beautiful.fg_widget_label .. -- Up
'">/</span><span color="' .. beautiful.fg_widget_value .. return string.format('<span color="' .. beautiful.fg_widget_value ..
'">%08s</span> ', format(up), format(down)) '">%08s</span>', format(up))
end, 3) end, 3)
-- Memory usage -- Memory usage
local memwidget = widget({ type = "textbox" }) local memwidget = widget({ type = "textbox" })
vicious.register(memwidget, vicious.widgets.mem, vicious.register(memwidget, vicious.widgets.mem,
'<span color="' .. beautiful.fg_widget_label .. '">Mem: </span>' ..
'<span color="' .. beautiful.fg_widget_value .. '">$1%</span>', '<span color="' .. beautiful.fg_widget_value .. '">$1%</span>',
13) 13)
local memicon = widget({ type = "imagebox" })
memicon.image = image(awful.util.getdir("config") .. "/icons/widgets/mem.png")
-- Volume level -- Volume level
local volicon = widget({ type = "imagebox" })
volicon.image = image(awful.util.getdir("config") .. "/icons/widgets/vol.png")
local volwidget = widget({ type = "textbox" }) local volwidget = widget({ type = "textbox" })
vicious.register(volwidget, vicious.widgets.volume, vicious.register(volwidget, vicious.widgets.volume,
'<span color="' .. beautiful.fg_widget_value .. '">$2 $1%</span>', '<span color="' .. beautiful.fg_widget_value .. '">$2 $1%</span>',
@ -121,6 +137,8 @@ local fs = { ["/"] = "root",
["/usr"] = "usr", ["/usr"] = "usr",
["/tmp"] = "tmp", ["/tmp"] = "tmp",
["/var/cache/build"] = "pbuilder" } ["/var/cache/build"] = "pbuilder" }
local fsicon = widget({ type = "imagebox" })
fsicon.image = image(awful.util.getdir("config") .. "/icons/widgets/disk.png")
local fswidget = widget({ type = "textbox" }) local fswidget = widget({ type = "textbox" })
vicious.register(fswidget, vicious.widgets.fs, vicious.register(fswidget, vicious.widgets.fs,
function (widget, args) function (widget, args)
@ -135,7 +153,7 @@ vicious.register(fswidget, vicious.widgets.fs,
result = string.format( result = string.format(
'%s%s<span color="' .. beautiful.fg_widget_label .. '">%s: </span>' .. '%s%s<span color="' .. beautiful.fg_widget_label .. '">%s: </span>' ..
'<span color="' .. color .. '">%2d%%</span>', '<span color="' .. color .. '">%2d%%</span>',
result, #result > 0 and separator.text or "", name, used) result, #result > 0 and " " or "", name, used)
end end
end end
return result return result
@ -168,7 +186,6 @@ tasklist.buttons = awful.util.table.join(
for s = 1, screen.count() do for s = 1, screen.count() do
promptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright }) promptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
layoutbox[s] = awful.widget.layoutbox(s) layoutbox[s] = awful.widget.layoutbox(s)
awful.widget.layout.margins[layoutbox[s]] = { left = 5 }
tasklist[s] = awful.widget.tasklist( tasklist[s] = awful.widget.tasklist(
function(c) function(c)
local fn = awful.widget.tasklist.label.currenttags local fn = awful.widget.tasklist.label.currenttags
@ -192,7 +209,7 @@ for s = 1, screen.count() do
fg = beautiful.fg_normal, fg = beautiful.fg_normal,
bg = beautiful.bg_widget, bg = beautiful.bg_widget,
position = "top", position = "top",
height = 14, height = 16,
}) })
-- Add widgets to the wibox -- Add widgets to the wibox
local on = function(n, what) local on = function(n, what)
@ -202,19 +219,22 @@ for s = 1, screen.count() do
wibox[s].widgets = { wibox[s].widgets = {
{ {
taglist[s], layoutbox[s], sepopen,
separator, promptbox[s], taglist[s],
spacer,
layoutbox[s], sepclose,
promptbox[s],
layout = awful.widget.layout.horizontal.leftright layout = awful.widget.layout.horizontal.leftright
}, },
on(1, systray), on(1, separator), on(1, systray),
datewidget, separator, sepclose, datewidget, dateicon, spacer,
on(2, volwidget), on(2, separator), on(2, volwidget), on(2, volicon), on(2, spacer),
on(2, batwidget.widget), on(2, batwidget.widget ~= "" and separator or ""), on(2, batwidget.widget), on(2, batwidget.widget ~= "" and spacer or ""),
on(2, fswidget), on(2, separator), on(2, fswidget), on(2, fsicon), on(2, sepopen),
on(1, netgraph.widget), on(1, netwidget), on(1, separator), on(1, netgraph.widget), on(1, netdownicon), on(1, netdown), on(1, netupicon), on(1, netup), on(1, spacer),
on(1, memwidget), on(1, separator), on(1, memwidget), on(1, memicon), on(1, spacer),
on(1, cpuwidget), on(1, separator), on(1, cpuwidget), on(1, cpuicon), on(1, sepopen),
tasklist[s], separator, tasklist[s],
layout = awful.widget.layout.horizontal.rightleft } layout = awful.widget.layout.horizontal.rightleft }
end end