File: sxmo_timezonechange.sh

package info (click to toggle)
sxmo-utils 1.14.2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 6,016 kB
  • sloc: sh: 9,166; ansic: 117; makefile: 68
file content (50 lines) | stat: -rwxr-xr-x 1,032 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors

# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh

change_alpine() {
	echo "Changing timezone to $1"

	doas setup-timezone -z "$1"
	sxmo_hook_statusbar.sh time

	echo "Timezone changed ok"
}

change_systemd() {
	echo "Changing timezone to $1"

	timedatectl set-timezone "$1"
	sxmo_hook_statusbar.sh time

	echo "Timezone changed ok"
}

menu() {
	zoneinfo_dir=$(xdg_data_path zoneinfo)
	T="$(
		find "$zoneinfo_dir" -type f |
		sed  "s#^${zoneinfo_dir}/##g" |
		sort |
		sxmo_dmenu_with_kb.sh -p Timezone -i
	)" || exit 0
	sxmo_terminal.sh "$0" "$T"
}

if [ $# -gt 0 ]; then
	trap "read -r" EXIT
	set -e

	case "$SXMO_OS" in
		alpine|postmarketos) change_alpine "$@";;
		arch|archarm|debian) change_systemd "$@";;
		nixos) echo "Change the timezone in configuration.nix with time.timeZone = \"[timezone]\"";;
		*) echo "Changing the timezone isn't implemented on your distro yet";;
	esac
else
	menu
fi