Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1df6d1740e | ||
|
|
dc209ae275 | ||
|
|
216d93fbff | ||
|
|
c7f21c9234 | ||
|
|
d41a531b9d | ||
|
|
4134a16ecd | ||
|
|
0df6d7b0fc | ||
|
|
a8d4fc1fc1 |
No files matched your search
+17
-3
@@ -48,6 +48,7 @@ If the build is interrupted, run `sudo umount -R /mnt && sudo losetup -D` to be
|
||||
- **Packages**: Edit the package list inside `pi4/build/build-stormux.sh` (search for `pacman -Su --needed`). Add or remove entries as needed, then rebuild.
|
||||
- **Package sources**: The build does not fetch or compile packages from the AUR. Packages are installed from the official Arch Linux ARM repositories or the Stormux repository. The finished image includes `yay`, but it is installed as a prebuilt package from the Stormux repository and is not used during the build.
|
||||
- **First-boot behavior**: Modify `pi4/files/usr/local/bin/configure-stormux` to change the guided setup that runs when the image boots the first time.
|
||||
- **X resources**: `pi4/files/etc/skel/.Xresources` is installed in the default user's home and `/etc/skel`, so newly created users inherit it too.
|
||||
|
||||
Remember to keep permissions sensible (`chmod 755` for scripts, `644` for configs) so rsync copies them correctly.
|
||||
|
||||
@@ -69,9 +70,11 @@ Rebuild after pulling so your custom image inherits any upstream fixes (new pack
|
||||
```bash
|
||||
xzcat stormux-rpi4-5-aarch64-*.img.xz | sudo dd of=/dev/sdX bs=4M status=progress conv=fsync
|
||||
```
|
||||
3. Insert the card into your Raspberry Pi and power it on. You should hear Fenrir start speaking once the user session loads.
|
||||
4. Log in using the default credentials (username `stormux`, password `stormux`). Root uses `root`/`root` until you change it.
|
||||
5. Run `sudo configure-stormux` (or follow the automatic prompt) to finish the guided setup: configure networking via `nmtui`, update the clock, optionally resize the SD card with `growpartfs`, and toggle Fenrir’s layout.
|
||||
3. Insert the card into your Raspberry Pi and power it on. The first boot automatically logs in on tty1 and starts guided setup.
|
||||
4. Setup calibrates volume, offers the default speech-engine selector, and speaks the laptop-layout question using the selected engine. Enter or N selects desktop layout; Y selects laptop layout. Fenrir stays stopped until these choices are complete.
|
||||
5. Setup updates `[keyboard] layout` in `/etc/fenrirscreenreader/settings/settings.toml`, preserving comments, and validates the edited settings with `fenrir --check-config` before replacing the original. It then starts Fenrir and presents the welcome prompt.
|
||||
6. Continue with the Pi-specific setup: display and I38 startup choices, optional SD-card resizing, networking via `nmtui`, and the clock/timezone. Fenrir is enabled for later boots unless you choose to disable console speech when I38 starts at boot.
|
||||
7. After first-boot setup, log in using the default credentials (username `stormux`, password `stormux`). Root uses `root`/`root` until you change it. If setup is interrupted, run `sudo configure-stormux` to continue.
|
||||
|
||||
## Testing Without Hardware
|
||||
You can boot the image in a container to verify services before flashing:
|
||||
@@ -81,6 +84,17 @@ sudo systemd-nspawn -i stormux-rpi4-5-aarch64-*.img --boot
|
||||
```
|
||||
Use `machinectl` to connect to the console and ensure critical services start. For unit files you edit, run `systemd-analyze verify path/to/unit` inside the container or the Pi.
|
||||
|
||||
### Focused Setup Checks
|
||||
|
||||
From the repository root, run:
|
||||
```bash
|
||||
python3 pi4/tests/test-first-boot-fenrir-setup.py
|
||||
bash tests/test-select-speech-module.sh
|
||||
shellcheck pi4/build/build-stormux.sh pi4/files/etc/profile.d/stormux_first_boot.sh pi4/files/usr/local/bin/configure-stormux
|
||||
```
|
||||
|
||||
For acceptance, boot a rebuilt image on a Pi. Confirm that volume calibration comes first, voice previews work with Up/Down, Enter accepts the engine, Escape keeps the previous engine, and the laptop question uses the selected voice. Test desktop (Enter or N) and laptop (Y) bindings and confirm Fenrir starts once after the choice. Exercise both connected and headless display setup, I38 boot with console Fenrir enabled and disabled, SD-card resize accepted and declined, and setup with and without networking. Reboot after completing setup to check voice/layout persistence, the selected console/I38 startup behavior, and removal of temporary autologin/passwordless sudo. Automated checks and container boots do not establish audible speech, physical keyboard behavior, or real Pi boot acceptance.
|
||||
|
||||
## Troubleshooting Tips
|
||||
- **Locale or package errors**: Ensure your host’s pacman keyring is up to date (`sudo pacman -Sy archlinux-keyring`).
|
||||
- **Loop device cleanup**: After failures run `sudo losetup -a` to find stray devices, then `sudo losetup -d /dev/loopX`.
|
||||
|
||||
@@ -442,6 +442,7 @@ packages=(
|
||||
man-pages
|
||||
networkmanager
|
||||
nodm-dgw
|
||||
openevv-git
|
||||
openssh
|
||||
parted
|
||||
pipewire
|
||||
@@ -548,10 +549,13 @@ if command -v spd-conf > /dev/null 2>&1; then
|
||||
spd-conf -n -C || echo "Warning: Speech Dispatcher system configuration failed."
|
||||
fi
|
||||
if [[ -f /etc/speech-dispatcher/speechd.conf ]]; then
|
||||
if grep -qE '^[[:space:]]*#?[[:space:]]*DefaultModule[[:space:]]+' /etc/speech-dispatcher/speechd.conf; then
|
||||
sed -i -E 's/^[[:space:]]*#?[[:space:]]*DefaultModule[[:space:]]+.*/DefaultModule rhvoice/' /etc/speech-dispatcher/speechd.conf
|
||||
speechBackup="\$(mktemp)"
|
||||
if /usr/local/lib/stormux/select-speech-module \
|
||||
--apply-module rhvoice /etc/speech-dispatcher/speechd.conf "\$speechBackup"; then
|
||||
rm -f "\$speechBackup"
|
||||
else
|
||||
printf '\nDefaultModule rhvoice\n' >> /etc/speech-dispatcher/speechd.conf
|
||||
echo "Warning: Could not set RHVoice as the default speech engine."
|
||||
rm -f "\$speechBackup"
|
||||
fi
|
||||
fi
|
||||
# Enable linger so that hopefully sound will start at login.
|
||||
@@ -566,6 +570,8 @@ echo '%wheel ALL=(ALL) ALL' > /etc/sudoers.d/wheel
|
||||
echo stormux > /etc/hostname
|
||||
# Configure services
|
||||
systemctl disable systemd-networkd.service systemd-networkd.socket
|
||||
# First-login setup starts Fenrir after volume, voice, and layout selection.
|
||||
systemctl disable fenrirscreenreader.service
|
||||
# Enable services
|
||||
services=(
|
||||
brltty.path
|
||||
@@ -599,6 +605,8 @@ install_rhvoice_english_fixes
|
||||
|
||||
# Copy skel files to stormux user home (after user rename in chroot)
|
||||
find ../files/etc/skel/ -mindepth 1 -exec cp -rv "{}" /mnt/home/stormux/ \;
|
||||
install -Dm644 ../files/etc/skel/.Xresources /mnt/etc/skel/.Xresources
|
||||
arch-chroot /mnt chown stormux:users /home/stormux/.Xresources
|
||||
|
||||
# Copy boot files again to ensure custom config overrides any package changes
|
||||
cp -rv ../files/boot/* /mnt/boot
|
||||
|
||||
@@ -60,16 +60,6 @@ if [[ -x /etc/audibleprompt.sh ]]; then
|
||||
export sudoFlags=("-A")
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Starting Fenrir..."
|
||||
spd-say "Starting Fenrir."
|
||||
sudo "${sudoFlags[@]}" systemctl --quiet enable --now fenrirscreenreader.service
|
||||
/usr/local/lib/stormux/select-speech-module
|
||||
|
||||
clear
|
||||
cat << "EOF"
|
||||
Hello, and welcome to Stormux!
|
||||
|
||||
Please press enter to continue.
|
||||
EOF
|
||||
read -r
|
||||
sudo "${sudoFlags[@]}" configure-stormux
|
||||
@@ -0,0 +1,25 @@
|
||||
! Start in Unicode
|
||||
XTerm*utf8: 1
|
||||
UXTerm*utf8: 1
|
||||
! Use white-on-black colors
|
||||
XTerm.vt100.reverseVideo: true
|
||||
UXTerm.vt100.reverseVideo: true
|
||||
! XTerm already has 256 colors support
|
||||
! We ask it to set the correct $TERM XTerm.termName: xterm-256color
|
||||
UXTerm.termName: xterm-256color
|
||||
! Start with maximized window
|
||||
xterm*maximized: true
|
||||
! Make Alt key behave like in other terminals
|
||||
XTerm.vt100.altIsNotMeta: true
|
||||
UXTerm.vt100.altIsNotMeta: true
|
||||
XTerm.vt100.metaSendsEscape: true
|
||||
UXTerm.vt100.metaSendsEscape: true
|
||||
URxvt.perl-ext-common: "default, -searchable-scrollback"
|
||||
URxvt.font: xft:terminus:size=16
|
||||
*VT100.Translations: #override \
|
||||
<Key>BackSpace: string(0x7F)\n\
|
||||
<Key>Delete: string("\033[3~")\n\
|
||||
<Key>Home: string("\033[1~")\n\
|
||||
<Key>End: string("\033[4~")\n\
|
||||
Ctrl Shift <Key>V: insert-selection(CLIPBOARD)
|
||||
*ttyModes: erase ^?
|
||||
@@ -104,6 +104,54 @@ EndSection
|
||||
EOF
|
||||
}
|
||||
|
||||
configure_fenrir() {
|
||||
local keyboardLayout="desktop" answer configPath tempPath serviceAction="start"
|
||||
configPath="/etc/fenrirscreenreader/settings/settings.toml"
|
||||
# A manual rerun must also apply the newly selected launch-time layout.
|
||||
if systemctl is-active --quiet fenrirscreenreader.service; then
|
||||
serviceAction="restart"
|
||||
fi
|
||||
|
||||
# Reload the default engine selected before this script was started.
|
||||
killall speech-dispatcher 2>/dev/null || true
|
||||
while true; do
|
||||
echo "Would you like to switch Fenrir to laptop layout? [y/N]"
|
||||
spd-say -w "Would you like to switch Fenrir to laptop layout? Press y for yes or n for no, followed by Enter. Press Enter for desktop layout."
|
||||
read -r answer || return 1
|
||||
case "${answer,,}" in
|
||||
y|yes) keyboardLayout="laptop"; break ;;
|
||||
n|no|"") break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
tempPath="$(mktemp "${configPath}.stormux.XXXXXX")" || return 1
|
||||
if ! cp --preserve=mode,ownership "$configPath" "$tempPath" || ! awk -v layout="$keyboardLayout" '
|
||||
/^[[:space:]]*\[/ { inKeyboard = ($0 ~ /^[[:space:]]*\[keyboard\][[:space:]]*(#.*)?$/) }
|
||||
inKeyboard && /^[[:space:]]*layout[[:space:]]*=/ {
|
||||
if (sub(/=[[:space:]]*("[^"]*"|\047[^\047]*\047)/, "= \"" layout "\"")) {
|
||||
changed++
|
||||
}
|
||||
}
|
||||
{ print }
|
||||
END { if (changed != 1) exit 1 }
|
||||
' "$configPath" > "$tempPath" || ! fenrir --config "$tempPath" --check-config; then
|
||||
rm -f "$tempPath"
|
||||
echo "Could not configure Fenrir. The original settings were preserved."
|
||||
spd-say -w "Could not configure Fenrir. The original settings were preserved."
|
||||
return 1
|
||||
fi
|
||||
if ! mv -f "$tempPath" "$configPath"; then
|
||||
rm -f "$tempPath"
|
||||
return 1
|
||||
fi
|
||||
if ! systemctl "$serviceAction" fenrirscreenreader.service; then
|
||||
echo "Fenrir could not start. Check journalctl -u fenrirscreenreader.service."
|
||||
spd-say -w "Fenrir could not start. Check the screen reader service log."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
set_timezone() {
|
||||
# Get the list of timezones
|
||||
mapfile -t regions < <(timedatectl --no-pager list-timezones | cut -d '/' -f1 | sort -u)
|
||||
@@ -132,12 +180,14 @@ set_timezone() {
|
||||
ln -sf /usr/share/zoneinfo/"${region}"/"${city}" /etc/localtime
|
||||
timedatectl set-ntp true
|
||||
}
|
||||
# Offer to switch fenrir layout.
|
||||
if read_yes_no "Would you like to switch Fenrir to laptop layout?"; then
|
||||
sed -i 's/=desktop/=laptop/' /etc/fenrirscreenreader/settings/settings.conf
|
||||
clear
|
||||
systemctl restart fenrirscreenreader.service
|
||||
fi
|
||||
configure_fenrir || exit 1
|
||||
# Keep console speech available on later boots unless the I38 choice disables it.
|
||||
systemctl --quiet enable fenrirscreenreader.service || exit 1
|
||||
|
||||
clear
|
||||
echo "Hello, and welcome to Stormux!"
|
||||
echo "Let's get you set up. Please press enter to continue."
|
||||
read -r
|
||||
|
||||
if command -v i3 > /dev/null 2>&1 && systemctl list-unit-files nodm.service > /dev/null 2>&1; then
|
||||
if read_yes_no "Will this Pi be connected to a physical screen?"; then
|
||||
@@ -189,9 +239,9 @@ fi
|
||||
if ! ping -c1 stormux.org &> /dev/null ; then
|
||||
echo "No internet connection detected. Press enter to open NetworkManager."
|
||||
read -r _
|
||||
echo "setting set focus#highlight=True" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-daemon.sock
|
||||
echo "setting set reading#mode=highlight" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-daemon.sock
|
||||
nmtui-connect
|
||||
echo "setting set focus#highlight=False" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-daemon.sock
|
||||
echo "setting set reading#mode=cursor" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-daemon.sock
|
||||
fi
|
||||
# Check for internet connectivity
|
||||
if ping -qc1 -W 1 stormux.org &> /dev/null; then
|
||||
|
||||
+334
@@ -0,0 +1,334 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -u
|
||||
|
||||
speechConfig="${STORMUX_SPEECH_CONFIG:-/etc/speech-dispatcher/speechd.conf}"
|
||||
selectionFile=""
|
||||
spdSayCommand="${STORMUX_SPD_SAY:-spd-say}"
|
||||
systemctlCommand="${STORMUX_SYSTEMCTL:-systemctl}"
|
||||
socatCommand="${STORMUX_SOCAT:-socat}"
|
||||
fenrirSocket="${STORMUX_FENRIR_SOCKET:-/tmp/fenrirscreenreader-daemon.sock}"
|
||||
scriptPath="$(readlink -f "$0")"
|
||||
runtimeDir="${STORMUX_RUNTIME_DIR:-/run/stormux}"
|
||||
fenrirSpeechMuted=false
|
||||
|
||||
is_safe_module() {
|
||||
[[ "$1" =~ ^[A-Za-z0-9][A-Za-z0-9_.-]*$ ]]
|
||||
}
|
||||
|
||||
apply_module() {
|
||||
local moduleName="$1"
|
||||
local configPath="$2"
|
||||
local backupPath="$3"
|
||||
local tempPath
|
||||
|
||||
is_safe_module "$moduleName" || return 1
|
||||
[[ -f "$configPath" ]] || return 1
|
||||
|
||||
mkdir -p "${backupPath%/*}" || return 1
|
||||
cp --preserve=mode,ownership,timestamps "$configPath" "$backupPath" || return 1
|
||||
tempPath="$(mktemp "${configPath}.stormux.XXXXXX")" || return 1
|
||||
|
||||
if ! awk -v moduleName="$moduleName" '
|
||||
BEGIN { wroteDefault = 0 }
|
||||
/^[[:space:]]*#?[[:space:]]*DefaultModule[[:space:]]+/ {
|
||||
if (!wroteDefault) {
|
||||
print "DefaultModule " moduleName
|
||||
wroteDefault = 1
|
||||
}
|
||||
next
|
||||
}
|
||||
{ print }
|
||||
END {
|
||||
if (!wroteDefault) {
|
||||
print ""
|
||||
print "DefaultModule " moduleName
|
||||
}
|
||||
}
|
||||
' "$configPath" > "$tempPath"; then
|
||||
rm -f "$tempPath"
|
||||
return 1
|
||||
fi
|
||||
|
||||
chown --reference="$configPath" "$tempPath" || {
|
||||
rm -f "$tempPath"
|
||||
return 1
|
||||
}
|
||||
chmod --reference="$configPath" "$tempPath" || {
|
||||
rm -f "$tempPath"
|
||||
return 1
|
||||
}
|
||||
mv -f "$tempPath" "$configPath"
|
||||
}
|
||||
|
||||
restore_config() {
|
||||
local configPath="$1"
|
||||
local backupPath="$2"
|
||||
local tempPath
|
||||
|
||||
[[ -f "$backupPath" ]] || return 1
|
||||
tempPath="$(mktemp "${configPath}.stormux.XXXXXX")" || return 1
|
||||
if ! cp --preserve=mode,ownership,timestamps "$backupPath" "$tempPath"; then
|
||||
rm -f "$tempPath"
|
||||
return 1
|
||||
fi
|
||||
mv -f "$tempPath" "$configPath" || return 1
|
||||
rm -f "$backupPath"
|
||||
}
|
||||
|
||||
write_selection() {
|
||||
local moduleName="$1"
|
||||
local targetPath="$2"
|
||||
local tempPath
|
||||
|
||||
is_safe_module "$moduleName" || return 1
|
||||
mkdir -p "${targetPath%/*}" || return 1
|
||||
tempPath="$(mktemp "${targetPath}.stormux.XXXXXX")" || return 1
|
||||
printf '%s\n' "$moduleName" > "$tempPath" || {
|
||||
rm -f "$tempPath"
|
||||
return 1
|
||||
}
|
||||
chmod 644 "$tempPath" || {
|
||||
rm -f "$tempPath"
|
||||
return 1
|
||||
}
|
||||
mv -f "$tempPath" "$targetPath"
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
--apply-module)
|
||||
[[ $# -eq 4 ]] || exit 2
|
||||
apply_module "$2" "$3" "$4"
|
||||
exit $?
|
||||
;;
|
||||
--restore-config)
|
||||
[[ $# -eq 3 ]] || exit 2
|
||||
restore_config "$2" "$3"
|
||||
exit $?
|
||||
;;
|
||||
--write-selection)
|
||||
[[ $# -eq 3 ]] || exit 2
|
||||
write_selection "$2" "$3"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--config)
|
||||
[[ $# -ge 2 ]] || exit 2
|
||||
speechConfig="$2"
|
||||
shift 2
|
||||
;;
|
||||
--selection-file)
|
||||
[[ $# -ge 2 ]] || exit 2
|
||||
selectionFile="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
printf 'Unknown option: %s\n' "$1" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
sudoCommand=(sudo)
|
||||
if [[ -n "${SUDO_ASKPASS:-}" ]]; then
|
||||
sudoCommand+=(-A)
|
||||
fi
|
||||
|
||||
announce_failure() {
|
||||
local previousModule="$1"
|
||||
local message="Speech engine selection failed. Your previous speech engine is still selected."
|
||||
|
||||
"$spdSayCommand" -C >/dev/null 2>&1 || true
|
||||
if is_safe_module "$previousModule"; then
|
||||
"$spdSayCommand" -o "$previousModule" "$message" >/dev/null 2>&1 || \
|
||||
"$spdSayCommand" "$message" >/dev/null 2>&1 || true
|
||||
else
|
||||
"$spdSayCommand" "$message" >/dev/null 2>&1 || true
|
||||
fi
|
||||
printf '%s\n' "$message" >&2
|
||||
}
|
||||
|
||||
set_fenrir_speech() {
|
||||
local enabled="$1"
|
||||
|
||||
printf 'setting set speech#enabled=%s\n' "$enabled" | \
|
||||
"$socatCommand" - UNIX-CLIENT:"$fenrirSocket" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
mute_fenrir_speech() {
|
||||
if "$systemctlCommand" is-active --quiet fenrirscreenreader.service 2>/dev/null && \
|
||||
set_fenrir_speech False; then
|
||||
fenrirSpeechMuted=true
|
||||
fi
|
||||
}
|
||||
|
||||
restore_fenrir_speech() {
|
||||
if [[ "$fenrirSpeechMuted" == true ]]; then
|
||||
set_fenrir_speech True || true
|
||||
fenrirSpeechMuted=false
|
||||
fi
|
||||
}
|
||||
|
||||
trap restore_fenrir_speech EXIT
|
||||
trap 'exit 130' HUP INT TERM
|
||||
|
||||
discover_modules() {
|
||||
local output line candidate
|
||||
local skippedHeading=false
|
||||
|
||||
if ! output="$("$spdSayCommand" -O 2>/dev/null)"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
modules=()
|
||||
while IFS= read -r line; do
|
||||
candidate="${line%$'\r'}"
|
||||
candidate="${candidate#"${candidate%%[![:space:]]*}"}"
|
||||
candidate="${candidate%"${candidate##*[![:space:]]}"}"
|
||||
[[ -n "$candidate" ]] || continue
|
||||
if [[ "$skippedHeading" == false ]]; then
|
||||
skippedHeading=true
|
||||
continue
|
||||
fi
|
||||
is_safe_module "$candidate" || continue
|
||||
modules+=("$candidate")
|
||||
done <<< "$output"
|
||||
|
||||
[[ ${#modules[@]} -gt 0 ]]
|
||||
}
|
||||
|
||||
configured_module() {
|
||||
local configured=""
|
||||
|
||||
if [[ -r "$speechConfig" ]]; then
|
||||
configured="$(awk '$1 == "DefaultModule" { print $2; exit }' "$speechConfig")"
|
||||
fi
|
||||
if ! is_safe_module "$configured"; then
|
||||
configured="rhvoice"
|
||||
fi
|
||||
printf '%s\n' "$configured"
|
||||
}
|
||||
|
||||
module_index() {
|
||||
local wanted="$1"
|
||||
local index
|
||||
|
||||
for index in "${!modules[@]}"; do
|
||||
if [[ "${modules[$index]}" == "$wanted" ]]; then
|
||||
printf '%s\n' "$index"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
draw_menu() {
|
||||
local index
|
||||
|
||||
printf '\033[H\033[2J'
|
||||
printf 'Select the default speech engine. Use Up and Down, Enter to select, or Escape to keep the current engine.\n\n'
|
||||
for index in "${!modules[@]}"; do
|
||||
if [[ $index -eq $selectedIndex ]]; then
|
||||
printf '> %s\n' "${modules[$index]}"
|
||||
else
|
||||
printf ' %s\n' "${modules[$index]}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
read_menu_key() {
|
||||
local first rest=""
|
||||
|
||||
IFS= read -rsn1 first || return 1
|
||||
if [[ -z "$first" ]]; then
|
||||
printf 'enter\n'
|
||||
return 0
|
||||
fi
|
||||
if [[ "$first" == $'\033' ]]; then
|
||||
IFS= read -rsn2 -t 0.1 rest || true
|
||||
case "$rest" in
|
||||
'[A') printf 'up\n' ;;
|
||||
'[B') printf 'down\n' ;;
|
||||
'') printf 'escape\n' ;;
|
||||
*) printf 'other\n' ;;
|
||||
esac
|
||||
return 0
|
||||
fi
|
||||
printf 'other\n'
|
||||
}
|
||||
|
||||
declare -a modules=()
|
||||
previousModule="$(configured_module)"
|
||||
mute_fenrir_speech
|
||||
if ! discover_modules; then
|
||||
announce_failure "$previousModule"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! selectedIndex="$(module_index "$previousModule")"; then
|
||||
if selectedIndex="$(module_index rhvoice)"; then
|
||||
:
|
||||
else
|
||||
selectedIndex=0
|
||||
fi
|
||||
fi
|
||||
|
||||
draw_menu
|
||||
"$spdSayCommand" "Use up and down arrows to select the default voice for this computer. ${modules[$selectedIndex]} is highlighted. Press Enter to select, or Escape to keep the current voice." >/dev/null 2>&1 || true
|
||||
|
||||
while true; do
|
||||
if ! keyName="$(read_menu_key)"; then
|
||||
announce_failure "$previousModule"
|
||||
exit 0
|
||||
fi
|
||||
case "$keyName" in
|
||||
up)
|
||||
selectedIndex=$(( (selectedIndex - 1 + ${#modules[@]}) % ${#modules[@]} ))
|
||||
;;
|
||||
down)
|
||||
selectedIndex=$(( (selectedIndex + 1) % ${#modules[@]} ))
|
||||
;;
|
||||
enter)
|
||||
break
|
||||
;;
|
||||
escape)
|
||||
"$spdSayCommand" -C >/dev/null 2>&1 || true
|
||||
"$spdSayCommand" -o "$previousModule" "Keeping ${previousModule} as the default speech engine." >/dev/null 2>&1 || true
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
draw_menu
|
||||
moduleName="${modules[$selectedIndex]}"
|
||||
"$spdSayCommand" -C >/dev/null 2>&1 || true
|
||||
"$spdSayCommand" -o "$moduleName" "This is ${moduleName}. If selected, I will be your default text-to-speech voice." >/dev/null 2>&1 || true
|
||||
done
|
||||
|
||||
selectedModule="${modules[$selectedIndex]}"
|
||||
backupFile="${runtimeDir}/speechd.conf.$$.backup"
|
||||
"$spdSayCommand" -C >/dev/null 2>&1 || true
|
||||
|
||||
if ! "${sudoCommand[@]}" "$scriptPath" --apply-module "$selectedModule" "$speechConfig" "$backupFile"; then
|
||||
"${sudoCommand[@]}" "$scriptPath" --restore-config "$speechConfig" "$backupFile" >/dev/null 2>&1 || true
|
||||
announce_failure "$previousModule"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ -n "$selectionFile" ]]; then
|
||||
if ! "${sudoCommand[@]}" "$scriptPath" --write-selection "$selectedModule" "$selectionFile"; then
|
||||
"${sudoCommand[@]}" "$scriptPath" --restore-config "$speechConfig" "$backupFile" >/dev/null 2>&1 || true
|
||||
announce_failure "$previousModule"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -f "$backupFile" 2>/dev/null || "${sudoCommand[@]}" rm -f "$backupFile" 2>/dev/null || true
|
||||
|
||||
"$spdSayCommand" -o "$selectedModule" "${selectedModule} is now the default speech engine." >/dev/null 2>&1 || true
|
||||
printf 'Default speech engine set to %s.\n' "$selectedModule"
|
||||
Executable
+180
@@ -0,0 +1,180 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
repoRoot="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
selector="$repoRoot/pi4/files/usr/local/lib/stormux/select-speech-module"
|
||||
tempDir="$(mktemp -d)"
|
||||
mockBin="$tempDir/bin"
|
||||
testCount=0
|
||||
|
||||
cleanup() {
|
||||
rm -rf "$tempDir"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
mkdir -p "$mockBin" "$tempDir/runtime"
|
||||
|
||||
cat > "$mockBin/sudo" <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
if [[ "${1:-}" == "-A" ]]; then
|
||||
shift
|
||||
fi
|
||||
if [[ "${MOCK_SUDO_FAIL_WRITE:-no}" == "yes" && "$*" == *"--write-selection"* ]]; then
|
||||
exit 1
|
||||
fi
|
||||
exec "$@"
|
||||
EOF
|
||||
|
||||
cat > "$mockBin/spd-say" <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
printf '%s\n' "$*" >> "$MOCK_LOG"
|
||||
if [[ "${1:-}" == "-O" ]]; then
|
||||
cat "$MOCK_MODULES"
|
||||
exit "${MOCK_DISCOVERY_STATUS:-0}"
|
||||
fi
|
||||
exit 0
|
||||
EOF
|
||||
|
||||
cat > "$mockBin/socat" <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
read -r command
|
||||
printf 'socat %s: %s\n' "$*" "$command" >> "$MOCK_LOG"
|
||||
EOF
|
||||
|
||||
cat > "$mockBin/systemctl" <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
printf 'systemctl %s\n' "$*" >> "$MOCK_LOG"
|
||||
if [[ "${1:-}" == "is-active" ]]; then
|
||||
[[ "${MOCK_FENRIR_ACTIVE:-no}" == "yes" ]]
|
||||
exit
|
||||
fi
|
||||
exit 0
|
||||
EOF
|
||||
chmod 755 "$mockBin"/*
|
||||
|
||||
fail() {
|
||||
printf 'FAIL: %s\n' "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
assert_equals() {
|
||||
local expected="$1"
|
||||
local actual="$2"
|
||||
local description="$3"
|
||||
|
||||
[[ "$actual" == "$expected" ]] || fail "$description (expected '$expected', got '$actual')"
|
||||
}
|
||||
|
||||
assert_file_contains() {
|
||||
local filePath="$1"
|
||||
local pattern="$2"
|
||||
local description="$3"
|
||||
|
||||
grep -qE -- "$pattern" "$filePath" || fail "$description"
|
||||
}
|
||||
|
||||
assert_file_absent() {
|
||||
local filePath="$1"
|
||||
local description="$2"
|
||||
|
||||
[[ ! -e "$filePath" ]] || fail "$description"
|
||||
}
|
||||
|
||||
reset_case() {
|
||||
caseDir="$tempDir/case-$testCount"
|
||||
testCount=$((testCount + 1))
|
||||
mkdir -p "$caseDir/runtime"
|
||||
configFile="$caseDir/speechd.conf"
|
||||
selectionFile="$caseDir/selected"
|
||||
modulesFile="$caseDir/modules"
|
||||
mockLog="$caseDir/mock.log"
|
||||
: > "$mockLog"
|
||||
printf 'OUTPUT MODULES\nrhvoice\nopenevv\nespeak-ng\n' > "$modulesFile"
|
||||
printf '# Speech Dispatcher\nDefaultModule rhvoice\n' > "$configFile"
|
||||
}
|
||||
|
||||
run_selector() {
|
||||
local input="$1"
|
||||
|
||||
printf '%b' "$input" | env \
|
||||
PATH="$mockBin:$PATH" \
|
||||
MOCK_LOG="$mockLog" \
|
||||
MOCK_MODULES="$modulesFile" \
|
||||
MOCK_DISCOVERY_STATUS="${MOCK_DISCOVERY_STATUS:-0}" \
|
||||
MOCK_FENRIR_ACTIVE="${MOCK_FENRIR_ACTIVE:-no}" \
|
||||
MOCK_SUDO_FAIL_WRITE="${MOCK_SUDO_FAIL_WRITE:-no}" \
|
||||
STORMUX_SPEECH_CONFIG="$configFile" \
|
||||
STORMUX_RUNTIME_DIR="$caseDir/runtime" \
|
||||
STORMUX_SPD_SAY=spd-say \
|
||||
STORMUX_SOCAT=socat \
|
||||
STORMUX_SYSTEMCTL=systemctl \
|
||||
"$selector" --selection-file "$selectionFile" >/dev/null
|
||||
}
|
||||
|
||||
# Enter accepts the configured initial module and collapses duplicate directives.
|
||||
reset_case
|
||||
printf 'DefaultModule rhvoice\n# DefaultModule espeak-ng\nDefaultModule openevv\n' > "$configFile"
|
||||
MOCK_FENRIR_ACTIVE=yes run_selector '\n'
|
||||
assert_equals 1 "$(grep -c '^DefaultModule ' "$configFile")" "initial selection should leave one active default"
|
||||
assert_file_contains "$configFile" '^DefaultModule rhvoice$' "initial selection should retain rhvoice"
|
||||
assert_equals rhvoice "$(< "$selectionFile")" "initial selection should be recorded"
|
||||
assert_file_contains "$mockLog" 'speech#enabled=False' "active Fenrir speech should be muted"
|
||||
assert_file_contains "$mockLog" 'speech#enabled=True' "active Fenrir speech should be restored"
|
||||
assert_file_contains "$mockLog" 'Use up and down arrows to select the default voice for this computer\.' "the selector should voice its own instructions"
|
||||
if grep -q '^systemctl restart ' "$mockLog"; then
|
||||
fail "the selector should defer the Fenrir restart until after layout selection"
|
||||
fi
|
||||
|
||||
# Down previews and selects the next module.
|
||||
reset_case
|
||||
run_selector 'x\033[B\n'
|
||||
assert_file_contains "$mockLog" '^-o openevv This is openevv\.' "Down should preview OpenEVV"
|
||||
assert_file_contains "$configFile" '^DefaultModule openevv$' "Down then Enter should select OpenEVV"
|
||||
|
||||
# Up wraps from the first module to the last.
|
||||
reset_case
|
||||
run_selector '\033[A\n'
|
||||
assert_file_contains "$mockLog" '^-o espeak-ng This is espeak-ng\.' "Up should wrap and preview eSpeak NG"
|
||||
assert_file_contains "$configFile" '^DefaultModule espeak-ng$' "wrapped module should persist"
|
||||
|
||||
# Escape retains the prior file and does not create an installer selection.
|
||||
reset_case
|
||||
cp "$configFile" "$caseDir/original.conf"
|
||||
run_selector '\033'
|
||||
cmp -s "$configFile" "$caseDir/original.conf" || fail "Escape should retain the configuration"
|
||||
assert_file_absent "$selectionFile" "Escape should not record an installer selection"
|
||||
|
||||
# Empty discovery fails safely.
|
||||
reset_case
|
||||
printf 'OUTPUT MODULES\n' > "$modulesFile"
|
||||
cp "$configFile" "$caseDir/original.conf"
|
||||
run_selector '\n'
|
||||
cmp -s "$configFile" "$caseDir/original.conf" || fail "empty discovery should retain the configuration"
|
||||
assert_file_absent "$selectionFile" "empty discovery should not record a selection"
|
||||
|
||||
# Unsafe names are rejected rather than passed to spd-say or configuration.
|
||||
reset_case
|
||||
printf 'OUTPUT MODULES\nbad name\n;command\nopenevv\n' > "$modulesFile"
|
||||
run_selector '\n'
|
||||
assert_file_contains "$configFile" '^DefaultModule openevv$' "the remaining safe module should be selected"
|
||||
if grep -qE 'bad name|;command' "$mockLog"; then
|
||||
fail "unsafe module names should not reach spd-say"
|
||||
fi
|
||||
|
||||
# A missing configuration simulates failed persistence and remains nonfatal.
|
||||
reset_case
|
||||
rm -f "$configFile"
|
||||
MOCK_FENRIR_ACTIVE=yes run_selector '\n'
|
||||
assert_file_absent "$selectionFile" "failed persistence should not record a selection"
|
||||
assert_file_contains "$mockLog" 'selection failed' "failed persistence should be announced"
|
||||
assert_file_contains "$mockLog" 'speech#enabled=True' "failed persistence should restore Fenrir speech"
|
||||
|
||||
# Failure to record the live choice also rolls the system configuration back.
|
||||
reset_case
|
||||
cp "$configFile" "$caseDir/original.conf"
|
||||
MOCK_SUDO_FAIL_WRITE=yes run_selector '\033[B\n'
|
||||
cmp -s "$configFile" "$caseDir/original.conf" || fail "selection-file failure should roll back the configuration"
|
||||
assert_file_absent "$selectionFile" "selection-file failure should leave no selection"
|
||||
|
||||
printf 'PASS: %s speech selector cases\n' "$testCount"
|
||||
+44
-8
@@ -89,7 +89,7 @@ The Stormux repository key is also embedded in the ISO at `/usr/share/stormux/st
|
||||
- The UEFI systemd-boot menu enables its audible beep
|
||||
- Boot menu defaults to accessible entry
|
||||
- Service startup order ensures audio is ready before screen reader
|
||||
- First-login live-environment setup calibrates volume, checks networking and time, then offers to run the installer
|
||||
- First-login setup calibrates volume, selects the default speech engine and Fenrir keyboard layout, starts Fenrir, then checks networking and time before offering the installer
|
||||
|
||||
### Package Management
|
||||
|
||||
@@ -113,21 +113,31 @@ The live environment uses a carefully orchestrated startup sequence to ensure Fe
|
||||
- Starts pipewire user services
|
||||
- Unmutes audio and sets volume to 70%
|
||||
|
||||
2. **stormux-speech.service** - Runs after audio setup
|
||||
- Waits 2 seconds for pipewire to fully initialize
|
||||
- Starts fenrirscreenreader.service
|
||||
2. **First-login setup on tty1**
|
||||
- Calibrates volume using Speech Dispatcher
|
||||
- Offers the default speech-engine selector
|
||||
- Speaks the laptop-layout question using the selected engine
|
||||
- Sets `[keyboard] layout` in `/etc/fenrirscreenreader/settings/settings.toml`, preserving comments, and validates the configuration
|
||||
- Starts `fenrirscreenreader.service` with the selected settings
|
||||
|
||||
3. **fenrirscreenreader.service** - Screen reader with dependencies
|
||||
- Configured to wait for pipewire, speech-dispatcher, and sound.target
|
||||
- Configured to wait for user audio initialization and sound.target
|
||||
- Uses speech-dispatcher for TTS output
|
||||
- Disabled at boot in the live ISO; started by first-login setup
|
||||
|
||||
This ensures Fenrir never starts without working audio, preventing system freezes or silent boot.
|
||||
The old `stormux-speech.service` boot launcher is also disabled in the live ISO. The installed system still enables Fenrir at boot.
|
||||
|
||||
## Live Setup and Installer Flow
|
||||
|
||||
On first login to tty1, the live environment runs a short setup script. It calibrates speech volume, checks for network access, updates the live environment clock, copies the detected timezone into the installer defaults, and then asks whether to run `install-stormux`.
|
||||
On first login to tty1, setup calibrates volume, selects the default speech engine, and asks whether to use Fenrir's laptop layout. These prompts use Speech Dispatcher directly while Fenrir is stopped. Enter at the layout prompt selects desktop layout. Setup then starts Fenrir, presents the welcome prompt, checks for network access, updates the live environment clock, and asks whether to run `install-stormux`.
|
||||
|
||||
The installer gives one last chance to accept or change the timezone before installation. The live setup changes are for the temporary live environment only; the installed system is configured by `install-stormux`.
|
||||
The installer gives one last chance to accept or change the timezone before installation. Live setup configures the running ISO; `install-stormux` carries the settings described below into the installed system.
|
||||
|
||||
The installed system includes `intel-ucode` for Intel CPUs or `amd-ucode` for AMD CPUs, selected from the running machine's CPU vendor. Other or unidentified vendors produce a warning and do not select a microcode package. Arch's default mkinitcpio `microcode` hook includes the installed microcode in the initramfs used by either bootloader. The installer also installs `irqbalance` and enables `irqbalance.service` for the installed system's next boot.
|
||||
|
||||
Before finishing, the installer saves the live ALSA mixer settings and copies WirePlumber's saved volumes, output selection, and audio profiles to root, the user skeleton, and each installed user. This carries the volume selected during live setup into the installed system while allowing later volume changes to be saved normally. If the live audio state is unavailable, the installer logs a warning.
|
||||
|
||||
Active Wi-Fi and Ethernet profiles are exported from NetworkManager with their available saved credentials, IP settings, and any referenced 802.1X certificate/key files. The installed copies autoconnect and are usable by the new users, even when the live profile was restricted to the `stormux` user. Credentials and certificates are stored in root-owned files with mode 600 and are not printed in the installation log. Existing target profiles with the same UUID are preserved. VPNs and other connection types, unavailable secrets, and unreadable certificates produce transfer warnings and may need manual setup. Live connections are not changed or restarted.
|
||||
|
||||
## Differences from Pi4 Build
|
||||
|
||||
@@ -146,6 +156,21 @@ After building, test the ISO with:
|
||||
- VirtualBox
|
||||
- Physical hardware (USB/CD)
|
||||
|
||||
Before building, run the focused checks from this directory:
|
||||
|
||||
```bash
|
||||
python3 tests/test-live-fenrir-setup.py
|
||||
python3 tests/test-installer-hardware.py
|
||||
python3 -B tests/test-installer-live-settings.py
|
||||
bash ../tests/test-select-speech-module.sh
|
||||
```
|
||||
|
||||
The installer hardware tests mock package installation and service management. After a test installation on Intel or AMD hardware, check the selected microcode package, inspect the initramfs with `lsinitcpio --early /boot/initramfs-linux.img`, and confirm `systemctl is-enabled irqbalance.service`. After booting the installed system, check `systemctl status irqbalance.service` and `journalctl -b -k -g microcode`. Verify both UEFI and BIOS installations; mocked tests do not prove boot-time microcode loading or interrupt balancing.
|
||||
|
||||
The live-settings tests require `python-gobject` and NetworkManager's libnm bindings. They use real libnm serialization and temporary files, with a simulated active-connection list and credential retrieval. They do not contact NetworkManager, change mixer controls, start services, or produce speech. For live acceptance, select an audible volume and a Wi-Fi or Ethernet connection in the ISO, install using a different username, and reboot without the ISO. Confirm the first spoken output uses the selected volume, networking reconnects without re-entering credentials, and a later volume change survives another reboot. Also check a console-only installation and a multi-user installation. Keep passwords and certificate contents out of shared test logs.
|
||||
|
||||
For boot acceptance, confirm that Fenrir stays silent during volume calibration and voice selection, the laptop prompt uses the selected voice, and Fenrir starts once afterward. Test both desktop (Enter or N) and laptop (Y) bindings, voice selection with Enter and Escape, network setup with and without a connection, and declining the installer. After a test installation, confirm that the selected voice persists and Fenrir starts at boot. Automated checks do not establish audible speech, physical keyboard behavior, or installed-system acceptance.
|
||||
|
||||
For VM testing with audio:
|
||||
```bash
|
||||
./qemu-boot.sh
|
||||
@@ -172,6 +197,17 @@ Edit `packages.x86_64` and add package names (one per line).
|
||||
Place files in `airootfs/` following the target filesystem structure.
|
||||
The x86_64 build uses this overlay directly.
|
||||
|
||||
### Default X Resources
|
||||
|
||||
Keep `airootfs/etc/skel.stormux/.Xresources` and
|
||||
`airootfs/home/stormux/.Xresources` identical. The home copy supplies the live
|
||||
user's defaults. During ISO creation, the skeleton copy is placed in
|
||||
`/etc/skel`; `install-stormux` copies it into the target's `/etc/skel` after
|
||||
package installation and before creating users. All users created with new
|
||||
home directories by the installer inherit `~/.Xresources`, regardless of the
|
||||
selected desktop or partition layout. Users created later with `useradd -m`
|
||||
inherit it as well. Reused home directories keep their existing files.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Build fails with GPG errors
|
||||
|
||||
@@ -32,7 +32,7 @@ while [[ $volume -le 130 ]]; do
|
||||
clear
|
||||
pactl set-sink-volume @DEFAULT_SINK@ "${volume}%" 2>/dev/null
|
||||
spd-say "If this is loud enough, press enter."
|
||||
if read -t4 ; then
|
||||
if read -r -t4 ; then
|
||||
echo "Volume set to ${volume}%"
|
||||
break
|
||||
else
|
||||
@@ -47,13 +47,7 @@ if [[ -x /etc/audibleprompt.sh ]]; then
|
||||
export sudoFlags=("-A")
|
||||
fi
|
||||
|
||||
clear
|
||||
cat << "EOF"
|
||||
Hello, and welcome to Stormux!
|
||||
/usr/local/lib/stormux/select-speech-module \
|
||||
--selection-file /run/stormux/selected-speech-module
|
||||
|
||||
Let's get you set up.
|
||||
|
||||
Please press enter to continue.
|
||||
EOF
|
||||
read -r
|
||||
sudo "${sudoFlags[@]}" configure-stormux
|
||||
@@ -0,0 +1,25 @@
|
||||
! Start in Unicode
|
||||
XTerm*utf8: 1
|
||||
UXTerm*utf8: 1
|
||||
! Use white-on-black colors
|
||||
XTerm.vt100.reverseVideo: true
|
||||
UXTerm.vt100.reverseVideo: true
|
||||
! XTerm already has 256 colors support
|
||||
! We ask it to set the correct $TERM XTerm.termName: xterm-256color
|
||||
UXTerm.termName: xterm-256color
|
||||
! Start with maximized window
|
||||
xterm*maximized: true
|
||||
! Make Alt key behave like in other terminals
|
||||
XTerm.vt100.altIsNotMeta: true
|
||||
UXTerm.vt100.altIsNotMeta: true
|
||||
XTerm.vt100.metaSendsEscape: true
|
||||
UXTerm.vt100.metaSendsEscape: true
|
||||
URxvt.perl-ext-common: "default, -searchable-scrollback"
|
||||
URxvt.font: xft:terminus:size=16
|
||||
*VT100.Translations: #override \
|
||||
<Key>BackSpace: string(0x7F)\n\
|
||||
<Key>Delete: string("\033[3~")\n\
|
||||
<Key>Home: string("\033[1~")\n\
|
||||
<Key>End: string("\033[4~")\n\
|
||||
Ctrl Shift <Key>V: insert-selection(CLIPBOARD)
|
||||
*ttyModes: erase ^?
|
||||
@@ -1,5 +1,5 @@
|
||||
[Unit]
|
||||
# Ensure audio and speech-dispatcher are available before starting Fenrir
|
||||
# Ensure audio is available before starting Fenrir.
|
||||
# Wait for user audio initialization to complete
|
||||
After=sound.target stormux-audio-setup.service speech-dispatcherd.service user@1000.service
|
||||
Wants=stormux-audio-setup.service speech-dispatcherd.service user@1000.service
|
||||
After=sound.target stormux-audio-setup.service user@1000.service
|
||||
Wants=stormux-audio-setup.service user@1000.service
|
||||
@@ -0,0 +1,25 @@
|
||||
! Start in Unicode
|
||||
XTerm*utf8: 1
|
||||
UXTerm*utf8: 1
|
||||
! Use white-on-black colors
|
||||
XTerm.vt100.reverseVideo: true
|
||||
UXTerm.vt100.reverseVideo: true
|
||||
! XTerm already has 256 colors support
|
||||
! We ask it to set the correct $TERM XTerm.termName: xterm-256color
|
||||
UXTerm.termName: xterm-256color
|
||||
! Start with maximized window
|
||||
xterm*maximized: true
|
||||
! Make Alt key behave like in other terminals
|
||||
XTerm.vt100.altIsNotMeta: true
|
||||
UXTerm.vt100.altIsNotMeta: true
|
||||
XTerm.vt100.metaSendsEscape: true
|
||||
UXTerm.vt100.metaSendsEscape: true
|
||||
URxvt.perl-ext-common: "default, -searchable-scrollback"
|
||||
URxvt.font: xft:terminus:size=16
|
||||
*VT100.Translations: #override \
|
||||
<Key>BackSpace: string(0x7F)\n\
|
||||
<Key>Delete: string("\033[3~")\n\
|
||||
<Key>Home: string("\033[1~")\n\
|
||||
<Key>End: string("\033[4~")\n\
|
||||
Ctrl Shift <Key>V: insert-selection(CLIPBOARD)
|
||||
*ttyModes: erase ^?
|
||||
@@ -94,9 +94,24 @@ locale-gen
|
||||
install_sas
|
||||
install_rhvoice_english_fixes
|
||||
|
||||
if command -v spd-conf > /dev/null 2>&1; then
|
||||
spd-conf -n -C || echo "Warning: Speech Dispatcher system configuration failed."
|
||||
fi
|
||||
if [[ -f /etc/speech-dispatcher/speechd.conf ]]; then
|
||||
speechBackup="$(mktemp)"
|
||||
if /usr/local/lib/stormux/select-speech-module \
|
||||
--apply-module rhvoice /etc/speech-dispatcher/speechd.conf "$speechBackup"; then
|
||||
rm -f "$speechBackup"
|
||||
else
|
||||
echo "Warning: Could not set RHVoice as the default speech engine."
|
||||
rm -f "$speechBackup"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Enable system services
|
||||
systemctl enable NetworkManager.service
|
||||
systemctl enable fenrirscreenreader.service
|
||||
# The first-login setup starts Fenrir after volume, voice, and layout selection.
|
||||
systemctl disable fenrirscreenreader.service stormux-speech.service
|
||||
systemctl enable brltty.path
|
||||
|
||||
# Enable user services globally for all users
|
||||
|
||||
@@ -37,23 +37,67 @@ set_timezone() {
|
||||
ln -sf /usr/share/zoneinfo/"${region}"/"${city}" /etc/localtime
|
||||
timedatectl set-ntp true
|
||||
}
|
||||
# Offer to switch fenrir layout.
|
||||
echo "Would you like to switch Fenrir to laptop layout?"
|
||||
echo "Press y for yes or n for no followed by enter."
|
||||
read -r continue
|
||||
continue="${continue::1}"
|
||||
if [[ "${continue,}" == "y" ]];then
|
||||
sed -i 's/=desktop/=laptop/' /etc/fenrirscreenreader/settings/settings.conf
|
||||
clear
|
||||
systemctl restart fenrirscreenreader.service
|
||||
fi
|
||||
|
||||
configure_fenrir() {
|
||||
local keyboardLayout="desktop" answer configPath tempPath serviceAction="start"
|
||||
configPath="/etc/fenrirscreenreader/settings/settings.toml"
|
||||
# A manual rerun must also apply the newly selected launch-time layout.
|
||||
if systemctl is-active --quiet fenrirscreenreader.service; then
|
||||
serviceAction="restart"
|
||||
fi
|
||||
|
||||
# Reload the default engine selected before this script was started.
|
||||
killall speech-dispatcher 2>/dev/null || true
|
||||
while true; do
|
||||
echo "Would you like to switch Fenrir to laptop layout? [y/N]"
|
||||
spd-say -w "Would you like to switch Fenrir to laptop layout? Press y for yes or n for no, followed by Enter. Press Enter for desktop layout."
|
||||
read -r answer || return 1
|
||||
case "${answer,,}" in
|
||||
y|yes) keyboardLayout="laptop"; break ;;
|
||||
n|no|"") break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
tempPath="$(mktemp "${configPath}.stormux.XXXXXX")" || return 1
|
||||
if ! cp --preserve=mode,ownership "$configPath" "$tempPath" || ! awk -v layout="$keyboardLayout" '
|
||||
/^[[:space:]]*\[/ { inKeyboard = ($0 ~ /^[[:space:]]*\[keyboard\][[:space:]]*(#.*)?$/) }
|
||||
inKeyboard && /^[[:space:]]*layout[[:space:]]*=/ {
|
||||
if (sub(/=[[:space:]]*("[^"]*"|\047[^\047]*\047)/, "= \"" layout "\"")) {
|
||||
changed++
|
||||
}
|
||||
}
|
||||
{ print }
|
||||
END { if (changed != 1) exit 1 }
|
||||
' "$configPath" > "$tempPath" || ! fenrir --config "$tempPath" --check-config; then
|
||||
rm -f "$tempPath"
|
||||
echo "Could not configure Fenrir. The original settings were preserved."
|
||||
spd-say -w "Could not configure Fenrir. The original settings were preserved."
|
||||
return 1
|
||||
fi
|
||||
if ! mv -f "$tempPath" "$configPath"; then
|
||||
rm -f "$tempPath"
|
||||
return 1
|
||||
fi
|
||||
if ! systemctl "$serviceAction" fenrirscreenreader.service; then
|
||||
echo "Fenrir could not start. Check journalctl -u fenrirscreenreader.service."
|
||||
spd-say -w "Fenrir could not start. Check the screen reader service log."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
configure_fenrir || exit 1
|
||||
|
||||
clear
|
||||
echo "Hello, and welcome to Stormux!"
|
||||
echo "Let's get you set up. Please press enter to continue."
|
||||
read -r
|
||||
|
||||
if ! ping -c1 stormux.org &> /dev/null ; then
|
||||
echo "No internet connection detected. Press enter to open NetworkManager."
|
||||
read -r continue
|
||||
echo "setting set focus#highlight=True" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-daemon.sock
|
||||
read -r
|
||||
echo "setting set reading#mode=highlight" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-daemon.sock
|
||||
nmtui-connect
|
||||
echo "setting set focus#highlight=False" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-daemon.sock
|
||||
echo "setting set reading#mode=cursor" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-daemon.sock
|
||||
fi
|
||||
# Check for internet connectivity
|
||||
if ping -qc1 -W 1 stormux.org &> /dev/null; then
|
||||
|
||||
@@ -31,6 +31,14 @@ errorCount=0
|
||||
warningCount=0
|
||||
currentStep="initialization"
|
||||
cleanupOnError=false
|
||||
selectedSpeechModule="rhvoice"
|
||||
|
||||
if [[ -r /run/stormux/selected-speech-module ]]; then
|
||||
mapfile -t selectedSpeechLines < /run/stormux/selected-speech-module
|
||||
if [[ ${#selectedSpeechLines[@]} -eq 1 && "${selectedSpeechLines[0]}" =~ ^[A-Za-z0-9][A-Za-z0-9_.-]*$ ]]; then
|
||||
selectedSpeechModule="${selectedSpeechLines[0]}"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
@@ -1382,9 +1390,23 @@ install_base_system() {
|
||||
local basePackages=(
|
||||
base base-devel linux linux-firmware
|
||||
networkmanager sudo dialog git ii rsync wget curl
|
||||
bash-completion cronie openssh rng-tools
|
||||
bash-completion cronie openssh rng-tools irqbalance
|
||||
)
|
||||
|
||||
local cpuVendor
|
||||
cpuVendor=$(awk '/^vendor_id[[:space:]]*:/ { print $3; exit }' /proc/cpuinfo)
|
||||
case "$cpuVendor" in
|
||||
GenuineIntel)
|
||||
basePackages+=(intel-ucode)
|
||||
;;
|
||||
AuthenticAMD)
|
||||
basePackages+=(amd-ucode)
|
||||
;;
|
||||
*)
|
||||
log_warning "No CPU microcode package selected for vendor: ${cpuVendor:-unknown}"
|
||||
;;
|
||||
esac
|
||||
|
||||
local audioPackages=(
|
||||
pipewire pipewire-alsa pipewire-pulse pipewire-jack
|
||||
wireplumber alsa-utils sox gstreamer
|
||||
@@ -1412,7 +1434,7 @@ install_base_system() {
|
||||
# Stormux-specific packages (installed later in chroot after keyring setup)
|
||||
# Note: NOT local so it's available in configure_system()
|
||||
stormuxPackages=(
|
||||
yay w3m-git
|
||||
openevv-git yay w3m-git
|
||||
)
|
||||
|
||||
# Combine all packages
|
||||
@@ -1459,6 +1481,10 @@ install_base_system() {
|
||||
|
||||
copy_rhvoice_english_fixes
|
||||
|
||||
# Populate the target skeleton before configure_system creates users.
|
||||
log_info "Installing default X resources"
|
||||
install -Dm644 /etc/skel/.Xresources "$mountPoint/etc/skel/.Xresources"
|
||||
|
||||
# Generate or preserve fstab
|
||||
if [[ "$useExistingMount" == true ]]; then
|
||||
if grep -Eq '^[[:space:]]*[^#[:space:]]' "$mountPoint/etc/fstab" 2>/dev/null; then
|
||||
@@ -1603,6 +1629,60 @@ EOF
|
||||
log_info "Audio configuration installed"
|
||||
}
|
||||
|
||||
#
|
||||
# Live settings transfer
|
||||
#
|
||||
|
||||
copy_live_audio_settings() {
|
||||
log_info "Saving live audio settings for the installed system"
|
||||
|
||||
local alsaState liveHome stateName targetHome stateDir
|
||||
local targetHomes=("$mountPoint/etc/skel" "$mountPoint/root")
|
||||
local stateNames=(default-routes default-nodes default-profile stream-properties restore-stream)
|
||||
|
||||
mkdir -p "$mountPoint/var/lib/alsa"
|
||||
alsaState=$(mktemp "$mountPoint/var/lib/alsa/asound.state.XXXXXX")
|
||||
if alsactl -f "$alsaState" store; then
|
||||
mv -f "$alsaState" "$mountPoint/var/lib/alsa/asound.state"
|
||||
else
|
||||
rm -f "$alsaState"
|
||||
log_warning "Could not save live ALSA mixer settings"
|
||||
fi
|
||||
|
||||
if ! liveHome=$(getent passwd stormux | cut -d: -f6) || [[ -z "$liveHome" ]]; then
|
||||
log_warning "Could not find the live user's audio settings"
|
||||
return 0
|
||||
fi
|
||||
stateDir="$liveHome/.local/state/wireplumber"
|
||||
if [[ ! -f "$stateDir/default-routes" ]]; then
|
||||
log_warning "Live WirePlumber volume settings are unavailable"
|
||||
return 0
|
||||
fi
|
||||
|
||||
for targetHome in "${userNames[@]}"; do
|
||||
targetHomes+=("$mountPoint/home/$targetHome")
|
||||
done
|
||||
for targetHome in "${targetHomes[@]}"; do
|
||||
mkdir -p "$targetHome/.local/state"
|
||||
chown --reference="$targetHome" "$targetHome/.local" "$targetHome/.local/state"
|
||||
install -d -m 700 "$targetHome/.local/state/wireplumber"
|
||||
chown --reference="$targetHome" "$targetHome/.local/state/wireplumber"
|
||||
for stateName in "${stateNames[@]}"; do
|
||||
if [[ -f "$stateDir/$stateName" && ! -L "$stateDir/$stateName" ]]; then
|
||||
install -m 600 "$stateDir/$stateName" "$targetHome/.local/state/wireplumber/$stateName"
|
||||
chown --reference="$targetHome" "$targetHome/.local/state/wireplumber/$stateName"
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
copy_live_network_connections() {
|
||||
log_info "Saving active network connections for the installed system"
|
||||
if ! /usr/local/lib/stormux/copy-live-network "$mountPoint" 2>&1 | tee -a "$logFile"; then
|
||||
log_warning "Some live network settings could not be copied; review the network transfer warnings"
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# SSH login monitor installation (script + service)
|
||||
#
|
||||
@@ -1696,10 +1776,10 @@ fi
|
||||
gameManagerPackagesCmd+="
|
||||
# Install packages for audiogame-manager
|
||||
echo \"Installing packages for audiogame-manager...\"
|
||||
# Critical packages: wine, p7zip, curl, dialog, sox, cabextract, unzip, xz
|
||||
# Critical packages: wine, wine-access, p7zip, curl, dialog, sox, cabextract, unzip, xz
|
||||
# Optional packages: winetricks, wine_gecko, wine-mono, translate-shell, gawk, perl, xclip, xdotool
|
||||
# Audio packages: gst-plugins for multimedia support
|
||||
if ! pacman -S --noconfirm --needed wine winetricks wine_gecko wine-mono p7zip curl dialog sox cabextract unzip xz translate-shell gawk perl xclip xdotool gst-plugins-bad gst-plugins-good gst-plugins-ugly gst-libav; then
|
||||
if ! pacman -S --noconfirm --needed wine wine-access winetricks wine_gecko wine-mono p7zip curl dialog sox cabextract unzip xz translate-shell gawk perl xclip xdotool gst-plugins-bad gst-plugins-good gst-plugins-ugly gst-libav; then
|
||||
echo \"WARNING: Failed to install one or more audiogame-manager dependencies\"
|
||||
fi
|
||||
"
|
||||
@@ -1786,6 +1866,7 @@ systemctl enable NetworkManager.service
|
||||
systemctl enable brltty.path
|
||||
systemctl enable fenrirscreenreader.service
|
||||
systemctl enable cronie.service
|
||||
systemctl enable irqbalance.service
|
||||
|
||||
# Enable bluetooth if present
|
||||
if ! systemctl enable bluetooth.service; then
|
||||
@@ -1902,11 +1983,28 @@ if command -v spd-conf > /dev/null 2>&1; then
|
||||
fi
|
||||
|
||||
if [[ -f /etc/speech-dispatcher/speechd.conf ]]; then
|
||||
if grep -qE '^[[:space:]]*#?[[:space:]]*DefaultModule[[:space:]]+' /etc/speech-dispatcher/speechd.conf; then
|
||||
sed -i -E 's/^[[:space:]]*#?[[:space:]]*DefaultModule[[:space:]]+.*/DefaultModule rhvoice/' /etc/speech-dispatcher/speechd.conf
|
||||
else
|
||||
printf '\nDefaultModule rhvoice\n' >> /etc/speech-dispatcher/speechd.conf
|
||||
fi
|
||||
speechConfig=/etc/speech-dispatcher/speechd.conf
|
||||
speechConfigTemp="\$(mktemp "\${speechConfig}.stormux.XXXXXX")"
|
||||
awk -v moduleName="${selectedSpeechModule}" '
|
||||
BEGIN { wroteDefault = 0 }
|
||||
/^[[:space:]]*#?[[:space:]]*DefaultModule[[:space:]]+/ {
|
||||
if (!wroteDefault) {
|
||||
print "DefaultModule " moduleName
|
||||
wroteDefault = 1
|
||||
}
|
||||
next
|
||||
}
|
||||
{ print }
|
||||
END {
|
||||
if (!wroteDefault) {
|
||||
print ""
|
||||
print "DefaultModule " moduleName
|
||||
}
|
||||
}
|
||||
' "\$speechConfig" > "\$speechConfigTemp"
|
||||
chown --reference="\$speechConfig" "\$speechConfigTemp"
|
||||
chmod --reference="\$speechConfig" "\$speechConfigTemp"
|
||||
mv -f "\$speechConfigTemp" "\$speechConfig"
|
||||
fi
|
||||
|
||||
# Create system-wide accessibility configuration
|
||||
@@ -2248,6 +2346,11 @@ install_ssh_login_monitor
|
||||
currentStep="chroot system configuration"
|
||||
configure_system
|
||||
|
||||
# Preserve the live selections after package setup and user creation.
|
||||
currentStep="live audio and network settings"
|
||||
copy_live_audio_settings
|
||||
copy_live_network_connections
|
||||
|
||||
# Install bootloader
|
||||
currentStep="bootloader installation"
|
||||
install_bootloader
|
||||
|
||||
@@ -13,6 +13,8 @@ if [ -d /etc/skel.custom ]; then
|
||||
fi
|
||||
|
||||
# Set the distribution name
|
||||
# /etc/issue interprets these escapes when getty displays it.
|
||||
# shellcheck disable=SC2028
|
||||
echo 'Stormux \r (\l)' > /etc/issue
|
||||
echo >> /etc/issue
|
||||
|
||||
@@ -54,9 +56,10 @@ echo stormux > /etc/hostname
|
||||
systemctl disable systemd-networkd.service systemd-networkd.socket 2>/dev/null || true
|
||||
|
||||
# Enable services
|
||||
# The first-login setup starts Fenrir after volume, voice, and layout selection.
|
||||
systemctl disable fenrirscreenreader.service stormux-speech.service
|
||||
services=(
|
||||
brltty.path
|
||||
fenrirscreenreader.service
|
||||
NetworkManager.service
|
||||
stormux-audio-setup.service
|
||||
)
|
||||
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Export active Wi-Fi/Ethernet profiles without modifying the live connection."""
|
||||
|
||||
from pathlib import Path
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
from uuid import UUID
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("NM", "1.0")
|
||||
from gi.repository import GLib, NM
|
||||
|
||||
|
||||
def write_private_file(filePath, contents):
|
||||
filePath.parent.mkdir(mode=0o700, parents=True, exist_ok=True)
|
||||
descriptor, tempName = tempfile.mkstemp(dir=filePath.parent)
|
||||
try:
|
||||
with os.fdopen(descriptor, "wb") as targetFile:
|
||||
targetFile.write(contents)
|
||||
os.replace(tempName, filePath)
|
||||
finally:
|
||||
if os.path.exists(tempName):
|
||||
os.unlink(tempName)
|
||||
|
||||
|
||||
def profile_exists(profileDir, connectionUuid):
|
||||
for profilePath in profileDir.glob("*"):
|
||||
if not profilePath.is_file():
|
||||
continue
|
||||
keyfile = GLib.KeyFile.new()
|
||||
try:
|
||||
keyfile.load_from_file(str(profilePath), GLib.KeyFileFlags.NONE)
|
||||
if keyfile.get_string("connection", "uuid") == connectionUuid:
|
||||
return True
|
||||
except GLib.Error:
|
||||
continue
|
||||
return False
|
||||
|
||||
|
||||
def copy_certificates(connection, targetRoot, connectionUuid):
|
||||
setting = connection.get_setting_802_1x()
|
||||
if setting is None:
|
||||
return
|
||||
for propertyName in (
|
||||
"ca-cert", "client-cert", "private-key",
|
||||
"phase2-ca-cert", "phase2-client-cert", "phase2-private-key",
|
||||
):
|
||||
methodName = propertyName.replace("-", "_")
|
||||
if getattr(setting, f"get_{methodName}_scheme")() != NM.Setting8021xCKScheme.PATH:
|
||||
continue
|
||||
sourcePath = Path(getattr(setting, f"get_{methodName}_path")())
|
||||
installedPath = Path("/etc/NetworkManager/certs") / connectionUuid / propertyName
|
||||
write_private_file(targetRoot / installedPath.relative_to("/"), sourcePath.read_bytes())
|
||||
setting.set_property(
|
||||
propertyName, GLib.Bytes.new(b"file://" + os.fsencode(installedPath) + b"\0")
|
||||
)
|
||||
|
||||
|
||||
def copy_connection(remote, targetRoot):
|
||||
connectionUuid = str(UUID(remote.get_uuid()))
|
||||
profileDir = targetRoot / "etc/NetworkManager/system-connections"
|
||||
if profile_exists(profileDir, connectionUuid):
|
||||
print(f"Preserving existing installed network profile {connectionUuid}")
|
||||
return
|
||||
|
||||
connection = NM.SimpleConnection.new_clone(remote)
|
||||
connection.verify()
|
||||
for setting in remote.get_settings():
|
||||
secretNames = [
|
||||
prop.name for prop in setting.list_properties()
|
||||
if prop.flags & NM.SETTING_PARAM_SECRET
|
||||
]
|
||||
if not secretNames:
|
||||
continue
|
||||
settingName = setting.get_name()
|
||||
secrets = remote.get_secrets(settingName, None)
|
||||
if secrets is not None:
|
||||
connection.update_secrets(settingName, secrets)
|
||||
copiedSetting = connection.get_setting_by_name(settingName)
|
||||
for secretName in secretNames:
|
||||
if copiedSetting.get_property(secretName) is not None:
|
||||
copiedSetting.set_secret_flags(secretName, NM.SettingSecretFlags.NONE)
|
||||
|
||||
if connection.need_secrets()[0]:
|
||||
raise ValueError("Required credentials are unavailable")
|
||||
# Live-user restrictions must not exclude the newly created users.
|
||||
settings = connection.get_setting_connection()
|
||||
settings.props.permissions = []
|
||||
settings.props.autoconnect = True
|
||||
copy_certificates(connection, targetRoot, connectionUuid)
|
||||
connection.verify()
|
||||
connection.verify_secrets()
|
||||
keyfile = NM.keyfile_write(connection, NM.KeyfileHandlerFlags.NONE, None, None)
|
||||
write_private_file(
|
||||
profileDir / f"stormux-live-{connectionUuid}.nmconnection",
|
||||
keyfile.to_data()[0].encode("utf-8"),
|
||||
)
|
||||
|
||||
|
||||
def copy_active_connections(client, targetRoot):
|
||||
failed = False
|
||||
copiedCount = 0
|
||||
for active in client.get_active_connections():
|
||||
connectionType = active.get_connection_type()
|
||||
if connectionType == "loopback":
|
||||
continue
|
||||
if connectionType not in ("802-11-wireless", "802-3-ethernet"):
|
||||
print("WARNING: An active network profile needs manual transfer (unsupported connection type)")
|
||||
failed = True
|
||||
continue
|
||||
try:
|
||||
remote = active.get_connection()
|
||||
if remote is None:
|
||||
raise ValueError("Active connection has no profile")
|
||||
copy_connection(remote, targetRoot)
|
||||
copiedCount += 1
|
||||
except (GLib.Error, OSError, ValueError):
|
||||
# Exceptions may contain credentials or private paths. Never log them.
|
||||
print("WARNING: Could not transfer an active network profile and its credentials or certificates")
|
||||
failed = True
|
||||
print(f"Preserved {copiedCount} active network connection(s)")
|
||||
return not failed
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 2 or os.geteuid() != 0:
|
||||
print("Usage (as root): copy-live-network TARGET_ROOT", file=sys.stderr)
|
||||
return 1
|
||||
try:
|
||||
client = NM.Client.new(None)
|
||||
if not client.get_nm_running():
|
||||
raise ValueError("NetworkManager is not running")
|
||||
return 0 if copy_active_connections(client, Path(sys.argv[1])) else 1
|
||||
except (GLib.Error, OSError, ValueError):
|
||||
print("WARNING: Could not read live NetworkManager connections")
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
+334
@@ -0,0 +1,334 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -u
|
||||
|
||||
speechConfig="${STORMUX_SPEECH_CONFIG:-/etc/speech-dispatcher/speechd.conf}"
|
||||
selectionFile=""
|
||||
spdSayCommand="${STORMUX_SPD_SAY:-spd-say}"
|
||||
systemctlCommand="${STORMUX_SYSTEMCTL:-systemctl}"
|
||||
socatCommand="${STORMUX_SOCAT:-socat}"
|
||||
fenrirSocket="${STORMUX_FENRIR_SOCKET:-/tmp/fenrirscreenreader-daemon.sock}"
|
||||
scriptPath="$(readlink -f "$0")"
|
||||
runtimeDir="${STORMUX_RUNTIME_DIR:-/run/stormux}"
|
||||
fenrirSpeechMuted=false
|
||||
|
||||
is_safe_module() {
|
||||
[[ "$1" =~ ^[A-Za-z0-9][A-Za-z0-9_.-]*$ ]]
|
||||
}
|
||||
|
||||
apply_module() {
|
||||
local moduleName="$1"
|
||||
local configPath="$2"
|
||||
local backupPath="$3"
|
||||
local tempPath
|
||||
|
||||
is_safe_module "$moduleName" || return 1
|
||||
[[ -f "$configPath" ]] || return 1
|
||||
|
||||
mkdir -p "${backupPath%/*}" || return 1
|
||||
cp --preserve=mode,ownership,timestamps "$configPath" "$backupPath" || return 1
|
||||
tempPath="$(mktemp "${configPath}.stormux.XXXXXX")" || return 1
|
||||
|
||||
if ! awk -v moduleName="$moduleName" '
|
||||
BEGIN { wroteDefault = 0 }
|
||||
/^[[:space:]]*#?[[:space:]]*DefaultModule[[:space:]]+/ {
|
||||
if (!wroteDefault) {
|
||||
print "DefaultModule " moduleName
|
||||
wroteDefault = 1
|
||||
}
|
||||
next
|
||||
}
|
||||
{ print }
|
||||
END {
|
||||
if (!wroteDefault) {
|
||||
print ""
|
||||
print "DefaultModule " moduleName
|
||||
}
|
||||
}
|
||||
' "$configPath" > "$tempPath"; then
|
||||
rm -f "$tempPath"
|
||||
return 1
|
||||
fi
|
||||
|
||||
chown --reference="$configPath" "$tempPath" || {
|
||||
rm -f "$tempPath"
|
||||
return 1
|
||||
}
|
||||
chmod --reference="$configPath" "$tempPath" || {
|
||||
rm -f "$tempPath"
|
||||
return 1
|
||||
}
|
||||
mv -f "$tempPath" "$configPath"
|
||||
}
|
||||
|
||||
restore_config() {
|
||||
local configPath="$1"
|
||||
local backupPath="$2"
|
||||
local tempPath
|
||||
|
||||
[[ -f "$backupPath" ]] || return 1
|
||||
tempPath="$(mktemp "${configPath}.stormux.XXXXXX")" || return 1
|
||||
if ! cp --preserve=mode,ownership,timestamps "$backupPath" "$tempPath"; then
|
||||
rm -f "$tempPath"
|
||||
return 1
|
||||
fi
|
||||
mv -f "$tempPath" "$configPath" || return 1
|
||||
rm -f "$backupPath"
|
||||
}
|
||||
|
||||
write_selection() {
|
||||
local moduleName="$1"
|
||||
local targetPath="$2"
|
||||
local tempPath
|
||||
|
||||
is_safe_module "$moduleName" || return 1
|
||||
mkdir -p "${targetPath%/*}" || return 1
|
||||
tempPath="$(mktemp "${targetPath}.stormux.XXXXXX")" || return 1
|
||||
printf '%s\n' "$moduleName" > "$tempPath" || {
|
||||
rm -f "$tempPath"
|
||||
return 1
|
||||
}
|
||||
chmod 644 "$tempPath" || {
|
||||
rm -f "$tempPath"
|
||||
return 1
|
||||
}
|
||||
mv -f "$tempPath" "$targetPath"
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
--apply-module)
|
||||
[[ $# -eq 4 ]] || exit 2
|
||||
apply_module "$2" "$3" "$4"
|
||||
exit $?
|
||||
;;
|
||||
--restore-config)
|
||||
[[ $# -eq 3 ]] || exit 2
|
||||
restore_config "$2" "$3"
|
||||
exit $?
|
||||
;;
|
||||
--write-selection)
|
||||
[[ $# -eq 3 ]] || exit 2
|
||||
write_selection "$2" "$3"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--config)
|
||||
[[ $# -ge 2 ]] || exit 2
|
||||
speechConfig="$2"
|
||||
shift 2
|
||||
;;
|
||||
--selection-file)
|
||||
[[ $# -ge 2 ]] || exit 2
|
||||
selectionFile="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
printf 'Unknown option: %s\n' "$1" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
sudoCommand=(sudo)
|
||||
if [[ -n "${SUDO_ASKPASS:-}" ]]; then
|
||||
sudoCommand+=(-A)
|
||||
fi
|
||||
|
||||
announce_failure() {
|
||||
local previousModule="$1"
|
||||
local message="Speech engine selection failed. Your previous speech engine is still selected."
|
||||
|
||||
"$spdSayCommand" -C >/dev/null 2>&1 || true
|
||||
if is_safe_module "$previousModule"; then
|
||||
"$spdSayCommand" -o "$previousModule" "$message" >/dev/null 2>&1 || \
|
||||
"$spdSayCommand" "$message" >/dev/null 2>&1 || true
|
||||
else
|
||||
"$spdSayCommand" "$message" >/dev/null 2>&1 || true
|
||||
fi
|
||||
printf '%s\n' "$message" >&2
|
||||
}
|
||||
|
||||
set_fenrir_speech() {
|
||||
local enabled="$1"
|
||||
|
||||
printf 'setting set speech#enabled=%s\n' "$enabled" | \
|
||||
"$socatCommand" - UNIX-CLIENT:"$fenrirSocket" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
mute_fenrir_speech() {
|
||||
if "$systemctlCommand" is-active --quiet fenrirscreenreader.service 2>/dev/null && \
|
||||
set_fenrir_speech False; then
|
||||
fenrirSpeechMuted=true
|
||||
fi
|
||||
}
|
||||
|
||||
restore_fenrir_speech() {
|
||||
if [[ "$fenrirSpeechMuted" == true ]]; then
|
||||
set_fenrir_speech True || true
|
||||
fenrirSpeechMuted=false
|
||||
fi
|
||||
}
|
||||
|
||||
trap restore_fenrir_speech EXIT
|
||||
trap 'exit 130' HUP INT TERM
|
||||
|
||||
discover_modules() {
|
||||
local output line candidate
|
||||
local skippedHeading=false
|
||||
|
||||
if ! output="$("$spdSayCommand" -O 2>/dev/null)"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
modules=()
|
||||
while IFS= read -r line; do
|
||||
candidate="${line%$'\r'}"
|
||||
candidate="${candidate#"${candidate%%[![:space:]]*}"}"
|
||||
candidate="${candidate%"${candidate##*[![:space:]]}"}"
|
||||
[[ -n "$candidate" ]] || continue
|
||||
if [[ "$skippedHeading" == false ]]; then
|
||||
skippedHeading=true
|
||||
continue
|
||||
fi
|
||||
is_safe_module "$candidate" || continue
|
||||
modules+=("$candidate")
|
||||
done <<< "$output"
|
||||
|
||||
[[ ${#modules[@]} -gt 0 ]]
|
||||
}
|
||||
|
||||
configured_module() {
|
||||
local configured=""
|
||||
|
||||
if [[ -r "$speechConfig" ]]; then
|
||||
configured="$(awk '$1 == "DefaultModule" { print $2; exit }' "$speechConfig")"
|
||||
fi
|
||||
if ! is_safe_module "$configured"; then
|
||||
configured="rhvoice"
|
||||
fi
|
||||
printf '%s\n' "$configured"
|
||||
}
|
||||
|
||||
module_index() {
|
||||
local wanted="$1"
|
||||
local index
|
||||
|
||||
for index in "${!modules[@]}"; do
|
||||
if [[ "${modules[$index]}" == "$wanted" ]]; then
|
||||
printf '%s\n' "$index"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
draw_menu() {
|
||||
local index
|
||||
|
||||
printf '\033[H\033[2J'
|
||||
printf 'Select the default speech engine. Use Up and Down, Enter to select, or Escape to keep the current engine.\n\n'
|
||||
for index in "${!modules[@]}"; do
|
||||
if [[ $index -eq $selectedIndex ]]; then
|
||||
printf '> %s\n' "${modules[$index]}"
|
||||
else
|
||||
printf ' %s\n' "${modules[$index]}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
read_menu_key() {
|
||||
local first rest=""
|
||||
|
||||
IFS= read -rsn1 first || return 1
|
||||
if [[ -z "$first" ]]; then
|
||||
printf 'enter\n'
|
||||
return 0
|
||||
fi
|
||||
if [[ "$first" == $'\033' ]]; then
|
||||
IFS= read -rsn2 -t 0.1 rest || true
|
||||
case "$rest" in
|
||||
'[A') printf 'up\n' ;;
|
||||
'[B') printf 'down\n' ;;
|
||||
'') printf 'escape\n' ;;
|
||||
*) printf 'other\n' ;;
|
||||
esac
|
||||
return 0
|
||||
fi
|
||||
printf 'other\n'
|
||||
}
|
||||
|
||||
declare -a modules=()
|
||||
previousModule="$(configured_module)"
|
||||
mute_fenrir_speech
|
||||
if ! discover_modules; then
|
||||
announce_failure "$previousModule"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! selectedIndex="$(module_index "$previousModule")"; then
|
||||
if selectedIndex="$(module_index rhvoice)"; then
|
||||
:
|
||||
else
|
||||
selectedIndex=0
|
||||
fi
|
||||
fi
|
||||
|
||||
draw_menu
|
||||
"$spdSayCommand" "Use up and down arrows to select the default voice for this computer. ${modules[$selectedIndex]} is highlighted. Press Enter to select, or Escape to keep the current voice." >/dev/null 2>&1 || true
|
||||
|
||||
while true; do
|
||||
if ! keyName="$(read_menu_key)"; then
|
||||
announce_failure "$previousModule"
|
||||
exit 0
|
||||
fi
|
||||
case "$keyName" in
|
||||
up)
|
||||
selectedIndex=$(( (selectedIndex - 1 + ${#modules[@]}) % ${#modules[@]} ))
|
||||
;;
|
||||
down)
|
||||
selectedIndex=$(( (selectedIndex + 1) % ${#modules[@]} ))
|
||||
;;
|
||||
enter)
|
||||
break
|
||||
;;
|
||||
escape)
|
||||
"$spdSayCommand" -C >/dev/null 2>&1 || true
|
||||
"$spdSayCommand" -o "$previousModule" "Keeping ${previousModule} as the default speech engine." >/dev/null 2>&1 || true
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
draw_menu
|
||||
moduleName="${modules[$selectedIndex]}"
|
||||
"$spdSayCommand" -C >/dev/null 2>&1 || true
|
||||
"$spdSayCommand" -o "$moduleName" "This is ${moduleName}. If selected, I will be your default text-to-speech voice." >/dev/null 2>&1 || true
|
||||
done
|
||||
|
||||
selectedModule="${modules[$selectedIndex]}"
|
||||
backupFile="${runtimeDir}/speechd.conf.$$.backup"
|
||||
"$spdSayCommand" -C >/dev/null 2>&1 || true
|
||||
|
||||
if ! "${sudoCommand[@]}" "$scriptPath" --apply-module "$selectedModule" "$speechConfig" "$backupFile"; then
|
||||
"${sudoCommand[@]}" "$scriptPath" --restore-config "$speechConfig" "$backupFile" >/dev/null 2>&1 || true
|
||||
announce_failure "$previousModule"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ -n "$selectionFile" ]]; then
|
||||
if ! "${sudoCommand[@]}" "$scriptPath" --write-selection "$selectedModule" "$selectionFile"; then
|
||||
"${sudoCommand[@]}" "$scriptPath" --restore-config "$speechConfig" "$backupFile" >/dev/null 2>&1 || true
|
||||
announce_failure "$previousModule"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -f "$backupFile" 2>/dev/null || "${sudoCommand[@]}" rm -f "$backupFile" 2>/dev/null || true
|
||||
|
||||
"$spdSayCommand" -o "$selectedModule" "${selectedModule} is now the default speech engine." >/dev/null 2>&1 || true
|
||||
printf 'Default speech engine set to %s.\n' "$selectedModule"
|
||||
@@ -13,7 +13,7 @@ bluez
|
||||
bluez-utils
|
||||
bolt
|
||||
brltty
|
||||
broadcom-wl
|
||||
broadcom-wl-dkms
|
||||
btrfs-progs
|
||||
clonezilla
|
||||
cloud-init
|
||||
@@ -59,6 +59,7 @@ lftp
|
||||
libfido2
|
||||
libusb-compat
|
||||
linux
|
||||
linux-headers
|
||||
linux-atm
|
||||
linux-firmware
|
||||
linux-firmware-marvell
|
||||
@@ -90,6 +91,7 @@ nvme-cli
|
||||
open-iscsi
|
||||
open-vm-tools
|
||||
openconnect
|
||||
openevv-git
|
||||
openpgp-card-tools
|
||||
openssh
|
||||
openvpn
|
||||
@@ -106,6 +108,7 @@ ppp
|
||||
pptpclient
|
||||
pv
|
||||
python-dbus
|
||||
python-gobject
|
||||
python-pyenchant
|
||||
python-pyte
|
||||
python-pyperclip
|
||||
|
||||
@@ -18,15 +18,14 @@ bootstrap_tarball_compression=('zstd' '-c' '-T0' '--auto-threads=logical' '--lon
|
||||
file_permissions=(
|
||||
["/etc/shadow"]="0:0:400"
|
||||
["/root"]="0:0:750"
|
||||
["/root/.automated_script.sh"]="0:0:755"
|
||||
["/root/customize_airootfs.sh"]="0:0:755"
|
||||
["/root/.gnupg"]="0:0:700"
|
||||
["/root/.config"]="0:0:700"
|
||||
["/usr/local/bin/choose-mirror"]="0:0:755"
|
||||
["/usr/local/bin/Installation_guide"]="0:0:755"
|
||||
["/usr/local/bin/livecd-sound"]="0:0:755"
|
||||
["/usr/local/bin/configure-stormux"]="0:0:755"
|
||||
["/usr/local/bin/install-stormux"]="0:0:755"
|
||||
["/usr/local/lib/stormux/select-speech-module"]="0:0:755"
|
||||
["/usr/local/lib/stormux/copy-live-network"]="0:0:755"
|
||||
["/usr/local/bin/stormux-setup.sh"]="0:0:755"
|
||||
["/usr/local/bin/init-pipewire-sound.sh"]="0:0:755"
|
||||
["/usr/share/fenrirscreenreader/scripts/ssh-login-monitor.sh"]="0:0:755"
|
||||
|
||||
Reference in new issue
Block a user