got a decent start on a Fenrir configuration utility.
This commit is contained in:
parent
63124f4f68
commit
bcf17ff021
248
tools/fenrir-conf
Normal file → Executable file
248
tools/fenrir-conf
Normal file → Executable file
@ -1,216 +1,62 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Get user input args are return variable, question, options
|
# Fenrir TTY screen reader
|
||||||
get_input()
|
# By Chrys, Storm Dragon, and contributers.
|
||||||
{
|
|
||||||
# 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"
|
|
||||||
|
|
||||||
if [ "$(whoami)" != "root" ]; then
|
import os
|
||||||
echo "Please run $0 as root."
|
import configparser
|
||||||
exit 1
|
import dialog
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f "$configFile" ]; then
|
# Make sure dialog is accessible
|
||||||
read -p "This will replace your current settings, press enter to continue or control+C to abort." continue
|
os.environ['DIALOGOPTS'] = '--no-lines --visit-items'
|
||||||
fi
|
# Initialize the dialog
|
||||||
|
tui = dialog.Dialog(dialog="dialog")
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
# The rate selects how fast Fenrir will speak. Options range from 0, slowest, to 1.0, fastest.
|
# Define the path to the settings file
|
||||||
rate=0.45
|
settings_file = '/etc/fenrirscreenreader/settings/settings.conf'
|
||||||
|
|
||||||
# Pitch controls the pitch of the voice, select from 0, lowest, to 1.0, highest.
|
# Check write permissions for the settings file
|
||||||
pitch=0.5
|
if not os.access(settings_file, os.W_OK):
|
||||||
# Pitch for capital letters
|
tui.msgbox("Error: Insufficient permissions to modify the settings file. Please run as root or with sudo.")
|
||||||
capitalPitch=0.9
|
exit()
|
||||||
|
|
||||||
# Volume controls the loudness of the voice, select from 0, quietest, to 1.0, loudest.
|
# Load the settings file
|
||||||
volume=1.0
|
config = configparser.ConfigParser()
|
||||||
|
config.read(settings_file)
|
||||||
|
|
||||||
# Module is used for Speech-dispatcher, to select the speech module you want to use.
|
# Get a list of sections in the settings file
|
||||||
# Consult Speech-dispatcher's configuration and help to find out which modules are available.
|
sections = config.sections()
|
||||||
# The default is Espeak.
|
|
||||||
module=espeak
|
|
||||||
|
|
||||||
# Voice selects the varient you want to use, for example, f5 will use the female voice #5 in espeak,
|
# Select a section.
|
||||||
# or if using the espeak module in Speech-dispatcher. To find out which voices are available, consult the documentation provided with your selected synthesizer.
|
code, section = tui.menu("Select a section:", choices=[(s, "") for s in sections])
|
||||||
voice=
|
|
||||||
|
|
||||||
# Select the language you want Fenrir to use.
|
# If a section is selected, modify its values
|
||||||
language=english-us
|
if code == tui.OK:
|
||||||
|
# Get the options in the selected section
|
||||||
|
options = config.options(section)
|
||||||
|
|
||||||
# Read new text as it happens?
|
# Select a value to edit using dialog
|
||||||
autoReadIncoming=True
|
code, option = tui.menu(f"Select a value to edit in '{section}':", choices=[(o, "") for o in options])
|
||||||
|
|
||||||
[braille]
|
# If something is selected, prompt for a new value.
|
||||||
#Braille is not implemented yet
|
if code == tui.OK:
|
||||||
enabled=False
|
value = config.get(section, option)
|
||||||
driver=brlapi
|
code, new_value = tui.inputbox(f"Enter a new value for '{option}':", init=value)
|
||||||
layout=en
|
|
||||||
|
|
||||||
[screen]
|
# If a new setting is provided, update the configuration
|
||||||
driver=vcsa
|
if code == tui.OK:
|
||||||
encoding=auto
|
config.set(section, option, new_value)
|
||||||
autodetectSuspendingScreen=True
|
|
||||||
|
|
||||||
[keyboard]
|
# Save changes.
|
||||||
driver=evdev
|
with open(settings_file, 'w') as configfile:
|
||||||
# filter input devices NOMICE, ALL or a DEVICE NAME
|
config.write(configfile)
|
||||||
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
|
|
||||||
|
|
||||||
[general]
|
tui.msgbox("Fenrir settings saved.")
|
||||||
debugLevel=0
|
else:
|
||||||
# debugMode sets where the debug output should send to:
|
tui.msgbox("Changes discarded. Your Fenrir configuration has not been modified.")
|
||||||
# debugMode=File writes to /var/log/fenrir.log
|
else:
|
||||||
# debugMode=Print just prints on the screen
|
tui.msgbox("Canceled.")
|
||||||
debugMode=File
|
else:
|
||||||
punctuationProfile=default
|
tui.msgbox("Canceled.")
|
||||||
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
|
|
||||||
|
Loading…
Reference in New Issue
Block a user