4

Typically, I set the timezone of my computer's clock by changing the .bashrc file, appending, say, TZ='America/Los_Angeles'; export TZ such that whenever date is invoked the right time in the right timezone is returned. However, after probing awesome, it seems that running echo $TZ in awesome returns something other than when I run echo $TZ in my own terminal.

According to any instance of a lua repl, echo $TZ also appears to return the correct timezone (in accordance with the .bashrc).

How would I go about synchronising the timezones across the programs?

Soyuz
  • 367

1 Answers1

4

Your problem is that you are not defining the environment variable TZ in the right file. ~/.bashrc is the configuration file for interactive shells. It's the place for aliases, key bindings and other things that you want to have in interactive shell. While you can define an environment variable there, this variable will only be set in the programs that are started from an interactive shell. This excluded your window manager and any program started by the window manager.

So instead define environment variables in the proper place. For non-graphical logins, the proper place is ~/.profile. When you log in in graphical mode, the proper place depends on your distribution, your display manager and your session or window manager. On Ubuntu, I believe that all display managers are set up to read ~/.profile as well. So define environment variables in ~/.profile.

This topic has come up many times — see Is there a ".bashrc" equivalent file read by all shells?

In your situation, an alternative possibility is to define the environment variable in your Awesome configuration file (os.setenv('TZ', 'America/Los_Angeles')). Awesome would be the right place to act if you want to change the timezone without logging out and back in (if you're travelling with your laptop).