summaryrefslogtreecommitdiff
path: root/configs/profile/root-image/root/.session/session-init.sh
blob: a344ac90503f5c4cb4893542d5429cc4da9e29ac (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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash

# Parabolaiso Session Setup
#
# prompt the user to decide which login session to use
#
# this script is normally called from the .bash_profile of the initial live login,
#   which will then 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 bill-auger <bill-auger@programmer.net>
#
# License: GNU GPLv2+
#
# 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 2 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


readonly TIMEOUT=30
readonly H=15
readonly W=42
readonly N_ITEMS=10

readonly LANG_TITLE="System language selection"
readonly LANG_PROMPT="Choose your language:"
readonly LANG_DEFAULT='en_US.UTF-8'
readonly KEYMAP_TITLE="System keymap selection"
readonly KEYMAP_PROMPT="Choose your keymap:"
readonly KEYMAP_DEFAULT='us'
readonly SESSION_TITLE="Launch installer or command-line"
readonly SESSION_PROMPT="Would you like to start the installer, or drop onto the command line?"

readonly -a LANGUAGES=( $(cat "${WIZARD_DIR}"/LANGUAGES) )
readonly -a ESPERANTO_LANG_PACKS=(  'iceweasel-l10n-es-eo'                      )
readonly -a SPANISH_LANG_PACKS=(    'iceweasel-l10n-es-ar' 'icedove-l10n-es-ar'
                                    'iceweasel-l10n-es-cl'
                                    'iceweasel-l10n-es-es' 'icedove-l10n-es-es'
                                    'iceweasel-l10n-es-mx'                      )
readonly -a FRENCH_LANG_PACKS=(     'iceweasel-l10n-fr'    'icedove-l10n-fr'    )
readonly -a GALEGO_LANG_PACKS=(     'iceweasel-l10n-gl'    'icedove-l10n-gl'    )
readonly -a ITALIAN_LANG_PACKS=(    'iceweasel-l10n-it'    'icedove-l10n-it'    )
readonly -a POLISH_LANG_PACKS=(     'iceweasel-l10n-pl'    'icedove-l10n-pl'    )
readonly -a PORTUGUESE_LANG_PACKS=( 'iceweasel-l10n-pt-br' 'icedove-l10n-pt-br' )

readonly -a KEYMAPS=( $(cat "${WIZARD_DIR}"/KEYMAPS_X) )

readonly -a ALL_SESSIONS=( 'live'      "Live desktop"  \
                           'calamares' "GUI installer" \
                           'wizard'    "TUI installer" \
                           'cli'       "Command line"  )
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')
if   [[ "${Language}" == '_UNDEFINED_' ]]
then Language=$( InitDlg "$LANG_TITLE" "$LANG_PROMPT" $LANG_DEFAULT "${LANGUAGES[@]}" )
     [[ "${Language}" == "" ]] && Language=$LANG_DEFAULT

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

     # inject language packs into the install wizard package set
    Lang=${Language/_*/}
     case ${Lang} in
     'eo') echo "${ESPERANTO_LANG_PACKS[@]}"  >> "${WIZARD_DIR}"/packages ;;
     'fr') echo "${FRENCH_LANG_PACKS[@]}"     >> "${WIZARD_DIR}"/packages ;;
     'gl') echo "${GALEGO_LANG_PACKS[@]}"     >> "${WIZARD_DIR}"/packages ;;
     'it') echo "${ITALIAN_LANG_PACKS[@]}"    >> "${WIZARD_DIR}"/packages ;;
     'pl') echo "${POLISH_LANG_PACKS[@]}"     >> "${WIZARD_DIR}"/packages ;;
     'pt') echo "${PORTUGUESE_LANG_PACKS[@]}" >> "${WIZARD_DIR}"/packages ;;
     'es') echo "${SPANISH_LANG_PACKS[@]}"    >> "${WIZARD_DIR}"/packages ;;
     esac

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

     # prepare installer translations
     TrKey=$( [[ "${TRANSLATIONS}" =~ " ${Lang} " ]] && echo ${Lang} || echo 'en' )
     SetStateVar 'TR_KEY' ${TrKey}
fi


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

Keymap=$(GetStateVar 'XKBMAP')
if   [[ "${Keymap}" == '_UNDEFINED_' ]]
then Keymap=$( InitDlg "$KEYMAP_TITLE" "$KEYMAP_PROMPT" $KEYMAP_DEFAULT "${KEYMAPS[@]}" )
     [[ "${Keymap}" == "" ]] && Keymap=$KEYMAP_DEFAULT

     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')
if   [[ "${Session}" == '_UNDEFINED_' ]]
then Session=$( InitDlg "$SESSION_TITLE" "$SESSION_PROMPT" $SESSION_DEFAULT "${SESSIONS[@]}" )
     [[ "${Session}" == "" ]] && Session=$SESSION_DEFAULT

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

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

clear