This is not perfect. If the first config is invalid, then it wont use
the correct modeline. However there is no way to know if the config
is valid before attempting to execute it, so it's the best we can do.
Fix#3166
This commits re-use the modeline code from the previous commit
to support Lua scripts starting with #!. Previously, it was
non-trivial to add support since most *nix OS wont parse the
command line arguments correctly. Since we now have a state
machine good enough for 95%+ of the use case, it is easy to
support them.
This commits adds the ability to add an `-- awesome_mode:` comment
to `rc.lua`. This line will be interpreted before Lua starts and
allow command line options to be set in the file.
There is also a partial shebang mode (`#!`) support. While it is
not yet possible to make a random Lua file executable and start
`awesome`, it is at least supported to configure AwesomeWM. The
next commit will add the missing bits.
This commit implements the parsing using a state machine. While
glib has its own functions, they don't do 100% of what we need.
It could have been possible to use them anyway and get quotes,
escaping and UTF-8 support for free. The downside would have been
duplicated code to handle shebangs and modeline. The state machine
code fully support 3 different ways of loading the arguments with
the same code path.
The next commit will add modeline support. By default, modelines have
the final work on which options to set. However, mostly for testing,
this isn't flexible enough.