Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically set timezone when nework becomes available #133

Open
gi1242 opened this issue Jul 14, 2024 · 0 comments
Open

Automatically set timezone when nework becomes available #133

gi1242 opened this issue Jul 14, 2024 · 0 comments

Comments

@gi1242
Copy link

gi1242 commented Jul 14, 2024

Thanks for this script. I just set it up so it automatically sets the timezone when the network becomes available. If you find it useful and want to distribute some version of it with your script, here's what I did:

Create /etc/NetworkManager/dispatcher.d/update-timezone.sh with

#! /bin/bash
# Automatically set time zone when connected to the network

iface=$1
action=$2

#logger "tzupdate $iface $action"

if [[ $iface == wlan0 && $action == up ]]; then
    tz=$(tzupdate -s 1 -p 2>/dev/null)
    if [[ -n $tz && -r /usr/share/zoneinfo/$tz ]]; then
	timedatectl set-timezone $tz
    fi
fi

(Change $iface == wlan0 to $iface != lo if desired, and don't forget to make the script executable.)

This only works for systems that use NetworkManager.

GI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant