Hello,

On startup, stderr says:

W: awesome: luaA_dofunction:323: error running function: invalid object

That does not tell me anything. If I switch a window to floating and touch the 
titlebar with the mouse, I get:

W: awesome: luaA_dofunction:323: error running function: 
/usr/share/awesome/lib/awful/hooks.lua:45: bad argument #1 to 'pairs' (table 
expected, got nil)

I have this in my default theme:

# Display close button inside titlebar
titlebar_close_button = true
titlebar_maximize_button = true

Which path should I set in my config? I set:

beautiful.init("/home/ls/.config/awesome/default")

(Which is the correct path).
I use the git version of awesome on arch linux.

I attached my config and the default theme.

Thanks!
Nathan

On Thu, Nov 20, 2008 at 06:42:10PM +0100, Julien Danjou wrote:
> At 1227202493 time_t, Nathan Huesken wrote:
> > But since I upgraded to awesome 3.1, the titlebar has no close button 
> > anymore.
> > How can I get the close button back?
> 
> Watch std{err,out}, you may have errors.
> 
> -- 
> Julien Danjou
> // ᐰ <[EMAIL PROTECTED]>   http://julien.danjou.info
> // 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD



-- 
 _______________________________________ 
/  "My ethicator machine must've had a  \
| built-in moral compromise             |
|                                       |
| spectral release phantasmatron! I'm a |
\ genius!" --- Calvin                   /
 --------------------------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
---------------------------
-- Default awesome theme --
---------------------------

font          = arial bold 10

bg_normal     = #000000
bg_focus      = #000080
bg_urgent     = #ff0000

fg_normal     = #aaaaaa
fg_focus      = #ffffff
fg_urgent     = #0000ff

border_width  = 2
border_normal = #0000ff
border_focus  = #ff0000
border_marked = #91231c

titlebar_bg_normal = #404040
titlebar_bg_focus = #0000aa
titlebar_fg_normal = #aaaaaa
titlebar_fg_focus = #ffffff

taglist_bg_normal = #000000
taglist_bg_focus = #000000
taglist_fg_normal = #ff0000
taglist_fg_focus = #ff0000
taglist_bg_urgent = #ff0000
taglist_fg_urgent = #0000ff
taglist_fg_empty = #aaaa00
taglist_bg_empty = #000000

# Display the taglist squares
taglist_squares = false

# You can add as many variables as
# you wish and access them by using
# beautiful.variable in your rc.lua
#bg_widget    = #cc0000

# Display close button inside titlebar
titlebar_close_button = true
titlebar_maximize_button = true

# Define the image to load
@ (if titlebar_close_button_[normal|focus] these values are ignored)
#titlebar_close_button_img_normal = /titlebar/closea.png
#titlebar_close_button_img_focus = /titlebar/closera.png
# Or create your own close button
#titlebar_close_button_normal = <span>...</span>
#titlebar_close_button_focus = <span>...</span>

# You can use your own command to set your wallpaper
wallpaper_cmd = awsetbg ~/background.png
-- Create tags for our 9 workspaces
require("awful")
require("beautiful")
require("wicked")

beautiful.init("/home/ls/.config/awesome/default")
-- awful.beautiful.register(beautiful)

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

terminal = "urxvt +sb -bc -fg white -bg black -vb -tn rxvt -fade 20"

floatapps =
{
   ["mplayer"] = true,
   ["gimp"] = true,
   ["vlc"] = true
}

-- Execute command and return its output. You probably wan't only execute 
commands with one
-- line of output
function execute_command(command)
   local fh = io.popen(command)
   local str = ""
   for i in fh:lines() do
      str = str .. i
   end
   io.close(fh)
   return str
end

-- Create tags
tags = {}
for i=1,9 do
   tags[i]=tag({name = tostring(i), layout = "fairv"})
   tags[i].screen=1
   keybinding( {"Mod1"}, "F"..i, function() awful.tag.viewonly(tags[i]) 
end):add()
   keybinding( {"Control"}, "F"..i, function() tags[i].selected=not 
tags[i].selected end):add()
   keybinding( {"Mod1", "Shift"}, "F"..i, function()
                                                                                
         local sel = client.focus
                                                                                
         if sel then
                                                                                
                awful.client.movetotag(tags[i])
                                                                                
          end
                                                                                
  end):add()
   keybinding( {"Control", "Shift"}, "F"..i, function()
                                                                                
                local sel = client.focus
                                                                                
                if sel then
                                                                                
                   awful.client.toggletag(tags[i])
                                                                                
                end
                                                                                
         end):add()
end
tags[1].selected=true

-- Select screen bindings
keybinding( {"Mod1"}, "R", function() awful.screen.focus(1) end):add()
keybinding( {"Mod1"}, "E", function() awful.screen.focus(2) end):add()

-- tags[2].screen=2

