You are not logged in.

#1 2012-11-16 22:25:02

foyrkopp
Member
Registered: 2012-11-16
Posts: 4

Awesome / lua: os.getenv() problems

Hello everyone

I'm working on customizing my rc.lua for multiple, highly similar computers. For realizing the small differences, a check upon

require("awful")
...
host = os.getenv("HOSTNAME")

seemed the smart choice.

However, both os.getenv("HOSTNAME") and os.getenv("EDITOR") return nil from within rc.lua.

When i call the same functions from a arbitary lua script or via the lua console, os.getenv("EDITOR") works, while os.getenv("HOSTNAME") still doesn't.

By now I feel positively stupid for propably overlooking something fairly simple, but I'm out of ideas.


I'm running lua 5.1.5 and awesome 3.4.13.


Any ideas?

Offline

#2 2012-11-17 01:22:45

anrxc
Member
From: Croatia
Registered: 2008-03-22
Posts: 835
Website

Re: Awesome / lua: os.getenv() problems

Any ideas?

If you don't use BASH there's no guarantee this variable will be exported when X is started.


If you use vicious I propose an alternative:

$ lua
> widgets = require("vicious.widgets")
> print(widgets.os()[4])
sputnik


You need to install an RTFM interface.

Offline

#3 2012-11-17 11:02:06

foyrkopp
Member
Registered: 2012-11-16
Posts: 4

Re: Awesome / lua: os.getenv() problems

Would exporting environmental variables via .xsession / .xinitrc help?


Either way,

widgets = require("vicious.widgets")
...
host = (widgets.os()[4])

works, thanks.

--edit: add--

as does

host = awful.util.pread("hostname")

just for future reference and those who don't use vicious.

Last edited by foyrkopp (2012-11-17 11:17:33)

Offline

Board footer

Powered by FluxBB