Automatically Set Timezone

Install NetworkManager.

sudo pacman -S NetworkManager

Then ensure that NetworkManager.service and NetworkManager-dispatcher.service are both enabled and started.

Create this file at /etc/NetworkManager/dispatcher.d/09-timezone:

#!/bin/sh
case "$2" in
    up)
        timedatectl set-timezone "$(curl --fail https://ipapi.co/timezone)"
    ;;
esac

The dispatcher service should now set the timezone automatically.

I had to whitelist the domain I set in the script (ipapi.co) in my PiHole server. Some block lists may prevent this from resolving.

Links


Content properties

  • Type: Note
  • Category: Arch Linux
  • Tags: linux
  • Custom slug: None

This is a preview of a simpler page design that I'm working on over the next little bit. I've finally added a (click it!) but there's still a few pages left to be converted so don't worry if things don't look quite right just yet 🙏

Content on blog pages use the CC-BY-SA license. The source code and notes use the MIT license. Unsure? Mention me on Mastodon.