You are not logged in.
Hey all - i've been doing battle with lua for a week or so, and can't get a number of things to work. I can't get programs to automatically open on specific tags, and i can't get my keyboard shortcuts to work. Its probs something obvious, as i've been offline and haven't been able to read much on lua, but here is my awesomerc.lua file. Any corrections/improvements are most welcome. Please be nice+patient, as it probs IS something really obvious. I just can't understand it.
EDIT: i know some of my widgets don't work, but thats not the big problem. I'm happy to work those out on my own for now.
-- awesome 3 configuration file
-- Include awesome library, with lots of useful function!
require("awful")
require("tabulous")
require("wicked")
-- Uncomment this to activate autotabbing
-- tabulous.autotab_start()
-- {{{ Variable definitions
-- This is used later as the default terminal to run.
terminal = "urxvt"
broswer = "firefox3"
colorlight = "#4b7885"
colordark = "#223b56"
-- Default modkey.
modkey = "Mod4"
-- Table of layouts to cover with awful.layout.inc, order matters.
layouts =
{
"tile",
"tileleft",
"tilebottom",
"tiletop",
"magnifier",
"max",
"spiral",
"dwindle",
"floating"
}
-- Table of clients that should be set floating
floatings =
{
["mplayer"] = true,
["pinentry"] = true,
["gedit"] = true
}
floattag =
{
["Gimp"] = true,
["pidgin"] = true,
["SlingPlayer.exe"] = true,
["skype"] = true
}
nettag =
{
["firefox3"] = true
}
maintag =
{
["feh"] = true,
["thunar"] = true
}
-- STYLE ********************
-- Color & Appearance definitions, we use these later to display things
font = "sans 8"
border_width = 1
bg_normal = "#000000"
fg_normal = colordark
border_normal = fg_normal
bg_focus = colorlight
fg_focus = "#000000"
border_focus = bg_focus
border_marked = "#91231c"
awesome.font_set(font)
awesome.colors_set({ fg = fg_normal, bg = bg_normal })
-- }}}
-- {{{ Tags ***********************
-- Define tags table
tagsterm = tag({ name = 'term', layout = 'tile' })
tagsterm:add(1)
tagsterm.selected = true
tagsnet = tag({ name = 'net', layout = 'max' })
tagsnet:add(1)
tagsmain = tag({ name = 'main', layout = 'max' })
tagsmain:add(1)
tagsfloat = tag({ name = 'float', layout = 'floating' })
tagsfloat:add(1)
-- }}}
-- {{{ Statusbar
-- Create a taglist widget
mytaglist = widget({ type = "taglist", name = "mytaglist" })
mytaglist:mouse_add(mouse({}, 1, function (object, tag) awful.tag.viewonly(tag) end))
mytaglist:mouse_add(mouse({ modkey }, 1, function (object, tag) awful.client.movetotag(tag) end))
mytaglist:mouse_add(mouse({}, 3, function (object, tag) tag.selected = not tag.selected end))
mytaglist:mouse_add(mouse({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end))
mytaglist:mouse_add(mouse({ }, 4, awful.tag.viewnext))
mytaglist:mouse_add(mouse({ }, 5, awful.tag.viewprev))
mytaglist.text_focus = "<bg color='"..bg_focus.."'/> <span color='"..fg_focus.."'><title/></span> "
-- Create a tasklist widget
mytasklist = widget({ type = "tasklist", name = "mytasklist" })
mytasklist:mouse_add(mouse({ }, 1, function (object, c) c:focus_set(); c:raise() end))
mytasklist:mouse_add(mouse({ }, 4, function () awful.client.focus(1) end))
mytasklist:mouse_add(mouse({ }, 5, function () awful.client.focus(-1) end))
function mytasklist.label(c)
local text = ""
if c.floating then
text = text .. "<bg image=\"/usr/share/awesome/icons/floatingw.png\" align=\"right\"/>"
end
if client.focus_get() == c then
text = text .. " <bg color='"..bg_focus.."'/><span color='"..fg_focus.."'><title/></span> "
else
text = text .. " <title/> "
end
return text
end
-- TEXTBOXES *****************
-- Create a textbox widget
mytextbox = widget({ type = "textbox", name = "mytextbox", align = "right" })
-- Set the default text in textbox
mypromptbox = widget({ type = "textbox", name = "mypromptbox", align = "left" })
-- Create an iconbox widget
myiconbox = widget({ type = "textbox", name = "myiconbox", align = "left" })
myiconbox.text = "<bg image=\"/usr/share/awesome/icons/awesome16.png\" resize=\"true\"/>"
-- Create a systray
mysystray = widget({ type = "systray", name = "mysystray", align = "right" })
-- Create an iconbox widget which will contains an icon indicating which layout we're using.
-- We need one layoutbox per screen.
mylayoutbox = {}
for s = 1, screen.count() do
mylayoutbox[s] = widget({ type = "textbox", name = "mylayoutbox", align = "right" })
mylayoutbox[s]:mouse_add(mouse({ }, 1, function () awful.layout.inc(layouts, 1) end))
mylayoutbox[s]:mouse_add(mouse({ }, 3, function () awful.layout.inc(layouts, -1) end))
mylayoutbox[s]:mouse_add(mouse({ }, 4, function () awful.layout.inc(layouts, 1) end))
mylayoutbox[s]:mouse_add(mouse({ }, 5, function () awful.layout.inc(layouts, -1) end))
mylayoutbox[s].text = "<bg image=\"/usr/share/awesome/icons/layouts/tilew.png\" resize=\"true\"/>"
end
-- MY TEXTBOXES ETC
linkbox = widget ({ type = "textbox", name = "link", align = "left" })
netbox = widget ({ type = "textbox", name = "network", align = "left" })
downbox = widget ({ type = "textbox", name = "download", align = "left" })
rootbox = widget ({ type = "textbox", name = "root", align = "left" })
homebox = widget ({ type = "textbox", name = "home", align = "left" })
batterybox = widget ({ type = "textbox", name = "battery", align = "left" })
mpdbox = widget ({ type = "textbox", name = "mpd", align = "right" })
clockbox = widget ({ type = "textbox", name = "clock", align = "right" })
linkbox.text = "link"
netbox.text = "network"
downbox.text = "download"
rootbox.text = "root"
homebox.text = "home"
batterybox.text = "battery"
mpdbox.text = "mpd"
clockbox.text = "clock"
wicked.register(rootbox, 'fs', ' ${/ usep}% ', 30)
wicked.register(homebox, 'fs', ' ${/home usep}% ', 30)
wicked.register(mpdbox, 'mpd', ' $1 ')
wicked.register(clockbox, 'date', ' %H:%M ')
wicked.register(linkbox, 'net', ' ${wlan0 rx} // ${wlan0 tx} ')
wicked.register(batterybox, 'function', ' acpitool -b | cut -b29- ')
-- Create a statusbar for each screen and add it
mystatusbartop = statusbar({ position = "top", name = "statustop", fg = fg_normal, bg = bg_normal })
-- Add widgets to the statusbar - order matters
mystatusbartop:widget_add(mytaglist)
mystatusbartop:widget_add(myiconbox)
mystatusbartop:widget_add(mypromptbox)
mystatusbartop:widget_add(linkbox)
mystatusbartop:widget_add(netbox)
mystatusbartop:widget_add(downbox)
mystatusbartop:widget_add(rootbox)
mystatusbartop:widget_add(homebox)
mystatusbartop:widget_add(batterybox)
mystatusbartop:widget_add(mpdbox)
mystatusbartop:widget_add(clockbox)
mystatusbartop:widget_add(mylayoutbox[1])
mystatusbartop:add(1)
mystatusbarbtm = statusbar({ position = "bottom", name = "statusbottom", fg = fg_normal, bg = bg_normal })
mystatusbarbtm:widget_add(mytasklist)
mystatusbarbtm:add(1)
mystatusbarbtm:widget_add(mysystray)
-- }}}
-- {{{ Mouse bindings
awesome.mouse_add(mouse({ }, 3, function () awful.spawn(terminal) end))
awesome.mouse_add(mouse({ }, 4, awful.tag.viewnext))
awesome.mouse_add(mouse({ }, 5, awful.tag.viewprev))
-- }}}
-- {{{ Key bindings
keybinding({ modkey }, "Left", awful.tag.viewprev):add()
keybinding({ modkey }, "Right", awful.tag.viewnext):add()
-- Standard program
keybinding({ modkey, "Shift" }, "t", function () awful.spawn(terminal) end):add()
keybinding({ modkey, "Shift" }, "o", function () awful.spawn(browser) end):add()
keybinding({ modkey, "Control" }, "r", awesome.restart):add()
keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
-- Client manipulation
keybinding({ modkey, "Shift" }, "c", function () client.focus_get():kill() end):add()
keybinding({ modkey }, "j", function () awful.client.focus(1); client.focus_get():raise() end):add()
keybinding({ modkey }, "k", function () awful.client.focus(-1); client.focus_get():raise() end):add()
keybinding({ modkey, "Shift" }, "j", function () awful.client.swap(1) end):add()
keybinding({ modkey, "Shift" }, "k", function () awful.client.swap(-1) end):add()
keybinding({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
keybinding({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
keybinding({ modkey, "Control" }, "space", awful.client.togglefloating):add()
keybinding({ modkey, "Control" }, "Return", function () client.focus_get():swap(awful.client.master()) end):add()
keybinding({ modkey }, "o", awful.client.movetoscreen):add()
-- Layout manipulation
keybinding({ modkey }, "1", function () awful.tag.viewonly(tagsterm) end):add()
keybinding({ modkey }, "2", function () awful.tag.viewonly(tagsnet) end):add()
keybinding({ modkey }, "3", function () awful.tag.viewonly(tagsmain) end):add()
keybinding({ modkey }, "4", function () awful.tag.viewonly(tagsfloat) end):add()
keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
keybinding({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
keybinding({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
keybinding({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
keybinding({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
keybinding({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
keybinding({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
-- Prompt
keybinding({ modkey }, "F1", function ()
awful.prompt({ prompt = "Run: ", cursor_fg = fg_focus, cursor_bg = bg_focus }, mypromptbox, awful.spawn, awful.completion.bash)
end):add()
keybinding({ modkey }, "F4", function ()
awful.prompt({ prompt = "Run Lua code: ", cursor_fg = fg_focus, cursor_bg = bg_focus }, mypromptbox, awful.eval, awful.prompt.bash)
end):add()
--- Tabulous, tab manipulation
keybinding({ modkey, "Control" }, "y", function ()
local tabbedview = tabulous.tabindex_get()
local nextclient = awful.client.next(1)
if tabbedview == nil then
tabbedview = tabulous.tabindex_get(nextclient)
if tabbedview == nil then
tabbedview = tabulous.tab_create()
tabulous.tab(tabbedview, nextclient)
else
tabulous.tab(tabbedview, client.focus_get())
end
else
tabulous.tab(tabbedview, nextclient)
end
end):add()
keybinding({ modkey, "Shift" }, "y", tabulous.untab):add()
keybinding({ modkey }, "y", function ()
local tabbedview = tabulous.tabindex_get()
if tabbedview ~= nil then
local n = tabulous.next(tabbedview)
tabulous.display(tabbedview, n)
end
end):add()
-- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
keybinding({ modkey }, "t", awful.client.togglemarked):add()
keybinding({ modkey, 'Shift' }, "t", function ()
local tabbedview = tabulous.tabindex_get()
local clients = awful.client.getmarked()
if tabbedview == nil then
tabbedview = tabulous.tab_create(clients[1])
table.remove(clients, 1)
end
for k,c in pairs(clients) do
tabulous.tab(tabbedview, c)
end
end):add()
-- }}}
-- {{{ Hooks
-- Hook function to execute when focusing a client.
function hook_focus(c)
if not awful.client.ismarked(c) then
c.border_color = border_focus
end
end
-- Hook function to execute when unfocusing a client.
function hook_unfocus(c)
if not awful.client.ismarked(c) then
c.border_color = border_normal
end
end
-- Hook function to execute when marking a client
function hook_marked(c)
c.border_color = border_marked
end
-- Hook function to execute when unmarking a client
function hook_unmarked(c)
c.border_color = border_focus
end
-- Hook function to execute when the mouse is over a client.
function hook_mouseover(c)
-- Sloppy focus, but disabled for magnifier layout
if awful.layout.get(c.screen) ~= "magnifier" then
c:focus_set()
end
end
-- Hook function to execute when a new client appears.
function hook_manage(c)
-- Add mouse bindings
c:mouse_add(mouse({ }, 1, function (c) c:focus_set(); c:raise() end))
c:mouse_add(mouse({ modkey }, 1, function (c) c:mouse_move() end))
c:mouse_add(mouse({ modkey }, 3, function (c) c:mouse_resize() end))
-- New client may not receive focus
-- if they're not focusable, so set border anyway.
c.border_width = border_width
c.border_color = border_normal
c:focus_set()
-- set floating, and move to tags
if floatings[c.name:lower()] then
c.floating = true
end
if nettag[c.name:lower()] then
awful.client.movetotag( tagsnet, c)
end
if maintag[c.name:lower()] then
awful.client.movetotag( tagsmain, c)
end
if floattag[c.name:lower()] then
awful.client.movetotag( tagsfloat, c)
end
-- Honor size hints
c.honorsizehints = true
end
-- Hook function to execute when arranging the screen
-- (tag switch, new client, etc)
function hook_arrange(screen)
local layout = awful.layout.get(screen)
mylayoutbox[screen].text = "<bg image=\"/usr/share/awesome/icons/layouts/" .. layout .. "w.png\" resize=\"true\"/>"
-- Uncomment if you want mouse warping
--[[
local sel = client.focus_get()
if sel then
local c_c = sel.coords
local m_c = mouse.coords
if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
if table.maxn(m_c.buttons) == 0 then
mouse.coords = { x = c_c.x + 5, y = c_c.y + 5}
end
end
end
]]
end
-- Hook called every second
function hook_timer ()
-- For unix time_t lovers
mytextbox.text = " " .. os.time() .. " time_t "
-- Otherwise use:
-- mytextbox.text = " " .. os.date() .. " "
end
-- MY HOOKS ************
-- Set up some hooks
awful.hooks.focus(hook_focus)
awful.hooks.unfocus(hook_unfocus)
awful.hooks.marked(hook_marked)
awful.hooks.unmarked(hook_unmarked)
awful.hooks.manage(hook_manage)
awful.hooks.mouseover(hook_mouseover)
awful.hooks.arrange(hook_arrange)
awful.hooks.timer(1, hook_timer)
-- }}}
Last edited by shearn89 (2008-07-20 11:16:05)
Offline
U might wanna check out the Awsome wiki, it has some template rc.lua files. And about opening proggies on specific tags, I dont think that has been implemented just yet. I think that one user has managed to do that xOrg62 I believe. Again check http://awesome.naquadah.org/wiki/index.php/Main_Page -> the user configuration file section.
Offline
I have windows opening in specific tags.
inside function hook_manage(c):
function program(p)
return c.class:lower():find(p)
end
if program("opera") then
awful.client.movetotag(tags[1][2])
end
Offline
Hmm didnt know that, but then again I find the whole lua thing to be major crapola. Ill post my config file, maybe it'll help u out.
-- awesome 3 configuration file
require("awful")
require("tabulous")
require("wicked")
tabulous.autotab_start()
-- {{{ Variable definitions
terminal = "urxvtc"
modkey = "Mod1"
layouts =
{
"tile",
"tileleft",
"tilebottom",
"tiletop",
"magnifier",
"max",
"spiral",
"dwindle",
"floating"
}
floatings =
{
["mplayer"] = true,
["smplayer"] = true
}
-- Color & Appearance definitions, we use these later to display things
font = "Terminus 8"
border_width = 1
bg_normal = "#222222"
fg_normal = "#aaaaaa"
border_normal = "#000000"
bg_focus = "#535d6c"
fg_focus = "#ffffff"
border_focus = bg_focus
border_marked = "#91231C"
awesome.font_set(font)
awesome.colors_set({ fg = fg_normal, bg = bg_normal })
-- }}}
-- {{{ Tags
-- Define tags table
tags = {}
for s = 1, screen.count() do
-- Each screen has its own tag table
tags[s] = {}
-- Create 9 tags per screen
for tagnumber = 1, 9 do
tags[s][tagnumber] = tag({ name = tagnumber, layout = layouts[1] })
-- Add tags to screen one by one
tags[s][tagnumber].mwfact = 0.618033988769
tags[s][tagnumber]:add(s)
end
-- I'm sure you want to see at least one tag.
tags[s][1].selected = true
end
-- }}}
-- {{{ Statusbar
mytaglist = widget({ type = "taglist", name = "mytaglist" })
mytaglist:mouse_add(mouse({}, 1, function (object, tag) awful.tag.viewonly(tag) end))
mytaglist:mouse_add(mouse({ modkey }, 1, function (object, tag) awful.client.movetotag(tag) end))
mytaglist:mouse_add(mouse({}, 3, function (object, tag) tag.selected = not tag.selected end))
mytaglist:mouse_add(mouse({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end))
mytaglist:mouse_add(mouse({ }, 4, awful.tag.viewnext))
mytaglist:mouse_add(mouse({ }, 5, awful.tag.viewprev))
function mytaglist.label(t)
local text = ""
if t.selected then
text = "<bg color='"..bg_focus.."'/> <span color='"..fg_focus.."'>"..t.name.."</span> "
else
text = " "..t.name.." "
end
return text
end
mytasklist = widget({ type = "tasklist", name = "mytasklist" })
mytasklist:mouse_add(mouse({ }, 1, function (object, c) c:focus_set(); c:raise() end))
mytasklist:mouse_add(mouse({ }, 4, function () awful.client.focus(1) end))
mytasklist:mouse_add(mouse({ }, 5, function () awful.client.focus(-1) end))
function mytasklist.label(c)
local text = ""
if c.floating then
text = "<bg image=\"/usr/share/awesome/icons/floatingw.png\" align=\"right\"/>"
end
if client.focus_get() == c then
text = text .. " <bg color='"..bg_focus.."'/><span color='"..awful.escape(fg_focus).."'>"..c.name.."</span> "
else
text = text .. " "..awful.escape(c.name).." "
end
return text
end
mypromptbox = widget({ type = "textbox", name = "mypromptbox", align = "left" })
mysystray = widget({ type = "systray", name = "mysystray", align = "right" })
mylayoutbox = {}
mylayoutbox = widget({ type = "textbox", name = "mylayoutbox", align = "left" })
mylayoutbox:mouse_add(mouse({ }, 1, function () awful.layout.inc(layouts, 1) end))
mylayoutbox:mouse_add(mouse({ }, 3, function () awful.layout.inc(layouts, -1) end))
mylayoutbox:mouse_add(mouse({ }, 4, function () awful.layout.inc(layouts, 1) end))
mylayoutbox:mouse_add(mouse({ }, 5, function () awful.layout.inc(layouts, -1) end))
mylayoutbox.text = "<bg image=\"/usr/share/awesome/icons/layouts/tilew.png\" resize=\"true\"/>"
-- space
space = widget({
type = "textbox",
name = "space",
align = "right"
})
space.text = " "
-- CPU Graph
cpugraphwidget = widget({
type = "graph",
name = "cpugraphwidget",
align = "right"
})
cpugraphwidget.width = 50
cpugraphwidget.height = 0.65
cpugraphwidget.grow = "left"
cpugraphwidget:plot_properties_set('cpu', {
fg = "#AEC6D8",
fg_center = "#285577",
fg_end = "#285577",
vertical_gradient = false
})
wicked.register(cpugraphwidget, 'cpu', '$1', 1, 'cpu')
-- NetTraffic
netwidget = widget({
type = "textbox",
name = "netwidget",
align = "right"
})
wicked.register(netwidget, "net", "${wlan0 down} / ${wlan0 up}")
-- Volume
volumewidget = widget({
type = "progressbar",
name = "volumewidget",
align = "right"
})
volumewidget.width = 50
volumewidget.height = 0.65
volumewidget.ticks_count = 15
wicked.register(volumewidget, "function", function (widget, args)
local f = io.popen("amixer get PCM | grep Left: | cut -f 2 -d [ | cut -d% -f1")
local l = f:read()
f:close()
return l
end, 1, "volume")
volumewidget:mouse_add(mouse({ }, 4, function () awful.spawn("amixer set PCM 2%+") end))
volumewidget:mouse_add(mouse({ }, 5, function () awful.spawn("amixer set PCM 2%-") end))
-- Time & Date
datewidget = widget({ type = "textbox", name = "datewidget", align = "right" })
wicked.register(datewidget, "date", "%A, %d/%m/%Y - %T")
mystatusbar = {}
mystatusbar = statusbar({ position = "top", name = "mystatusbar", fg = fg_normal, bg = bg_normal })
mystatusbar:widget_add(mytaglist)
mystatusbar:widget_add(mytasklist)
mystatusbar:widget_add(mypromptbox)
mystatusbar:widget_add(mylayoutbox)
mystatusbar:widget_add(space)
mystatusbar:widget_add(cpugraphwidget)
mystatusbar:widget_add(space)
mystatusbar:widget_add(netwidget)
mystatusbar:widget_add(space)
mystatusbar:widget_add(volumewidget)
mystatusbar:widget_add(space)
mystatusbar:widget_add(datewidget)
mystatusbar:widget_add(mysystray)
mystatusbar:add(1)
-- }}}
-- {{{ Mouse bindings
awesome.mouse_add(mouse({ }, 3, function () awful.spawn(terminal) end))
awesome.mouse_add(mouse({ }, 4, awful.tag.viewnext))
awesome.mouse_add(mouse({ }, 5, awful.tag.viewprev))
-- }}}
-- {{{ Key bindings
-- Bind keyboard digits
-- Compute the maximum number of digit we need, limited to 9
keynumber = 0
for s = 1, screen.count() do
keynumber = math.min(9, math.max(#tags[s], keynumber));
end
for i = 1, keynumber do
keybinding({ modkey }, i,
function ()
local screen = mouse.screen
if tags[screen][i] then
awful.tag.viewonly(tags[screen][i])
end
end):add()
keybinding({ modkey, "Control" }, i,
function ()
local screen = mouse.screen
if tags[screen][i] then
tags[screen][i].selected = not tags[screen][i].selected
end
end):add()
keybinding({ modkey, "Shift" }, i,
function ()
local screen = mouse.screen
if tags[screen][i] then
awful.client.movetotag(tags[screen][i])
end
end):add()
keybinding({ modkey, "Control", "Shift" }, i,
function ()
local screen = mouse.screen
if tags[screen][i] then
awful.client.toggletag(tags[screen][i])
end
end):add()
end
keybinding({ modkey }, "Left", awful.tag.viewprev):add()
keybinding({ modkey }, "Right", awful.tag.viewnext):add()
-- Standard program
keybinding({ modkey }, "f", function () awful.spawn("firefox") end):add()
keybinding({ modkey }, "p", function () awful.spawn("pcmanfm") end):add()
keybinding({ modkey }, "g", function () awful.spawn("geany") end):add()
keybinding({ modkey }, "d", function () awful.spawn("deluge") end):add()
keybinding({ modkey }, "s", function () awful.spawn("savage2") end):add()
keybinding({ modkey }, "w", function () awful.spawn("soffice -writer") end):add()
keybinding({ modkey }, "c", function () awful.spawn("soffice -calc") end):add()
keybinding({ modkey, "Control" }, "r", function () awful.spawn("sudo reboot") end):add()
keybinding({ modkey, "Control" }, "s", function () awful.spawn("sudo halt") end):add()
keybinding({ modkey }, "Return", function () awful.spawn(terminal) end):add()
keybinding({ modkey, "Shift" }, "r", awesome.restart):add()
keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
-- Client manipulation
keybinding({ modkey, "Shift" }, "w", function () client.focus_get():kill() end):add()
keybinding({ modkey }, "j", function () awful.client.focus(1); client.focus_get():raise() end):add()
keybinding({ modkey }, "k", function () awful.client.focus(-1); client.focus_get():raise() end):add()
keybinding({ modkey, "Shift" }, "j", function () awful.client.swap(1) end):add()
keybinding({ modkey, "Shift" }, "k", function () awful.client.swap(-1) end):add()
keybinding({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
keybinding({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
keybinding({ modkey, "Control" }, "space", awful.client.togglefloating):add()
keybinding({ modkey, "Control" }, "Return", function () client.focus_get():swap(awful.client.master()) end):add()
keybinding({ modkey }, "o", awful.client.movetoscreen):add()
-- Layout manipulation
keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
keybinding({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
keybinding({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
keybinding({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
keybinding({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
keybinding({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
keybinding({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
-- Prompt
keybinding({ modkey }, "F1", function () awful.prompt({ prompt = "Run: ", cursor_fg = fg_focus, cursor_bg = bg_focus }, mypromptbox, awful.spawn, awful.completion.bash) end):add()
keybinding({ modkey }, "F4", function () awful.prompt({ prompt = "Run Lua code: ", cursor_fg = fg_focus, cursor_bg = bg_focus }, mypromptbox, awful.eval, awful.prompt.bash) end):add()
--- Tabulous, tab manipulation
keybinding({ modkey, "Control" }, "y", function ()
local tabbedview = tabulous.tabindex_get()
local nextclient = awful.client.next(1)
if tabbedview == nil then
tabbedview = tabulous.tabindex_get(nextclient)
if tabbedview == nil then
tabbedview = tabulous.tab_create()
tabulous.tab(tabbedview, nextclient)
else
tabulous.tab(tabbedview, client.focus_get())
end
else
tabulous.tab(tabbedview, nextclient)
end
end):add()
keybinding({ modkey, "Shift" }, "y", tabulous.untab):add()
keybinding({ modkey }, "y", function ()
local tabbedview = tabulous.tabindex_get()
if tabbedview ~= nil then
local n = tabulous.next(tabbedview)
tabulous.display(tabbedview, n)
end
end):add()
-- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
keybinding({ modkey }, "t", awful.client.togglemarked):add()
keybinding({ modkey, 'Shift' }, "t", function ()
local tabbedview = tabulous.tabindex_get()
local clients = awful.client.getmarked()
if tabbedview == nil then
tabbedview = tabulous.tab_create(clients[1])
table.remove(clients, 1)
end
for k,c in pairs(clients) do
tabulous.tab(tabbedview, c)
end
end):add()
for i = 1, keynumber do
keybinding({ modkey, "Shift" }, "F" .. i,
function ()
local screen = mouse.screen
if tags[screen][i] then
for k, c in pairs(awful.client.getmarked()) do
awful.client.movetotag(tags[screen][i], c)
end
end
end):add()
end
-- }}}
-- {{{ Hooks
-- Hook function to execute when focusing a client.
function hook_focus(c)
if not awful.client.ismarked(c) then
c.border_color = border_focus
end
end
-- Hook function to execute when unfocusing a client.
function hook_unfocus(c)
if not awful.client.ismarked(c) then
c.border_color = border_normal
end
end
-- Hook function to execute when marking a client
function hook_marked(c)
c.border_color = border_marked
end
-- Hook function to execute when unmarking a client
function hook_unmarked(c)
c.border_color = border_focus
end
-- Hook function to execute when the mouse is over a client.
function hook_mouseover(c)
-- Sloppy focus, but disabled for magnifier layout
if awful.layout.get(c.screen) ~= "magnifier" then
c:focus_set()
end
end
-- Hook function to execute when a new client appears.
function hook_manage(c)
-- Add mouse bindings
c:mouse_add(mouse({ }, 1, function (c) c:focus_set(); c:raise() end))
c:mouse_add(mouse({ modkey }, 1, function (c) c:mouse_move() end))
c:mouse_add(mouse({ modkey }, 3, function (c) c:mouse_resize() end))
-- New client may not receive focus
-- if they're not focusable, so set border anyway.
c.border_width = border_width
c.border_color = border_normal
c:focus_set()
if floatings[c.name:lower()] then
c.floating = true
end
-- Honor size hints
c.honorsizehints = false
end
-- Hook function to execute when arranging the screen
-- (tag switch, new client, etc)
function hook_arrange(screen)
local layout = awful.layout.get(screen)
mylayoutbox.text = "<bg image=\"/usr/share/awesome/icons/layouts/" .. layout .. "w.png\" resize=\"true\"/>"
-- Uncomment if you want mouse warping
--[[
local sel = client.focus_get()
if sel then
local c_c = sel.coords
local m_c = mouse.coords
if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
if table.maxn(m_c.buttons) == 0 then
mouse.coords = { x = c_c.x + 5, y = c_c.y + 5}
end
end
end
]]
end
-- Set up some hooks
awful.hooks.focus(hook_focus)
awful.hooks.unfocus(hook_unfocus)
awful.hooks.marked(hook_marked)
awful.hooks.unmarked(hook_unmarked)
awful.hooks.manage(hook_manage)
awful.hooks.mouseover(hook_mouseover)
awful.hooks.arrange(hook_arrange)
-- }}}
Offline
If you don't like lua, go back to awesome 2.3
I personally think it's a good idea. I don't know any lua myself, but the config file is pretty straightfoward, and I can usually figure things out
I'll also post my config to see if it can help you out any:
-- awesome 3 configuration file
-- AUTHOR: heleos (heleoslol@gmail.com)
require("awful")
require("wicked")
--require("tabulous")
-- {{{ Defaults
default_font = 'Bitstream Vera Sans Mono 8'
bar_font = 'snap 8'
--default_mwfact = 0.618033988769
default_mwfact = .75
www_mwfact = .8
spacer = " "
separator = " "
menu = 'mydmenu'
terminal = 'urxvtc'
filemanager = 'thunar'
webbrowser = 'opera'
music_toggle = 'mpc toggle'
music_stop = 'mpc stop'
music_next = 'mpc next'
music_prev = 'mpc prev'
-- BG colors
bg_normal = '#000000'
bg_focus = '#333333'
bg_urgent = '#FF0000'
-- FG Colors
fg_normal = '#FFFFFF'
fg_focus = '#AAAAAA'
fg_urgent = '#FFFFFF'
-- Border Colors
border_width = '1'
border_unfocus = '#000000'
border_focus = '#666666'
modkey = "Mod4"
-- Other layouts: magnifier, spiral, dwindle, tileleft
layouts =
{
"tile",
"tilebottom",
"tiletop",
"max",
"floating"
}
-- Floats
-- Default colors
awesome.colors_set({ fg = fg_normal, bg = bg_normal })
awesome.font_set(default_font)
-- {{{ Functions
function heading(text)
return fg(fg_focus, text)
end
--{{{
-- Tabs
tags = {}
for s = 1, screen.count() do
tags[s] = {}
tags[s][1] = tag({ name = "main", layout = layouts[5] })
tags[s][1]:add(s)
tags[s][1].mwfact = default_mwfact
tags[s][2] = tag({ name = "www", layout = layouts[2] })
tags[s][2]:add(s)
tags[s][2].mwfact = www_mwfact
tags[s][3] = tag({ name = "code", layout = layouts[1] })
tags[s][3]:add(s)
tags[s][3].mwfact = default_mwfact
tags[s][4] = tag({ name = "misc", layout = layouts[5] })
tags[s][4]:add(s)
tags[s][4].mwfact = default_mwfact
tags[s][1].selected = true
end
--{{{ Widgets
--Clock
clock_wid = widget({ type = 'textbox',
name = 'clock_wid',
align = 'right'
})
wicked.register(clock_wid, 'date','[%A %d %b %Y] [%r]')
--MPD
mpd_wid = widget({ type = 'textbox', name = 'mpd_wid', align = 'left' })
mpd_wid.text = "[]: not playing"
wicked.register(mpd_wid, 'mpd', ' <span color="white">[Now Playing:</span> $1]')
--Memory
mem_wid = widget({ type = 'textbox', name = 'mem_wid', align = 'left' })
wicked.register(mem_wid, 'mem', function (widget, args)
-- Add extra preceding zeroes when needed
if tonumber(args[1]) < 10 then args[1] = '0'..args[1] end
if tonumber(args[2]) < 1000 then args[2] = '0'..args[2] end
if tonumber(args[3]) < 1000 then args[3] = '0'..args[3] end
return spacer..('[Memory')..': '..args[1]..'% ('..args[2]..'/'..args[3]..')]'..spacer..separator end)
--CPU
cpu_wid = widget({ type = 'textbox', name = 'cpu_wid', align = 'left' })
cpu_wid.text = spacer..('CPU')..': '..spacer..separator
wicked.register(cpu_wid, 'cpu', function (widget, args)
-- Add a zero if lower than 10
if args[1] < 10 then
args[1] = '0'..args[1]
end
return spacer..('[CPU')..': '..args[1]..'%]'..spacer..separator end)
--SYSTRAY
systray_wid = widget({ type = 'systray', name = 'systray_wid', align = 'right' })
--}}}
-- {{{ Statusbar
-- Create a taglist widget
mytaglist = widget({ type = "taglist", name = "mytaglist" })
mytaglist:mouse_add(mouse({ }, 1, function (object, tag) awful.tag.viewonly(tag) end))
mytaglist:mouse_add(mouse({ modkey }, 1, function (object, tag) awful.client.movetotag(tag) end))
mytaglist:mouse_add(mouse({ }, 3, function (object, tag) tag:view(not tag:isselected()) end))
mytaglist:mouse_add(mouse({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end))
mytaglist:mouse_add(mouse({ modkey }, 4, awful.tag.viewnext))
mytaglist:mouse_add(mouse({ modkey }, 5, awful.tag.viewprev))
mytaglist.text_focus = spacer.."<bg color='"..bg_focus.."'/> <span color='"..fg_normal.."'><title/></span>"..spacer
mytaglist.text_urgent = spacer.."<bg color='"..bg_urgent.."'/> <span color='"..fg_urgent.."'><title/></span>"..spacer
function mytaglist.label(t)
local text = ""
if t.selected then
text = "<bg color='"..bg_focus.."'/> <span color='"..fg_focus.."'>"..t.name.."</span> "
elseif t.urgent then
text = "<bg color='"..bg_urgent.."'/> <span color='"..fg_urgent.."'>"..t.name.."</span> "
else
text = " "..t.name.." "
end
return text
end
-- Create a tasklist widget
mytasklist = widget({ type = "tasklist", name = "mytasklist" })
mytasklist:mouse_add(mouse({ }, 1, function (object, c) c:focus_set(); c:raise() end))
mytasklist:mouse_add(mouse({ }, 4, function () awful.client.focus(1) end))
mytasklist:mouse_add(mouse({ }, 5, function () awful.client.focus(-1) end))
mytasklist.text_focus = "<bg color='"..bg_focus.."'/> <span color='"..fg_normal.."'><title/></span>"
mytasklist.text_urgent = "<bg color='"..bg_urgent.."'/> <span color='"..fg_normal.."'><title/></span>"
function mytasklist.label(c)
local text = ""
if c.floating then
text = "<bg image=\"/usr/share/awesome/icons/floatingw.png\" align=\"right\"/>"
end
if client.focus_get() == c then
text = text .. " <bg color='"..bg_focus.."'/><span color='"..awful.escape(fg_focus).."'>"..c.name.."</span> "
else
text = text .. " "..awful.escape(c.name).." "
end
return text
end
-- Create a textbox widget
mytextbox = widget({ type = "textbox", name = "mytextbox", align = "left" })
-- Set the default text in textbox
mytextbox.text = "<b><small> awesome " ..AWESOME_VERSION.. " </small></b>"
-- Create an iconbox widget
myiconbox = widget({ type = "textbox", name = "myiconbox", align = "left" })
myiconbox.text = "<bg image=\"/usr/share/awesome/icons/awesome16.png\" resize=\"true\"/>"
--menubox_wid = widget({ type = "textbox", name = "menubox_wid", align = "left" })
-- Create an iconbox widget which will contains an icon indicating which layout we're using.
-- We need one layoutbox per screen.
mylayoutbox = {}
for s = 1, screen.count() do
mylayoutbox[s] = widget({ type = "textbox", name = "myiconbox", align = "left" })
mylayoutbox[s]:mouse_add(mouse({ }, 1, function () awful.layout.inc(layouts, 1) end))
mylayoutbox[s]:mouse_add(mouse({ }, 3, function () awful.layout.inc(layouts, -1) end))
mylayoutbox[s]:mouse_add(mouse({ }, 4, function () awful.layout.inc(layouts, 1) end))
mylayoutbox[s]:mouse_add(mouse({ }, 5, function () awful.layout.inc(layouts, -1) end))
mylayoutbox[s].text = "<bg image=\"/usr/share/awesome/icons/layouts/tilew.png\" resize=\"true\"/>"
end
-- Create a statusbar for each screen and add it
topbar = {}
botbar = {}
for s = 1, screen.count() do
topbar[s] = statusbar({ position = "top", name = "topbar" .. s,
fg = fg_normal, bg = bg_normal })
botbar[s] = statusbar({ position = "bottom", name = "botbar" .. s,
fg = fg_normal, bg = bg_normal })
-- Add widgets to the statusbar - order matters
topbar[s]:widget_add(mytaglist)
topbar[s]:widget_add(mylayoutbox[s])
topbar[s]:widget_add(mytasklist)
topbar[s]:widget_add(clock_wid)
-- botbar[s]:widget_add(myiconbox)
-- botbar[s]:widget_add(menubox_wid)
botbar[s]:widget_add(mem_wid)
botbar[s]:widget_add(cpu_wid)
botbar[s]:widget_add(mpd_wid)
topbar[s]:add(s)
botbar[s]:add(s)
end
topbar[screen.count()]:widget_add(systray_wid)
-- }}}
-- {{{ Mouse bindings
awesome.mouse_add(mouse({ }, 1, function () awful.rause() end))
awesome.mouse_add(mouse({ }, 3, function () awful.spawn(terminal) end))
awesome.mouse_add(mouse({ }, 4, awful.tag.viewnext))
awesome.mouse_add(mouse({ }, 5, awful.tag.viewprev))
-- {{{ Key bindings
-- Bind keyboard digits
-- Compute the maximum number of digit we need, limited to 9
keynumber = 0
for s = 1, screen.count() do
keynumber = math.min(4, math.max(#tags[s], keynumber));
end
for i = 1, keynumber do
keybinding({ modkey }, i,
function ()
local screen = mouse.screen
if tags[screen][i] then
awful.tag.viewonly(tags[screen][i])
end
end):add()
keybinding({ modkey, "Shift" }, i,
function ()
end):add()
end
keybinding({ modkey }, "Left", awful.tag.viewprev):add()
keybinding({ modkey }, "Right", awful.tag.viewnext):add()
-- Standard program
keybinding({ modkey }, "Return", function () awful.spawn(terminal) end):add()
keybinding({ modkey, "Control" }, "r", awesome.restart):add()
keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
-- Client manipulation
keybinding({ modkey, "Shift" }, "c", function () client.focus_get():kill() end):add()
keybinding({ modkey }, "j", function () awful.client.focus(1); client.focus_get():raise() end):add()
keybinding({ modkey }, "k", function () awful.client.focus(-1); client.focus_get():raise() end):add()
keybinding({ modkey, "Shift" }, "j", function () awful.client.swap(1) end):add()
keybinding({ modkey, "Shift" }, "k", function () awful.client.swap(-1) end):add()
keybinding({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
keybinding({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
keybinding({ modkey, "Control" }, "space", function () awful.client.togglefloating() end):add()
-- Layout manipulation
keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
keybinding({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
keybinding({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
keybinding({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
keybinding({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
keybinding({ modkey, "Control" }, "l", function () awful.tag.incncol(1) end):add()
keybinding({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
--Menu
keybinding({ modkey }, "F2", function ()
awful.prompt({ prompt = " Run ", cursor_fg = fg_focus, cursor_bg = bg_focus }, mymenubox, awful.spawn, awful.completion.bash) end):add()
-- Custom bindings
keybinding({ modkey }, "f", function () awful.spawn(filemanager) end):add()
keybinding({ modkey }, "t", function () awful.spawn(terminal) end):add()
keybinding({ modkey }, "w", function () awful.spawn(webbrowser) end):add()
keybinding({ modkey }, "g", function () awful.spawn(musicplayer) end):add()
keybinding({ modkey }, "z", function () awful.spawn(music_prev) end):add()
keybinding({ modkey }, "x", function () awful.spawn(music_stop) end):add()
keybinding({ modkey }, "v", function () awful.spawn(music_toggle) end):add()
keybinding({ modkey }, "b", function () awful.spawn(music_next) end):add()
-- }}}
-- {{{ Hooks
-- Hook function to execute when focusing a client.
function hook_focus(c)
c.border_color = border_focus
-- c.titlebar_color = ({ fg = '#909090' })
end
-- Hook function to execute when unfocusing a client.
function hook_unfocus(c)
c.border_color = border_unfocus
end
-- Hook function to exeucte when the mouse is over a client.
function hook_mouseover(c)
-- Sloppy focus, but disabled for magnifier layout
c:focus_set()
end
-- Hook function to execute when a new client appears.
function hook_manage(c)
-- New client may not receive focus
-- if they're not focusable, so set border anyway.
c.border_color = border_focus
c.border_width = border_width
c:focus_set()
c.honorsizehints = true
c:mouse_add(mouse({ }, 1, function(c) c:focus_set(); c:raise() end))
c:mouse_add(mouse({ modkey }, 1, function (c) c:mouse_move({ snap = 1, infobox = true }) end))
c:mouse_add(mouse({ modkey }, 3, function (c) c:mouse_resize() end))
function program(p)
return c.class:lower():find(p)
end
if program("pidgin") then
c.floating = true
awful.client.movetotag(tags[1][1])
end
if program("wow") then
c.floating = true
awful.client.movetotag(tags[1][4])
end
if program("mplayer") then
c.floating = true
end
if program("thunar") then
c.floating = true
end
if program("sonata") then
c.floating = true
awful.client.movetotag(tags[1][1])
end
if program("opera") then
awful.client.movetotag(tags[1][2])
end
-- if name ~= "panel" then
-- c:titlebar_set(new_titlebar(c))
-- end
-- Prevents new windows from becoming master
cls = client.visible_get(mouse.screen)
for i,p in pairs(cls) do
if p ~= c then
c:swap(p)
break
end
end
end
-- Hook function to execute when arranging the screen
-- (tag switch, new client, etc)
function hook_arrange(screen)
local layout = awful.layout.get(screen)
mylayoutbox[screen].text = "<bg image=\"/usr/share/awesome/icons/layouts/" .. layout .. "w.png\" resize=\"true\"/>"
end
-- Hook called every 60 seconds
function hook_timer ()
end
-- Hook for urgency hints
function hook_urgent ()
end
-- Set up some hooks
awful.hooks.focus(hook_focus)
awful.hooks.unfocus(hook_unfocus)
awful.hooks.manage(hook_manage)
awful.hooks.mouseover(hook_mouseover)
awful.hooks.arrange(hook_arrange)
awful.hooks.timer(1, hook_timer)
awful.hooks.urgent(hook_urgent)
-- }}}
Offline
hmm I have some experience in Perl and Java, but lua sure ass hell aint no pretty straightfoward. And Im using awesome3 cuz I like to be up to date with the WM.
Offline
awesome - thanks guys. I'll check through my config again, and see whats up... The example rc files should help as well - couldn't find them when i flicked through the wiki the first time, so i'll have another look. Would probs help to take a look at the intro to lua link on the wiki too. Cheers for the help.
Offline