Added the ability for the configuration selection to loop, so you can do multiple configurations in without having to rerun the script.
This commit is contained in:
parent
bcf17ff021
commit
f45a77c7e1
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Fenrir TTY screen reader
|
# Fenrir TTY screen reader
|
||||||
# By Chrys, Storm Dragon, and contributers.
|
# By Chrys, Storm Dragon, and contributers.
|
||||||
@ -13,7 +12,6 @@ os.environ['DIALOGOPTS'] = '--no-lines --visit-items'
|
|||||||
# Initialize the dialog
|
# Initialize the dialog
|
||||||
tui = dialog.Dialog(dialog="dialog")
|
tui = dialog.Dialog(dialog="dialog")
|
||||||
|
|
||||||
|
|
||||||
# Define the path to the settings file
|
# Define the path to the settings file
|
||||||
settings_file = '/etc/fenrirscreenreader/settings/settings.conf'
|
settings_file = '/etc/fenrirscreenreader/settings/settings.conf'
|
||||||
|
|
||||||
@ -22,23 +20,31 @@ 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.")
|
tui.msgbox("Error: Insufficient permissions to modify the settings file. Please run as root or with sudo.")
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
# Load the settings file
|
while True:
|
||||||
config = configparser.ConfigParser()
|
# Load the settings file
|
||||||
config.read(settings_file)
|
config = configparser.ConfigParser()
|
||||||
|
config.read(settings_file)
|
||||||
|
|
||||||
# Get a list of sections in the settings file
|
# Get a list of sections in the settings file
|
||||||
sections = config.sections()
|
sections = config.sections()
|
||||||
|
|
||||||
# Select a section.
|
# Select a section.
|
||||||
code, section = tui.menu("Select a section:", choices=[(s, "") for s in sections])
|
code, section = tui.menu("Select a section:", choices=[(s, "") for s in sections] + [("Exit", " ")])
|
||||||
|
|
||||||
# If a section is selected, modify its values
|
# Exit if the "Exit" option is chosen
|
||||||
if code == tui.OK:
|
if section == "Exit":
|
||||||
|
break
|
||||||
|
|
||||||
|
while True:
|
||||||
# Get the options in the selected section
|
# Get the options in the selected section
|
||||||
options = config.options(section)
|
options = config.options(section)
|
||||||
|
|
||||||
# Select a value to edit using dialog
|
# 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])
|
code, option = tui.menu(f"Select a value to edit in '{section}':", choices=[(o, "") for o in options] + [("Go Back", " ")])
|
||||||
|
|
||||||
|
# Go back to the section menu if the "Go Back" option is chosen
|
||||||
|
if option == "Go Back":
|
||||||
|
break
|
||||||
|
|
||||||
# If something is selected, prompt for a new value.
|
# If something is selected, prompt for a new value.
|
||||||
if code == tui.OK:
|
if code == tui.OK:
|
||||||
@ -58,5 +64,3 @@ if code == tui.OK:
|
|||||||
tui.msgbox("Changes discarded. Your Fenrir configuration has not been modified.")
|
tui.msgbox("Changes discarded. Your Fenrir configuration has not been modified.")
|
||||||
else:
|
else:
|
||||||
tui.msgbox("Canceled.")
|
tui.msgbox("Canceled.")
|
||||||
else:
|
|
||||||
tui.msgbox("Canceled.")
|
|
||||||
|
Loading…
Reference in New Issue
Block a user