You are not logged in.

#1 2009-02-18 05:07:59

Reasons
Member
From: Washington
Registered: 2007-11-04
Posts: 572

Awesome not reading rc.lua

I'm trying to give awesome3.1 a go, but it isn't reading my rc.lua. It just keeps the default everything. Really all I've changed is the theme.

-- Include awesome libraries, with lots of useful function!
require("awful")
require("beautiful")

-- {{{ Variable definitions
-- Themes define colours, icons, and wallpapers
theme_path = "/home/shawn/.config/awesome/theme"

-- Actually load theme
beautiful.init(theme_path)

-- This is used later as the default terminal and editor to run.
terminal = "xterm"
editor = os.getenv("EDITOR") or "vi"
editor_cmd = terminal .. " -e " .. editor

-- Default modkey.
-- Usually, Mod4 is the key with a logo between Control and Alt.
-- If you do not like this or do not have such a key,
-- I suggest you to remap Mod4 to another key using xmodmap or other tools.
-- However, you can use another modifier like Mod1, but it may interact with others.
modkey = "Mod4"

-- Table of layouts to cover with awful.layout.inc, order matters.
layouts =
{
    "tile",
    "tileleft",
    "tilebottom",
    "tiletop",
    "fairh",
    "fairv",
    "magnifier",
    "max",
    "fullscreen",
    "spiral",
    "dwindle",
    "floating"
}

-- Table of clients that should be set floating. The index may be either
-- the application class or instance. The instance is useful when running
-- a console app in a terminal like (Music on Console)
--    xterm -name mocp -e mocp
floatapps =
{
    -- by class
    ["MPlayer"] = true,
    ["pinentry"] = true,
    ["gimp"] = true,
    -- by instance
    ["mocp"] = true
}

-- Applications to be moved to a pre-defined tag by class or instance.
-- Use the screen and tags indices.
apptags =
{
    -- ["Firefox"] = { screen = 1, tag = 2 },
    -- ["mocp"] = { screen = 2, tag = 4 },
}

-- Define if we want to use titlebar on all applications.
use_titlebar = false
-- }}}

-- {{{ 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, 3 do
        tags[s][tagnumber] = tag({ name = tag_settings[tagnumber].name, layout = tag_settings[tagnumber].layouts })
        -- Add tags to screen one by one
        tags[s][tagnumber].screen = s
    end
    -- I'm sure you want to see at least one tag.
    tags[s][1].selected = true
end


tag_settings = {
    { name="main",  layout=layouts[1]  },
    { name="work",  layout=layouts[1]  },
    { name="float",  layout=layouts[12]  }
-- }}}

-- {{{ Wibox
-- Create a textbox widget
mytextbox = widget({ type = "textbox", align = "right" })
-- Set the default text in textbox
mytextbox.text = "<b><small> " .. AWESOME_RELEASE .. " </small></b>"

-- Create a laucher widget and a main menu
myawesomemenu = {
   { "manual", terminal .. " -e man awesome" },
   { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
   { "restart", awesome.restart },
   { "quit", awesome.quit }
}

mymainmenu = awful.menu.new({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
                                        { "open terminal", terminal }
                                      }
                            })

mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
                                     menu = mymainmenu })

-- Create a systray
mysystray = widget({ type = "systray", align = "right" })

-- Create a wibox for each screen and add it
mywibox = {}
mypromptbox = {}
mylayoutbox = {}
mytaglist = {}
mytaglist.buttons = { button({ }, 1, awful.tag.viewonly),
                      button({ modkey }, 1, awful.client.movetotag),
                      button({ }, 3, function (tag) tag.selected = not tag.selected end),
                      button({ modkey }, 3, awful.client.toggletag),
                      button({ }, 4, awful.tag.viewnext),
                      button({ }, 5, awful.tag.viewprev) }
mytasklist = {}
mytasklist.buttons = { button({ }, 1, function (c) client.focus = c; c:raise() end),
                       button({ }, 3, function () awful.menu.clients({ width=250 }) end),
                       button({ }, 4, function () awful.client.focus.byidx(1) end),
                       button({ }, 5, function () awful.client.focus.byidx(-1) end) }

for s = 1, screen.count() do
    -- Create a promptbox for each screen
    mypromptbox[s] = widget({ type = "textbox", align = "left" })
    -- Create an imagebox widget which will contains an icon indicating which layout we're using.
    -- We need one layoutbox per screen.
    mylayoutbox[s] = widget({ type = "imagebox", align = "right" })
    mylayoutbox[s]:buttons({ button({ }, 1, function () awful.layout.inc(layouts, 1) end),
                             button({ }, 3, function () awful.layout.inc(layouts, -1) end),
                             button({ }, 4, function () awful.layout.inc(layouts, 1) end),
                             button({ }, 5, function () awful.layout.inc(layouts, -1) end) })
    -- Create a taglist widget
    mytaglist[s] = awful.widget.taglist.new(s, awful.widget.taglist.label.all, mytaglist.buttons)

    -- Create a tasklist widget
    mytasklist[s] = awful.widget.tasklist.new(function(c)
                                                  return awful.widget.tasklist.label.currenttags(c, s)
                                              end, mytasklist.buttons)

    -- Create the wibox
    mywibox[s] = wibox({ position = "top", fg = beautiful.fg_normal, bg = beautiful.bg_normal })
    -- Add widgets to the wibox - order matters
    mywibox[s].widgets = { mylauncher,
                           mytaglist[s],
                           mytasklist[s],
                           mypromptbox[s],
                           mytextbox,
                           mylayoutbox[s],
                           s == 1 and mysystray or nil }
    mywibox[s].screen = s
end
-- }}}

