Hi,

On 08.10.2012 18:47, Manuel Kasser wrote:
> to get a better overview over my rc.lua-file I want to transfer all
> function code into a separate file. For that I created a file named
> "functions.lua" in my .config/awesome-directory next to my rc.lua.
> The plan is to put all the function code into the functions.lua and just
> call the functions by name in the rc.lua to make it shorter and better
> readable.

Does that mean you are just moving functions out to another file? They were
already separate functions before?

> I put a "require("funtions")" after the other "require"-calls into my
> rc.lua and copied the function code (at the moment just three functions
> for testing) into the functions.lua-file which starts with the line
> "module("functions")".
> The functions got names in the new file and are, as mentioned, called by
> calling them by "functions.[functionname]" with "[functionname]" the
> chosen name of the function in the functions.lua.
> 
> Unfortunately my configuration breaks, so obviously I haven't done it right.
> 
> Does anyone have an idea what's my mistake? Thanks in advance!

An error message would help a lot. If you don't know where error messages from
awesome are going to: Run "ls -l /proc/$(pidof awesome)/fd/2" while inside of
awesome and when it says something about /dev/tty1, the message are on tty1
which you can access with ctrl-alt-f1 (to get back, use ctrl-alt-f7). Otherwise
that should be a file name with error messages. (someone should put this in the
FAQ...).

> My testobjects were the functions in tasklist.buttons (surrounding code,
> marked as "awesome-config-code" is from original rc.lua). My actual try
> in the rc.lua is:

If you want me to guess:

> [code]
> --  require-calls
> require("functions")
> 
> --  some awesome-config-code
> 
> mytasklist.buttons = awful.util.table.join(
>                      awful.button({ }, 1, functions.buttonone(c) ),
>                      awful.button({ }, 3, functions.buttonthree() ),
>                      awful.button({ }, 4, functions.buttonfour() ),

Do you really want to call the function here? I think you want
functions.buttonfour instead of functions.buttonfour(). Also, what's the "c"
argument to buttonone?

>                      awful.button({ }, 5, function ()
>                                               awful.client.focus.byidx(-1)
>                                               if client.focus then
> client.focus:raise() end
>                                           end))
> --  more awesome-config-code
> [/code]
> 
> And the complete functions.lua-file is:
> [code]
> module("functions")
> 
> --tasklist-stuff
> function buttonone(c)
>     if c == client.focus then
>         c.minimized = true
>     else
>         if not c:isvisible() then
>             awful.tag.viewonly(c:tags()[1])
>         end
>         -- This will also un-minimize
>         -- the client, if needed
>         client.focus = c
>         c:raise()
>     end
> end
> 
> function buttonthree()
>     if instance then
>         instance:hide()
>         instance = nil
>     else
>         instance = awful.menu.clients({ width=250 })
>     end
> end
> 
> function buttonfour()
>     awful.client.focus.byidx(1)
>     if client.focus then client.focus:raise() end
> end
> [/code]

This accesses global stuff like "awful" and "client". Those aren't visible in
modules by default. To get them, you need special magic before the 
module()-call:

local awful = require("awful")
local client = client
module("functions")
[other stuff]

Cheers,
Uli
-- 
"Do you know that books smell like nutmeg or some spice from a foreign land?"
                                                  -- Faber in Fahrenheit 451

-- 
To unsubscribe, send mail to [email protected].

Reply via email to