-- Taglist
function label_func(t, args)
   local fg_focus = beautiful.taglist_fg_focus
   local bg_focus = beautiful.taglist_bg_focus
   local fg_empty = beautiful.taglist_fg_empty
   local bg_empty = beautiful.taglist_bg_empty
   local fg_normal = beautiful.taglist_fg_normal
   local bg_normal = beautiful.taglist_bg_normal
   local fg_urgent = beautiful.taglist_fg_urgent
   local bg_urgent = beautiful.taglist_bg_urgent
   local text
   local background = ""
   local sel = client.focus
   local bg_color = bg_empty
   local fg_color = fg_empty
   if t.selected then
          background = "resize=\"false\" 
image=\"/home/ls/.config/awesome/focus_back.png\""
          bg_color = bg_focus
      fg_color = fg_focus
   else
          for k, c in pairs(t:clients()) do
                 if not taglist_squares or taglist_squares == "true" then
                        bg_color = bg_normal
                        fg_color = fg_normal
                 end
                 if c.urgent then
                        if os.time() % 2 == 1 then
                           bg_color = bg_urgent
                           fg_color = fg_urgent
                           break
                        end
                 end
          end
   end
   text = "<bg "..background.." color='"..bg_color.."'/> <span 
color='"..fg_color.."'>".. awful.util.escape(t.name).."</span> "
   return text
end

-- Return a label for the battery
function get_battery_label()
   local full = execute_command("cat  /sys/class/power_supply/BAT0/energy_full")
   local now = execute_command("cat  /sys/class/power_supply/BAT0/energy_now")
   local ac = execute_command("cat /sys/class/power_supply/AC/online")
   local text = "BAT: "
   
   local percentage = math.ceil(100*now/full)
   if percentage <= 10 then
          text = text .. "<span color=\"#ff0000\">"
   else if percentage <=50 then
                 text = text .. "<span color=\"#ffff00\">"
          else
                 text = text .."<span color=\"#00ff00\">"
          end
   end
   text = text .. percentage .. "</span>%"

   if ac == "1" then
          text = text .. "(<span color=\"#0000ff\">↑</span>)"
   else
          text = text .. "(<span color=\"#ffff00\">↓</span>)"
   end
   
   return text
end

-- battery display
mybattwidget = widget({type = "textbox", name = "mybattwidget", align="right"})
-- mybattwidget.text = get_battery_label()

-- common spacer
tb_spacer_l = widget({ type = "textbox", name = "tb_spacer", align="left"})
tb_spacer_l.text=" ][ "

tb_spacer_r = widget({ type = "textbox", name = "tb_spacer", align="right"})
tb_spacer_r.text=" ][ "

-- taglist
mytaglist = awful.widget.taglist.new(1, label_func, {})

-- tasklist
mybuttons = {
   button({}, 1, function (c) client.focus = c; c:raise() end),
}
mytasklist = awful.widget.tasklist.new(function(c) return 
awful.widget.tasklist.label.currenttags(c, 1) end, {})

-- Display if we pressed CtrlX
keychaintextbox = widget({ type= "textbox" , name = "keychaintextbox" , 
align="right"})
keychaintextbox.text = "-----"

-- Display the date
datetextbox = widget ({ type= "textbox", name = "date", align="right"})
datetextbox.text = "<span color=\"white\">" .. os.date("%H:%M") .. "</span>" .. 
 " <span color=\"yellow\">" .. os.date("(%d/%m)") .. "</span>"

