summaryrefslogtreecommitdiff
path: root/session-init.sh
blob: 8cb65128327e32367845399c7938e4d89f5c3ca8 (plain)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash

# Parabola Install Wizard - session setup
#
# prompt the user to decide which login/install session to use
#
# this script is normally called from the .bash_profile of live ISO,
#   which will later start the selected session
# .bash_profile will reset the 'SESSION' state var though;
#   so this script can be re-run by the user to start a new session
#
#
# Copyright (C) 2020,2022 bill-auger <bill-auger@programmer.net>
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This file is part of Parabola Install Wizard.
#
# Parabola Install Wizard is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Parabola Install Wizard is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Parabola Install Wizard. If not, see <http://www.gnu.org/licenses/>.


source $(cd $(dirname ${BASH_SOURCE[0]}) ; pwd)/session-common.sh.inc # sets: $Lang


readonly LANG_TITLE="System language selection"
readonly LANG_PROMPT="Select your language:"
readonly -a LANGUAGES=( $(sort -u ./LANGUAGES) )
readonly -a KEYMAPS=(   $(sort -u ./KEYMAPS_X) )
readonly -a ALL_SESSIONS=( 'live'      "Live desktop"  \
                           'calamares' "GUI installer" \
                           'wizard'    "TUI installer" \
                           'cli'       "Command line"  ) # per .bash_profile
case "$DESKTOP_SESSION" in                               # per .bash_profile
  'lxde') readonly SESSIONS=( "${ALL_SESSIONS[@]}"   ) ; readonly SESSION_DEFAULT='live'      ;;
  'mini') readonly SESSIONS=( "${ALL_SESSIONS[@]:2}" ) ; readonly SESSION_DEFAULT='calamares' ;;
  *     ) readonly SESSIONS=( "${ALL_SESSIONS[@]:4}" ) ; readonly SESSION_DEFAULT='cli'       ;;
esac


## prompt for language if not already selected ##

Language=$(GetStateVar 'LANG' '_UNDEFINED_')
if   [[ "${Language}" == '_UNDEFINED_' ]]
then Language=$( InitDlg "$LANG_TITLE" "$LANG_PROMPT" ${DEF_LANG} "${LANGUAGES[@]}" )
     [[ "${Language}" == "" ]] && Language=${DEF_LANG}

     logger "$0: selected language='${Language}'"

     # prepare locale
     echo "LANG=${Language}" > /etc/locale.conf
     SetStateVar 'LANG' ${Language}

     # prepare installer translations
     SetLang ${Language/_*/} # sets $Lang
     SetStateVar 'TR_KEY' ${Lang}
fi


## prompt for X11 keymap if not already selected ##

Keymap=$(GetStateVar 'XKBMAP' '_UNDEFINED_')
if   [[ "${Keymap}" == '_UNDEFINED_' ]]
then Keymap=$( InitDlg "${TR[dlg_keymap-${Lang}]}" "${TR[keymap-${Lang}]}" \
                       ${DEF_KEYMAP} "${KEYMAPS[@]}"                       )
     [[ "${Keymap}" == "" ]] && Keymap=${DEF_KEYMAP}

     logger "$0: selected keymap='${Keymap}'"

     # set keymap
     setxkbmap ${Keymap} 2> /dev/null
     SetStateVar 'XKBMAP' ${Keymap}
fi


## prompt to launch installer or CLI ##

Session=$(GetStateVar 'SESSION' '_UNDEFINED_')
if   [[ "${Session}" == '_UNDEFINED_' ]]
then Session=$( InitDlg "${TR[dlg_session-${Lang}]}" "${TR[session-${Lang}]}" \
                        ${SESSION_DEFAULT} "${SESSIONS[@]}"                   )
     [[ "${Session}" == "" ]] && Session=${SESSION_DEFAULT}

     logger "$0: selected interface='${Session}'"

     # set installer interface
     SetStateVar 'SESSION' ${Session}
fi

clear