got a decent start on a Fenrir configuration utility.
This commit is contained in:
parent
63124f4f68
commit
bcf17ff021
250
tools/fenrir-conf
Normal file → Executable file
250
tools/fenrir-conf
Normal file → Executable file
@ -1,216 +1,62 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
# Get user input args are return variable, question, options
|
||||
get_input()
|
||||
{
|
||||
# Variable names are long, because we want absolutely no name conflicts.
|
||||
local __get_input_input=$1
|
||||
shift
|
||||
local __get_input_question="$1"
|
||||
shift
|
||||
local __get_input_answer=""
|
||||
local __get_input_i=""
|
||||
local __get_input_continue=false
|
||||
for __get_input_i in $@; do
|
||||
if [ "${__get_input_i:0:1}" = "-" ]; then
|
||||
local __get_input_default="${__get_input_i:1}"
|
||||
fi
|
||||
done
|
||||
while [ $__get_input_continue = false ]; do
|
||||
echo -n "$__get_input_question (${@/#-/}) "
|
||||
if [ -n "$__get_input_default" ]; then
|
||||
read -e -i "$__get_input_default" __get_input_answer
|
||||
else
|
||||
read -e __get_input_answer
|
||||
fi
|
||||
for __get_input_i in $@; do
|
||||
if [ "$__get_input_answer" = "${__get_input_i/#-/}" ]; then
|
||||
__get_input_continue=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
done
|
||||
__get_input_answer="${__get_input_answer//no/False}"
|
||||
__get_input_answer="${__get_input_answer//yes/True}"
|
||||
eval $__get_input_input="'$__get_input_answer'"
|
||||
}
|
||||
configFile="/etc/fenrirscreenreader/settings/settings.conf"
|
||||
import os
|
||||
import configparser
|
||||
import dialog
|
||||
|
||||
if [ "$(whoami)" != "root" ]; then
|
||||
echo "Please run $0 as root."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f "$configFile" ]; then
|
||||
read -p "This will replace your current settings, press enter to continue or control+C to abort." continue
|
||||
fi
|
||||
|
||||
get_input sound "Enable sound?" -yes no
|
||||
if [ "$sound" = "true" ]; then
|
||||
get_input soundDriver "Select sound driver:" -generic gstreamer
|
||||
else
|
||||
soundDriver="generic"
|
||||
fi
|
||||
get_input speech "Enable speech?" -yes no
|
||||
if [ "$speech" = "true" ]; then
|
||||
get_input speechDriver "Select speech driver:" espeak -speechd
|
||||
else
|
||||
speechDriver="speechd"
|
||||
fi
|
||||
get_input charEcho "enable character echo?" -yes no
|
||||
get_input wordEcho "enable word echo?" yes -no
|
||||
|
||||
cat << EOF > "$configFile"
|
||||
[sound]
|
||||
# Turn sound on or off:
|
||||
enabled=$sound
|
||||
|
||||
# Select the driver used to play sounds, choices are generic and gstreamer.
|
||||
# Sox is the default.
|
||||
driver=$soundDriver
|
||||
|
||||
# Sound themes. These are the pack of sounds used for sound alerts.
|
||||
# Sound packs may be located at /usr/share/sounds
|
||||
# For system wide availability, or ~/.local/share/fenrir/sounds
|
||||
# For the current user.
|
||||
theme=default
|
||||
|
||||
# Sound volume controls how loud the sounds for your chosen soundpack are.
|
||||
# 0 is quietest, 1.0 is loudest.
|
||||
volume=1.0
|
||||
|
||||
# shell commands for generic sound driver
|
||||
# the folowing variables are substituted
|
||||
# fenrirVolume = the current volume setting
|
||||
# fenrirSoundFile = the soundfile for an soundicon
|
||||
# fenrirFrequence = the frequence to play
|
||||
# fenrirDuration = the duration of the frequency
|
||||
# the following command is used for play a soundfile
|
||||
genericPlayFileCommand=play -q -v fenrirVolume fenrirSoundFile
|
||||
#the following command is used for generating a frequency beep
|
||||
genericFrequencyCommand=play -q -v fenrirVolume -n -c1 synth fenrirDuration sine fenrirFrequence
|
||||
|
||||
[speech]
|
||||
# Turn speech on or off:
|
||||
enabled=$speech
|
||||
|
||||
# Select speech driver, options are speechd (default) or espeak:
|
||||
driver=$speechDriver
|
||||
# Make sure dialog is accessible
|
||||
os.environ['DIALOGOPTS'] = '--no-lines --visit-items'
|
||||
# Initialize the dialog
|
||||
tui = dialog.Dialog(dialog="dialog")
|
||||
|
||||
|
||||
# The rate selects how fast Fenrir will speak. Options range from 0, slowest, to 1.0, fastest.
|
||||
rate=0.45
|
||||
# Define the path to the settings file
|
||||
settings_file = '/etc/fenrirscreenreader/settings/settings.conf'
|
||||
|
||||
# Pitch controls the pitch of the voice, select from 0, lowest, to 1.0, highest.
|
||||
pitch=0.5
|
||||
# Pitch for capital letters
|
||||
capitalPitch=0.9
|
||||
# Check write permissions for the settings file
|
||||
if not os.access(settings_file, os.W_OK):
|
||||
tui.msgbox("Error: Insufficient permissions to modify the settings file. Please run as root or with sudo.")
|
||||
exit()
|
||||
|
||||
# Volume controls the loudness of the voice, select from 0, quietest, to 1.0, loudest.
|
||||
volume=1.0
|
||||
# Load the settings file
|
||||
config = configparser.ConfigParser()
|
||||
config.read(settings_file)
|
||||
|
||||
# Module is used for Speech-dispatcher, to select the speech module you want to use.
|
||||
# Consult Speech-dispatcher's configuration and help to find out which modules are available.
|
||||
# The default is Espeak.
|
||||
module=espeak
|
||||
# Get a list of sections in the settings file
|
||||
sections = config.sections()
|
||||
|
||||
# Voice selects the varient you want to use, for example, f5 will use the female voice #5 in espeak,
|
||||
# or if using the espeak module in Speech-dispatcher. To find out which voices are available, consult the documentation provided with your selected synthesizer.
|
||||
voice=
|
||||
# Select a section.
|
||||
code, section = tui.menu("Select a section:", choices=[(s, "") for s in sections])
|
||||
|
||||
# Select the language you want Fenrir to use.
|
||||
language=english-us
|
||||
# If a section is selected, modify its values
|
||||
if code == tui.OK:
|
||||
# Get the options in the selected section
|
||||
options = config.options(section)
|
||||
|
||||
# Read new text as it happens?
|
||||
autoReadIncoming=True
|
||||
# Select a value to edit using dialog
|
||||
code, option = tui.menu(f"Select a value to edit in '{section}':", choices=[(o, "") for o in options])
|
||||
|
||||
[braille]
|
||||
#Braille is not implemented yet
|
||||
enabled=False
|
||||
driver=brlapi
|
||||
layout=en
|
||||
# If something is selected, prompt for a new value.
|
||||
if code == tui.OK:
|
||||
value = config.get(section, option)
|
||||
code, new_value = tui.inputbox(f"Enter a new value for '{option}':", init=value)
|
||||
|
||||
[screen]
|
||||
driver=vcsa
|
||||
encoding=auto
|
||||
autodetectSuspendingScreen=True
|
||||
# If a new setting is provided, update the configuration
|
||||
if code == tui.OK:
|
||||
config.set(section, option, new_value)
|
||||
|
||||
[keyboard]
|
||||
driver=evdev
|
||||
# filter input devices NOMICE, ALL or a DEVICE NAME
|
||||
device=ALL
|
||||
# gives Fenrir exclusive access to the keyboard and lets it absorb keystrokes.
|
||||
grabDevices=True
|
||||
ignoreShortcuts=False
|
||||
# the current shortcut layout located in /etc/fenrir/keyboard
|
||||
keyboardLayout=$keyboard
|
||||
# echo chars while typing.
|
||||
charEcho=$charEcho
|
||||
# echo deleted chars
|
||||
charDeleteEcho=True
|
||||
# echo word after pressing space
|
||||
wordEcho=$wordEcho
|
||||
# interrupt speech on any keypress
|
||||
interruptOnKeyPress=$enterupt
|
||||
# you can filter the keys that the speech should interrupt (empty = all keys, otherwise the given keys)
|
||||
interruptOnKeyPressFilter=
|
||||
# timeout for double tap in sec
|
||||
doubleTapTimeout=0.2
|
||||
# Save changes.
|
||||
with open(settings_file, 'w') as configfile:
|
||||
config.write(configfile)
|
||||
|
||||
[general]
|
||||
debugLevel=0
|
||||
# debugMode sets where the debug output should send to:
|
||||
# debugMode=File writes to /var/log/fenrir.log
|
||||
# debugMode=Print just prints on the screen
|
||||
debugMode=File
|
||||
punctuationProfile=default
|
||||
punctuationLevel=some
|
||||
respectPunctuationPause=True
|
||||
newLinePause=True
|
||||
numberOfClipboards=10
|
||||
emoticons=True
|
||||
# define the current Fenrir key
|
||||
fenrirKeys=KEY_KP0,KEY_META,KEY_INSERT
|
||||
scriptKey=KEY_COMPOSE
|
||||
timeFormat=%H:%M:%P
|
||||
dateFormat=%A, %B %d, %Y
|
||||
autoSpellCheck=True
|
||||
spellCheckLanguage=en_US
|
||||
scriptPath=/usr/share/fenrirscreenreader/scripts
|
||||
|
||||
[focus]
|
||||
#follow the text cursor
|
||||
cursor=True
|
||||
#follow highlighted text changes
|
||||
highlight=False
|
||||
|
||||
[review]
|
||||
lineBreak=True
|
||||
endOfScreen=True
|
||||
|
||||
[promote]
|
||||
enabled=True
|
||||
inactiveTimeoutSec=120
|
||||
list=
|
||||
|
||||
[time]
|
||||
# automatic time anouncement
|
||||
enabled=False
|
||||
# present time
|
||||
presentTime=True
|
||||
# present date (on change)
|
||||
presentDate=True
|
||||
# present time after a given period of seconds
|
||||
delaySec=0
|
||||
# present time after to given minutes example every 15 minutes: 00,15,30,45
|
||||
# if delaySec is >0 onMinutes is ignored
|
||||
onMinutes=00,30
|
||||
# announce via soundicon (not interrupting)
|
||||
announce=True
|
||||
# interrupt current speech for time announcement
|
||||
interrupt=False
|
||||
EOF
|
||||
|
||||
echo "Settings saved to $configFile."
|
||||
|
||||
exit 0
|
||||
tui.msgbox("Fenrir settings saved.")
|
||||
else:
|
||||
tui.msgbox("Changes discarded. Your Fenrir configuration has not been modified.")
|
||||
else:
|
||||
tui.msgbox("Canceled.")
|
||||
else:
|
||||
tui.msgbox("Canceled.")
|
||||
|
Loading…
Reference in New Issue
Block a user