Search code examples
luaawesome-wm

Is there a way to run lua scripts using awesomewm library?


I know i can create scripts and import them to the rc file or that i can run keymaps for it. Can i lets say create a script (script.lua) and run it with my terminal.

I tried running awesome-client on my terminal an passing the script path as the first param awesome-client scipt.lua but it throws an error string "[string "script.lua"]:1: syntax error near <eof>". Is there a way to do this?


Solution

  • The answer changes depending on your AwesomeWM version, but yes, you can.

    
    # Like this
    echo 'require("naughty").notify{text="foo"}' | awesome-client
    
    # Or that
    cat myscript.lua | awesome-client
    
    # Or that
    awesome-client << EOF
    require("naughty").notify{text="foo"}
    EOF
    

    But keep in mind, this run the code within the main awesome process. It does not "execute the script" as a process.