-- Wlan display
wlantextbox = widget({type= "textbox", name = "wlantextbox", align="right"})
wlantextbox.text = execute_command("/usr/bin/test -e /tmp/wlan-working && echo 
\"Working ...\" || /usr/sbin/iwconfig wlan0 | 
/home/ls/.config/awesome/wlan_scan")

-- net-speed
netwidget = widget({
    type = 'textbox',
    name = 'netwidget',
                                          align = "right"
})

wicked.register(netwidget, wicked.widgets.net, 
    ' | <span color=\"white\">↑</span>=${wlan0 up_kb} /  <span 
color=\"white\">↓</span>=${wlan0 down_kb}',
nil, nil, 3)


-- volume display
volumetextbox = widget({type= "textbox", name = "soundtextbox", align="right"})
volumetextbox.text = "Vol: " .. execute_command("/usr/bin/amixer | 
/home/ls/.config/awesome/sound_scan")

function hook_time()
   datetextbox.text = "<span color=\"white\">" .. os.date("%H:%M") .. "</span>" 
..  " <span color=\"yellow\">" .. os.date("(%d/%m)") .. "</span>"
    wlantextbox.text = execute_command("/usr/bin/test -e /tmp/wlan-working && 
echo \"<span color=\\\"yellow\\\">Working ...</span>\" || /usr/sbin/iwconfig 
wlan0 | /home/ls/.config/awesome/wlan_scan")
        volumetextbox.text = "Vol: " .. execute_command("/usr/bin/amixer | 
/home/ls/.config/awesome/sound_scan")
        mybattwidget.text=get_battery_label()
end

-- Systray
mysystray = widget({type = "systray", name = "mysystray", align="right"})

-- Create Statusbar
mystatusbar = wibox({ position = "bottom", name = "topstatusbar" , fg= 
beautiful.fg_normal, bg=beautiful.bg_normal})
mystatusbar.widgets={ mytaglist,tb_spacer_l,
                                           mytasklist,tb_spacer_r,
                                           volumetextbox,tb_spacer_r,
                                           wlantextbox,netwidget,tb_spacer_r,
                                           mybattwidget,tb_spacer_r,
                                           keychaintextbox,tb_spacer_r,
                                           datetextbox,
                                           mysystray}
mystatusbar.screen = 1

--Universal Ctrl-x Ctrl-c close window
function ctrl_x_function(modifier,key)
   if key == "c" then
          if modifier.Control then
                client.focus:kill()
         end
   end
   keychaintextbox.text="-----"
   return false
end

function set_floating_props(c)
   if not (c.class=="<unknown>") then
          if c.floating or c.floating_placement then
                 awful.titlebar.add(c)
                 c:buttons({
                                button({ }, 1, function(c) client.focus = c; 
c:raise() end),
                                button({ "Mod1" }, 1, function(c) 
c:mouse_move() end),
                                button({ "Mod1" }, 3, function(c) 
c:mouse_resize() end)
                         })
                 c.floating_placement= "smart"
          else
                 c:buttons({
                                button({ }, 1, function(c) client.focus = c; 
c:raise() end)
                         })
                 awful.titlebar.remove(c)
          end
   end
end


function client_floating_toggle(c)
    if c then
           c.floating = not c.floating
           set_floating_props(c)
        end
end

function keychain_ctrl_x_add()
   keychaintextbox.text="<bg color=\"red\"/> <span 
color=\"green\">Ctrl-x</span> "
   keygrabber.run(ctrl_x_function)
end

function keychain_alt_parantese_add()
   keychaintextbox.text="<bg color=\"red\"/> <span color=\"green\">Alt-] 
</span> "
   keygrabber.run(alt_paranthese_function)
end
keybinding({ "Mod1" }, "bracketright", keychain_alt_parantese_add):add()

 -- focus hook
function property_hook(c,name)
   if (name=="name") then
          reset_keychain(c)
   end
end

function reset_keychain(c)
   -- add the binding
   keychaintextbox.text="-----"
   keybinding({ "Control"}, "x", keychain_ctrl_x_add):add()
   -- no client, then we are done
   if not c then
          return
   end
   -- if we are emacs, remove it again
   if (string.lower(c.class) == "emacs") then
          keychaintextbox.text="OFF"
          keybinding({ "Control"}, "x", keychain_ctrl_x_add):remove()
          return
   end
   if (string.lower(c.class) == "urxvt") then
          keychaintextbox.text="OFF"
          keybinding({ "Control"}, "x", keychain_ctrl_x_add):remove()
          return
   end
   -- if it is urxvt, then check if it has children
   -- if (string.lower(c.class)=="urxvt") then
        --  local command = "pstree " .. c.pid
          --local fh = io.popen(command)
          --local str = ""
          --for i in fh:lines() do
                -- str = str .. i
          --end
          --io.close()

          --if not (str == "urxvt---bash" or str == "urxvt---bash---bash") then
        --       keychaintextbox.text= "DISABLED"
        --       keybinding({ "Control"}, "x", keychain_ctrl_x_add):remove()
                -- return
          --end
   --end
end

function hook_focus(c)
   reset_keychain(c)
   c.border_color = beautiful.border_focus
end

function hook_unfocus(c)
   c.border_color = beautiful.border_normal
end


-- Alt-] as starting key combination
function alt_paranthese_function(modifier, key)
   -- reset box
   reset_keychain(client.focus)
   -- No cobinations with modifier
   if #modifier > 0 then
          return false
   end
   -- test our key
   if key=="r" then
          awesome.restart()
   end
   if key=="q" then
          awesome.quit()
   end
   if key == "f" then
          client_floating_toggle(client.focus)
   end
   return false
end

   

-- manage hook
function hook_manage(c)
   if floatapps[string.lower(c.class)] then
          c.floating = floatapps[string.lower(c.class)]
   end
   if not (c.class == "<unknown>") then
          client.focus=c
   end

   c.border_width=beautiful.border_width
   c.border_color=beautiful.border_focus
   set_floating_props(c)
end


-- rearrange hook
function hook_arrange(screen)
   if not client.focus then
          local c=awful.client.focus.history.get(screen,0)
          if c then client.focus = c end
   end
end


-- The usual dmenu on Alt-p
keybinding({ "Mod1" }, "p", function() awful.util.spawn("exec `dmenu_path | 
dmenu`") end):add()

-- Open terminal on Alt-Enter
keybinding({ "Mod1" }, "Return", function() awful.util.spawn(terminal) 
end):add()
keybinding({ "Mod1" }, "Tab", function() awful.client.focus.byidx(1); 
client.focus:raise(); end):add()

-- The hooks
awful.hooks.focus.register(hook_focus)
awful.hooks.unfocus.register(hook_unfocus)
awful.hooks.manage.register(hook_manage)
awful.hooks.arrange.register(hook_arrange)
awful.hooks.timer.register(1,hook_time)
awful.hooks.property.register(property_hook)

Reply via email to