-- {{{ Mouse bindings
awesome.buttons({
    button({ }, 3, function () mymainmenu:toggle() end),
    button({ }, 4, awful.tag.viewnext),
    button({ }, 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 ()
                       if client.focus then
                           if tags[client.focus.screen][i] then
                               awful.client.movetotag(tags[client.focus.screen][i])
                           end
                       end
                   end):add()
    keybinding({ modkey, "Control", "Shift" }, i,
                   function ()
                       if client.focus then
                           if tags[client.focus.screen][i] then
                               awful.client.toggletag(tags[client.focus.screen][i])
                           end
                       end
                   end):add()
end

keybinding({ modkey }, "Left", awful.tag.viewprev):add()
keybinding({ modkey }, "Right", awful.tag.viewnext):add()
keybinding({ modkey }, "Escape", awful.tag.history.restore):add()

-- Standard program
keybinding({ modkey }, "Return", function () awful.util.spawn(terminal) end):add()

keybinding({ modkey, "Control" }, "r", function ()
                                           mypromptbox[mouse.screen].text =
                                               awful.util.escape(awful.util.restart())
                                        end):add()
keybinding({ modkey, "Shift" }, "q", awesome.quit):add()

-- Client manipulation
keybinding({ modkey }, "m", awful.client.maximize):add()
keybinding({ modkey }, "f", function () if client.focus then client.focus.fullscreen = not client.focus.fullscreen end end):add()
keybinding({ modkey, "Shift" }, "c", function () if client.focus then client.focus:kill() end end):add()
keybinding({ modkey }, "j", function () awful.client.focus.byidx(1); if client.focus then client.focus:raise() end end):add()
keybinding({ modkey }, "k", function () awful.client.focus.byidx(-1);  if client.focus then client.focus:raise() end end):add()
keybinding({ modkey, "Shift" }, "j", function () awful.client.swap.byidx(1) end):add()
keybinding({ modkey, "Shift" }, "k", function () awful.client.swap.byidx(-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 () if client.focus then client.focus:swap(awful.client.getmaster()) end end):add()
keybinding({ modkey }, "o", awful.client.movetoscreen):add()
keybinding({ modkey }, "Tab", awful.client.focus.history.previous):add()
keybinding({ modkey }, "u", awful.client.urgent.jumpto):add()
keybinding({ modkey, "Shift" }, "r", function () if client.focus then client.focus:redraw() end 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()

-- Prompt
keybinding({ modkey }, "F1", function ()
                                 awful.prompt.run({ prompt = "Run: " }, mypromptbox[mouse.screen], awful.util.spawn, awful.completion.bash,
                                                  awful.util.getdir("cache") .. "/history")
                             end):add()
keybinding({ modkey }, "F4", function ()
                                 awful.prompt.run({ prompt = "Run Lua code: " }, mypromptbox[mouse.screen], awful.util.eval, awful.prompt.bash,
                                                  awful.util.getdir("cache") .. "/history_eval")
                             end):add()

keybinding({ modkey, "Ctrl" }, "i", function ()
                                        local s = mouse.screen
                                        if mypromptbox[s].text then
                                            mypromptbox[s].text = nil
                                        elseif client.focus then
                                            mypromptbox[s].text = nil
                                            if client.focus.class then
                                                mypromptbox[s].text = "Class: " .. client.focus.class .. " "
                                            end
                                            if client.focus.instance then
                                                mypromptbox[s].text = mypromptbox[s].text .. "Instance: ".. client.focus.instance .. " "
                                            end
                                            if client.focus.role then
                                                mypromptbox[s].text = mypromptbox[s].text .. "Role: ".. client.focus.role
                                            end
                                        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()

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.
awful.hooks.focus.register(function (c)
    if not awful.client.ismarked(c) then
        c.border_color = beautiful.border_focus
    end
end)

-- Hook function to execute when unfocusing a client.
awful.hooks.unfocus.register(function (c)
    if not awful.client.ismarked(c) then
        c.border_color = beautiful.border_normal
    end
end)

-- Hook function to execute when marking a client
awful.hooks.marked.register(function (c)
    c.border_color = beautiful.border_marked
end)

-- Hook function to execute when unmarking a client.
awful.hooks.unmarked.register(function (c)
    c.border_color = beautiful.border_focus
end)

-- Hook function to execute when the mouse enters a client.
awful.hooks.mouse_enter.register(function (c)
    -- Sloppy focus, but disabled for magnifier layout
    if awful.layout.get(c.screen) ~= "magnifier"
        and awful.client.focus.filter(c) then
        client.focus = c
    end
end)

-- Hook function to execute when a new client appears.
awful.hooks.manage.register(function (c)
    if use_titlebar then
        -- Add a titlebar
        awful.titlebar.add(c, { modkey = modkey })
    end
    -- Add mouse bindings
    c:buttons({
        button({ }, 1, function (c) client.focus = c; c:raise() end),
        button({ modkey }, 1, function (c) c:mouse_move() end),
        button({ 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 = beautiful.border_width
    c.border_color = beautiful.border_normal

    -- Check if the application should be floating.
    local cls = c.class
    local inst = c.instance
    if floatapps[cls] then
        c.floating = floatapps[cls]
    elseif floatapps[inst] then
        c.floating = floatapps[inst]
    end

    -- Check application->screen/tag mappings.
    local target
    if apptags[cls] then
        target = apptags[cls]
    elseif apptags[inst] then
        target = apptags[inst]
    end
    if target then
        c.screen = target.screen
        awful.client.movetotag(tags[target.screen][target.tag], c)
    end

    -- Do this after tag mapping, so you don't see it on the wrong tag for a split second.
    client.focus = c

    -- Set the windows at the slave,
    -- i.e. put it at the end of others instead of setting it master.
    -- awful.client.setslave(c)

    -- Honor size hints: if you want to drop the gaps between windows, set this to false.
    -- c.honorsizehints = false
end)

-- Hook function to execute when arranging the screen.
-- (tag switch, new client, etc)
awful.hooks.arrange.register(function (screen)
    local layout = awful.layout.get(screen)
    if layout then
        mylayoutbox[screen].image = image(beautiful["layout_" .. layout])
    else
        mylayoutbox[screen].image = nil
    end

    -- Give focus to the latest client in history if no window has focus
    -- or if the current window is a desktop or a dock one.
    if not client.focus then
        local c = awful.client.focus.history.get(screen, 0)
        if c then client.focus = c end
    end

    -- Uncomment if you want mouse warping
    --[[
    if client.focus then
        local c_c = client.focus:fullgeometry()
        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
awful.hooks.timer.register(1, function ()
    -- For unix time_t lovers
    mytextbox.text = " " .. os.time() .. " time_t "
    -- Otherwise use:
    -- mytextbox.text = " " .. os.date() .. " "
end)
-- }}}

Then if I try this one, I just get a black screen, I have all the required things:

-- Version 2
------
-- This config is for use with awesome 3.0 stable.
------
-- If you have any suggestions or questions, feel free
-- to pass me a message, find me in #awesome on OFTC, or
-- email me at <lucas[at]glacicle.com>
------
-- I use both wicked and eminent, so to use it,
-- you'll need to get both those helper libraries too.
------
-- Note that I use all-custom keybindings, so you might
-- want to copy the default rc.lua's keybindings 
-- into here if you wish to use those, although you might
-- find you like mine better :P
------

---- {{{ Require lua libraries
-- Shipped with awesome
require("awful")
require("beautiful")

-- External
require("wicked") -- Widgets
require("eminent") -- Dynamic tagging
-- }}}

---- {{{ 'Beautiful' theme settings
-- Font
beautiful.font = "Dina 8"

-- Background
beautiful.bg_normal = '#414141'
beautiful.bg_focus = '#414141'
beautiful.bg_sbfocus = '#414141'
beautiful.bg_urgent = '#414141'

-- Foreground
beautiful.fg_normal = '#999999'
beautiful.fg_focus = '#335565'
beautiful.fg_urgent = '#A000000'

-- Border
beautiful.border_width = 2
beautiful.border_normal = '#414141'
beautiful.border_focus = '#335565'
beautiful.border_marked = '#91231c'

-- Wallpaper
-- wallpaper_cmd = awsetbg /storage/images/backgrounds/nature/looking.jpg

-- }}}

---- {{{ Modkeys
key = {}
key.none = {}
key.alt = {"Mod1"}
key.super = {"Mod4"}
key.shift = {"Shift"}
key.control = {"Control"}

key.super_alt = {key.super[1], key.alt[1]}
key.super_shift = {key.super[1], key.shift[1]}
key.super_control = {key.super[1], key.control[1]}
key.control_alt = {key.control[1], key.alt[1]}
key.shift_alt = {key.shift[1], key.alt[1]}

-- }}}

---- {{{ Settings
-- Initialise tables
settings = {}
settings.widget = {}
settings.apps = {}
settings.tag = {}
settings.bindings = {}

-- {{{ General
-- Widget spacer and separator
settings.widget_spacer = " "
settings.widget_separator = " "

-- Warp mouse
settings.warp_mouse = true

-- New become master
settings.new_become_master = false

-- Tag mwfact
settings.tag.mwfact = 0.618033988769

-- }}}

-- {{{ Applications
-- Terminal application
settings.apps.terminal = 'urxvt'

-- Command to lock the screen
settings.apps.lock_screen = 'xscreensaver-command -lock'

-- Command to turn screen off with DPMS
settings.apps.screen_off = 'sleep 1; xset dpms force off'

-- File manager application
settings.apps.filemanager = settings.apps.terminal..' -e zsh -c "vifm %s"'

-- }}}

-- {{{ Floating windows
settings.floating = {
    ["gimp"] = true,
    ["urxvtcnotify"] = true,
    ["MPlayer"] = true,
}

-- }}}

-- {{{ Other
-- Check what widget mode to use
    settings.widget_mode = 'desktop'

-- Highlight statusbar of focussed screen on multiple-monitor setups
if screen.count() > 1 then
    settings.statusbar_highlight_focus = {true, 1}
end

-- }}}

-- }}}

---- {{{ Keybindings
-- Initialise table
settings.bindings.wm = {}
settings.bindings.mouse = {}

-- {{{ Open the filemanager at specific locations
settings.bindings.filemanager = {
    -- Alt+d: Data partition
    ["/storage"] = {key.alt, "#40"},

    -- Alt+a: Home Directory
    [os.getenv("HOME")] = {key.alt, "#38"},
}
-- }}}

-- {{{ Run specific commands
settings.bindings.commands = {
    -- Alt+q: Open Terminal
    [settings.apps.terminal] = {key.alt, "#24"},

    -- Mod+k: GNU Screen
    -- [settings.apps.gnu_screen] = {key.super, "#45"},

    -- Mod+l: Lock screen
    [settings.apps.lock_screen] = {key.super, "#46"},

    -- Mod+o: Screen off with DPMS
    [settings.apps.screen_off] = {key.super, "#32"},
}
-- }}}



-- {{{ Tag bindings
settings.bindings.wm.tag = {
    -- Mod+a: Switch to previous tag
    [function() eminent.tag.prev(mouse.screen) end] = {key.super, "#38"},

    -- Mod+s: Switch to next tag
    [function() eminent.tag.next(mouse.screen) end] = {key.super, "#39"},

    -- Alt+\: Switch to float layout
    [function() awful.layout.set('floating') end] = {key.alt, "#51"},

    -- Alt+z: Switch to max layout
    [function() awful.layout.set('max') end] = {key.alt, "#52"},

    -- Alt+x: Switch to tile layout
    [function() awful.layout.set('tile') end] = {key.alt, "#53"},
}
-- }}}

-- {{{ Prompt bindings
settings.bindings.prompt = {
    -- Alt+w: Run prompt
    [{awful.spawn, " Run: "}] = {key.alt, "#25"},

    -- Mod+Alt+w: Lua eval prompt
    [{awful.eval, " Run Lua: "}] = {key.super_alt, "#25"},
}

-- }}}

-- {{{ Miscellaneous bindings
settings.bindings.wm.misc = {
    -- Mod+Alt+r: Restart awesome
    [awesome.restart] = {key.super_alt, "#27"},

    -- Mod+e: Switch focus to next screen
    [function() awful.screen.focus(1) end] = {key.super, "#26"},

    -- Mod+d: Switch focus to previous screen
    [function() awful.screen.focus(-1) end] = {key.super, "#40"},
}
-- }}}

-- {{{ Keyboard digit bindings
settings.bindings.digits = {
    -- Mod+##: View tag
    [awful.tag.viewonly] = key.super,

    -- Mod+Shift+##: Toggle tag view
    [function(t) t.selected = not t.selected end] = key.super_shift,

    -- Mod+Control+##: Move window to tag
    [awful.client.movetotag] = key.super_control,

    -- Mod+Alt+##: Toggle window on tag
    [awful.client.toggletag] = key.super_alt,

}
-- }}}

-- {{{ Mouse bindings
settings.bindings.mouse.desktop = {
    -- Right click on desktop: Open terminal
    [function() awful.spawn(settings.apps.terminal) end] = {key.none, 3},
}

settings.bindings.mouse.client = {
    -- Alt+Left: Move window
    [function(c) c:mouse_move() end] = {key.alt, 1},

    -- Alt+Right: Resize window
    [function(c) c:mouse_resize({corner="bottomright"}) end] = {key.alt, 3},
}
-- }}}

-- }}}

---- {{{ Markup helper functions
-- Inline markup is a tad ugly, so use these functions
-- to dynamically create markup, we hook them into
-- the beautiful namespace for clarity.
beautiful.markup = {}

function beautiful.markup.bg(color, text)
    return '<bg color="'..color..'" />'..text
end

function beautiful.markup.fg(color, text)
    return '<span color="'..color..'">'..text..'</span>'
end

function beautiful.markup.font(font, text)
    return '<span font_desc="'..font..'">'..text..'</span>'
end

function beautiful.markup.title(t)
    return t
end

function beautiful.markup.title_normal(t)
    return beautiful.title(t)
end

function beautiful.markup.title_focus(t)
    return beautiful.markup.bg(beautiful.bg_focus, beautiful.markup.fg(beautiful.fg_focus, beautiful.markup.title(t)))
end

function beautiful.markup.title_urgent(t)
    return beautiful.markup.bg(beautiful.bg_urgent, beautiful.markup.fg(beautiful.fg_urgent, beautiful.markup.title(t)))
end

function beautiful.markup.bold(text)
    return '<b>'..text..'</b>'
end

function beautiful.markup.heading(text)
    return beautiful.markup.fg(beautiful.fg_focus, beautiful.markup.bold(text))
end

-- }}}

---- {{{ Widgets
settings.statusbars = {}
settings.widgets = {}

settings.statusbars[1] = {{
    position = "top",
    height = 18,
    fg = beautiful.fg_normal,
    bg = beautiful.bg_normal,
    name = "mainstatusbar",
}, "all"}

settings.promptbar = {
    position = "top",
    height = 18,
    fg = beautiful.fg_normal,
    bg = beautiful.bg_normal,
    name = "promptbar",
}

-- {{{ Taglist
maintaglist = widget({ 
    type = 'taglist', 
    name = 'maintaglist' 
})

function maintaglist.label(t)
    return awful.widget.taglist.label.noempty(t)
end

maintaglist:mouse_add(mouse(key.none, 1, function (o, t) awful.tag.viewonly(t) end))

table.insert(settings.widgets, {1, maintaglist})
-- }}}

if settings.widget_mode ~= 'none' then
-- {{{ MPD Widget
mpdwidget = widget({
    type = 'textbox',
    name = 'mpdwidget',
    align = 'right'
})

wicked.register(mpdwidget, wicked.widgets.mpd, function (widget, args)
    -- I don't want the stream name on my statusbar, so I gsub it out,
    -- feel free to remove this bit
    return settings.widget_spacer..beautiful.markup.heading('MPD')..': '
    ..args[1]:gsub('AnimeNfo Radio  | Serving you the best Anime music!: ','')
    ..settings.widget_spacer..settings.widget_separator end)

table.insert(settings.widgets, {1, mpdwidget})

-- }}}

-- {{{ GMail Widget
gmailwidget = widget({
    type = 'textbox',
    name = 'gmailwidget',
    align = 'right'
})

gmailwidget:mouse_add(mouse(key.none, 1, function () wicked.update(gmailwidget) end))

function read_gmail_temp(format)
    local f = io.open('/tmp/gmail-temp')

    if f == nil then 
        return {'n/a'}
    end

    local n = f:read()

    if n == nil or f == ' ' or f == '' then
        f:close()
        return {'n/a'}
    end

    return {n}
end


wicked.register(gmailwidget, read_gmail_temp, function (widget, args)
    local n = args[1]

    local out = settings.widget_spacer..beautiful.markup.heading('GMail')..': '

    if n ~= "n/a" and tonumber(n) > 0 then
        out = out..beautiful.markup.bg(beautiful.bg_urgent, beautiful.markup.fg(beautiful.fg_urgent, tostring(n)))
    else
        out = out..tostring(n)
    end

    out = out..settings.widget_spacer..settings.widget_separator

    return out
end, 120)

-- Start timer to fill the temp file
awful.hooks.timer.register(110, function ()
    -- Call GMail check script to check for new email
    os.execute(os.getenv("HOME")..'/other/.gmail.py > /tmp/gmail-temp &')
end, true)

wicked.update(gmailwidget)

table.insert(settings.widgets, {1, gmailwidget})

-- }}}

-- {{{ Load Averages Widget
loadwidget = widget({
    type = 'textbox',
    name = 'loadwidget',
    align = 'right'
})

function widget_loadavg(format)
    -- Use /proc/loadavg to get the average system load on 1, 5 and 15 minute intervals
    local f = io.open('/proc/loadavg')
    local n = f:read()
    f:close()

    -- Find the third space
    local pos = n:find(' ', n:find(' ', n:find(' ')+1)+1)

    return {n:sub(1,pos-1)}
end

wicked.register(loadwidget, widget_loadavg,
    settings.widget_spacer..beautiful.markup.heading('Load')..': $1'..settings.widget_spacer..settings.widget_separator, 2)

table.insert(settings.widgets, {1, loadwidget})

-- }}}

-- {{{ CPU Usage Widget
cputextwidget = widget({
    type = 'textbox',
    name = 'cputextwidget',
    align = 'right'
})

wicked.register(cputextwidget, wicked.widgets.cpu, 
    settings.widget_spacer..beautiful.markup.heading('CPU')..': $1%'..settings.widget_spacer..settings.widget_separator,
nil, nil, 2) 

table.insert(settings.widgets, {1, cputextwidget})

-- }}}

-- {{{ CPU Graph Widget
cpugraphwidget = widget({
    type = 'graph',
    name = 'cpugraphwidget',
    align = 'right'
})


cpugraphwidget.height = 0.85
cpugraphwidget.width = 45
cpugraphwidget.bg = '#333333'
cpugraphwidget.border_color = '#0a0a0a'
cpugraphwidget.grow = 'left'


cpugraphwidget:plot_properties_set('cpu', {
    fg = '#AEC6D8',
    fg_center = '#285577',
    fg_end = '#285577',
    vertical_gradient = false
})

wicked.register(cpugraphwidget, wicked.widgets.cpu, '$1', 1, 'cpu')
table.insert(settings.widgets, {1, cpugraphwidget})

-- }}}

-- {{{ Memory Usage Widget
memtextwidget = widget({
    type = 'textbox',
    name = 'memtextwidget',
    align = 'right'
})

wicked.register(memtextwidget, wicked.widgets.mem,
    settings.widget_spacer..beautiful.markup.heading('MEM')..': '..
    '$1% ($2/$3)'..settings.widget_spacer..settings.widget_separator,
3, nil, {2, 4, 4})

table.insert(settings.widgets, {1, memtextwidget})

-- }}}

-- {{{ Memory Graph Widget
memgraphwidget = widget({
    type = 'graph',
    name = 'memgraphwidget',
    align = 'right'
})

memgraphwidget.height = 0.85
memgraphwidget.width = 45
memgraphwidget.bg = '#333333'
memgraphwidget.border_color = '#0a0a0a'
memgraphwidget.grow = 'left'

memgraphwidget:plot_properties_set('mem', {
    fg = '#AEC6D8',
    fg_center = '#285577',
    fg_end = '#285577',
    vertical_gradient = false
})

wicked.register(memgraphwidget, wicked.widgets.mem, '$1', 1, 'mem')
table.insert(settings.widgets, {1, memgraphwidget})

-- }}}

-- {{{ Other Widget
settings.widget_spacerwidget = widget({ type = 'textbox', name = 'settings.widget_spacerwidget', align = 'right' })
settings.widget_spacerwidget.text = settings.widget_spacer..settings.widget_separator
table.insert(settings.widgets, {1, settings.widget_spacerwidget})

-- }}}
end

-- }}}

-------------------------------------------------------
-- You shouldn't have to edit the code after this, 
-- it takes care of applying the settings above.
-------------------------------------------------------

---- {{{ Initialisations
-- Register beautiful with awful
awful.beautiful.register(beautiful)

-- Set default colors
awesome.colors_set({ 
    fg = beautiful.fg_normal, 
    bg = beautiful.bg_normal })

-- Set default font
awesome.font_set(beautiful.font)

-- Table of layouts to cover with awful.layout.inc, order matters.
layouts =
{
    "tile",
    "tileleft",
    "tilebottom",
    "tiletop",
    "fairh",
    "fairv",
    "magnifier",
    "max",
    "fullscreen",
    "spiral",
    "dwindle",
    "floating"
}

-- Define tag tables
tag_settings = {
    { name="main",  layout=layouts[1]  },
    { name="work",  layout=layouts[1]  },
    { name="float",  layout=layouts[12]  }
}

-- Initialize tags in awesome 3.1
tags = {}
for s = 1, screen.count() do
    tags[s] = {}
    for tagnumber = 1, 3 do
        tags[s][tagnumber] = tag({ name = tag_settings[tagnumber].name, layout = tag_settings[tagnumber].layout })
        tags[s][tagnumber].screen = s
        awful.layout.set(layouts[1], tags[s][tagnumber])
    end
    tags[s][1].selected = true
end


-- }}}

---- {{{ Create statusbars
local mainstatusbar = {}

for i, b in pairs(settings.statusbars) do
    mainstatusbar[i] = {}

    for s=1,screen.count() do
        this_screen = false

        if b[2] ~= "all" then
            for sc in pairs(b[2]) do
                if sc == s then
                    this_screen = true
                    break
                end
            end
        end

        if b[2] == "all" or this_screen then
            mainstatusbar[i][s] = statusbar(b[1])
            local widgets = {}

            for ii, w in pairs(settings.widgets) do
                if w[1] == i then
                    table.insert(widgets, w[2])
                end
            end

            mainstatusbar[i][s]:widgets(widgets)
            mainstatusbar[i][s].screen = s
        end
    end
end

-- }}}

---- {{{ Create prompt statusbar
local mainpromptbar = statusbar(settings.promptbar)
local mainpromptbox = widget({type = "textbox", align = "left", name = "mainpromptbox"})

mainpromptbar:widgets({mainpromptbox})
mainpromptbar.screen = nil

-- }}}

---- {{{ Useful functions
-- {{{ Mouse warp function
function mouse_warp(c, force)
    -- Allow skipping a warp
    if warp_skip then
        warp_skip = false
        return
    end

    -- Get vars
    local sel = c or client.focus
    if sel == nil then return end

    local coords = sel:coords()
    local m = mouse.coords()

    -- Settings
    mouse_padd = 6
    border_area = 5
    
    -- Check if mouse is not already inside the window
    if  (( m.x < coords.x-border_area or
           m.y < coords.y-border_area or
           m.x > coords.x+coords.width+border_area or
           m.y > coords.y+coords.height+border_area
        ) and (
           table.maxn(m.buttons) == 0
        )) or force
    then
        mouse.coords({ x=coords.x+mouse_padd, y=coords.y+mouse_padd})
    end
end
-- }}}

-- {{{ Prompt with statusbar
function prompt_statusbar(s, callback, prompt)
    if not callback then callback = awful.spawn end
    if not prompt then prompt = " Run: " end

    for i, b in pairs(mainstatusbar) do
        for ii, bb in pairs(b) do
            if bb.screen == s then
                bb.screen = nil
            end
        end 
    end

    mainpromptbar.screen = s

    awful.prompt.run({prompt = prompt}, mainpromptbox, callback, 
        awful.completion.bash, os.getenv("HOME") .. "/.cache/awesome_history", 50, function ()
            mainpromptbar.screen = nil

            for i, b in pairs(mainstatusbar) do
                for ii, bb in pairs(b) do
                    if ii == s then
                        bb.screen = ii
                    end
                end 
            end
        end)
end

-- }}}
-- }}}

---- {{{ Create bindings
--- This reads the binding tables and turns them into actual keybindings

-- Always qwerty

-- WM Bindings
for i,table in pairs(settings.bindings.wm) do
    for f, keys in pairs(table) do
        keybinding(keys[1], keys[2], f):add()
    end
end

-- Keyboard digit bindings
for i=1,9 do
    for f, mod in pairs(settings.bindings.digits) do
        keybinding(mod, i, function()
            t = eminent.tag.getn(i, nil, true)
            if not t then return end
            f(t)
        end):add()
    end
end

-- Prompt Bindings
for prompt, keys in pairs(settings.bindings.prompt) do
    keybinding(keys[1], keys[2], function() prompt_statusbar(mouse.screen, unpack(prompt)) end):add()
end

-- Filemanager bindings
for loc, keys in pairs(settings.bindings.filemanager) do
    keybinding(keys[1], keys[2], function() awful.spawn(string.format(settings.apps.filemanager, loc)) end):add()
end

-- Custom command bindings
for command, keys in pairs(settings.bindings.commands) do
    keybinding(keys[1], keys[2], function() awful.spawn(command) end):add()
end

-- Desktop mouse bindings
for f, keys in pairs(settings.bindings.mouse.desktop) do
    awesome.mouse_add(mouse(keys[1], keys[2], f))
end

-- }}}

---- {{{ Set hooks

-- {{{ Focus hook
awful.hooks.focus.register(function (c)

    -- Skip over my urxvtcnotify
    if c.name and c.name:lower():find('urxvtcnotify') and awful.client.next(1) ~= c then
        awful.client.focusbyidx(1)
        return
    end

    -- Set border
    c.border_color = beautiful.border_focus

    -- Raise the client
    c:raise()

    -- Set statusbar color
    if settings.statusbar_highlight_focus and settings.statusbar_highlight_focus[1] then
        if last_screen == nil or last_screen ~= c.screen then
            mainstatusbar[settings.statusbar_highlight_focus[2]][c.screen].bg = beautiful.bg_sbfocus

            if last_screen then
                mainstatusbar[settings.statusbar_highlight_focus[2]][last_screen].bg = beautiful.bg_normal
            end
        end

        last_screen = c.screen
    end

end)
-- }}}

-- {{{ Unfocus hook
awful.hooks.unfocus.register(function (c)
    -- Set border
    c.border_color = beautiful.border_normal
end)
-- }}}

-- {{{ Mouseover hook
awful.hooks.mouseover.register(function (c)
    -- Set focus for sloppy focus
    client.focus = c
end)
-- }}}

-- {{{ Manage hook
awful.hooks.manage.register(function (c)
    local class = ""
    local name = ""

    if c.class then
        class = c.class:lower()
    end

    if c.name then
        name = c.name:lower()
    end

    -- Create border
    c.border_width = beautiful.border_width
    c.border_color = beautiful.border_normal

    -- Add mouse bindings
    for f, keys in pairs(settings.bindings.mouse.client) do
        c:mouse_add(mouse(keys[1], keys[2], f))
    end

    -- Check if floating
    for app, i in pairs(settings.floating) do
        if class:find(app) or name:find(app) then
            c.floating = i
            break
        end
    end

    if name:find('urxvtcnotify') then
        -- I got sick of libnotify/notification-daemon
        -- and their dependencies, so I'm using a little
        -- urxvtc window with some text in it as notifications :P
        -- This makes it appear at the correct place,
        -- feel free to remove the whole section, you probably
        -- won't need it.

        c.screen = 3

        c:coords({
            x = 1680*2+1400,
            y = 18,
            width = 276,
            height = 106
        })

        c.border_color = beautiful.border_normal

        local tags = {}
        for i,t in pairs(eminent.tags[3]) do
            if eminent.tag.isoccupied(3, t) then
                table.insert(tags, t)
            end
        end

        c:tags(tags)

        return 0
    end

    -- Focus new clients
    client.focus = c

    -- Prevent new windows from becoming master
    if not settings.new_become_master then
        awful.client.swap(1, c)
    end

    -- Don't honor size hints
    c.honorsizehints = false
end)
-- }}}

-- {{{ Arrange hook
awful.hooks.arrange.register(function(s)
    -- Warp the mouse
    if settings.warp_mouse then
        mouse_warp()
    end

    -- Check focus
    if not client.focus then
        local c = awful.client.focus.history.get(s, 0)
        if c then client.focus = c end
    end
end)
-- }}}

-- }}}

-- vim: set filetype=lua fdm=marker tabstop=4 shiftwidth=4 expandtab smarttab autoindent smartindent nu:

Offline

#2 2009-02-18 08:40:35

WhiteMagic
Member
Registered: 2007-03-01
Posts: 85

Re: Awesome not reading rc.lua

The most likely reason for you seeing the default settings, or nothing is that there is some error in the configuration file. You would have to take a look at the error output of xorg. Since I start X using startx I can look at it on the first sterminal (ALT - CTRL - F1). I don't know where the output would go if you use GDM or something similar.
If there are errors you could post them here and people might be able to help.

If the comment of the second config file is correct then the config most likely wont work with awesome 3.1 since the sytax of the config file changed between 3.0 and 3.1

Another possibility to get a working config would be to copy the default awesome config into your ~/.config/awesome folder and then gradually make changes to it, exchanging content for stuff from other configs, that way you'd know which change brakes something.

Offline

#3 2009-02-18 09:43:03

Gigamo
Member
Registered: 2008-01-19
Posts: 394

Re: Awesome not reading rc.lua

Try copying over /etc/xdg/awesome/rc.lua to ~/.config/awesome, and change what you want from there. Big chance other people's configuration files are incompatible with the version you are running. smile

(Mine is usually up to date for the latest -git version.)

Offline

#4 2009-02-18 20:57:44

Reasons
Member
From: Washington
Registered: 2007-11-04
Posts: 572

Re: Awesome not reading rc.lua

I've got one semi-working now by starting from scratch, thank you. I can't find any documentation on how to set up keybindings though, or how to reference alt and control keys.

Offline

#5 2009-02-18 22:23:55

Gigamo
Member
Registered: 2008-01-19
Posts: 394

Re: Awesome not reading rc.lua

Reasons wrote:

I've got one semi-working now by starting from scratch, thank you. I can't find any documentation on how to set up keybindings though, or how to reference alt and control keys.

table.insert(globalkeys, key({ modkey, "Alt", "Control" }, "key", function () foo() end))

smile

Offline

#6 2009-02-20 03:06:34

cwjiof
Member
From: Taichung, TW
Registered: 2008-01-27
Posts: 131

Re: Awesome not reading rc.lua

I wonder what to do when awesome changes it's rc.lua structure and rc.lua stops working. Can we know what lines of the config are not correct?

Last edited by cwjiof (2009-02-20 03:09:05)

Offline

#7 2009-02-20 03:10:51

Kknd
Member
From: Brazil, Santa Catarina
Registered: 2007-08-15
Posts: 100
Website

Re: Awesome not reading rc.lua

You can check syntax erros by running luac -p rc.lua.

Offline

Board footer

Powered by FluxBB