Updated help system to search Documents for all .md files making it much easier to add new help files. Added optional install system for software not shipped by default with the image. Added security documentation for people who decide to use the Stormux Gaming Image as their daily driver.
This commit is contained in:
@@ -416,6 +416,63 @@ class VoicedMenu:
|
||||
self.add_item("System", f"Enable {friendlyName}",
|
||||
lambda fn=friendlyName: self.toggle_service(fn))
|
||||
|
||||
def install_and_launch(self, package_name, executable_name, launch_mode="gui"):
|
||||
"""Install package if needed and launch it"""
|
||||
try:
|
||||
# Check if executable exists
|
||||
check_cmd = f"command -v {executable_name}"
|
||||
result = subprocess.run(check_cmd, shell=True, capture_output=True)
|
||||
|
||||
if result.returncode != 0:
|
||||
# Package not installed, inform user and install
|
||||
self.speak(f"Installing {executable_name}. This may take a few minutes.", interrupt=False)
|
||||
|
||||
# Install using yay
|
||||
install_cmd = f"yay -Sy --noconfirm {package_name}"
|
||||
install_result = subprocess.run(install_cmd, shell=True, capture_output=True, text=True)
|
||||
|
||||
if install_result.returncode != 0:
|
||||
error_msg = f"Could not install {package_name}. {install_result.stderr}"
|
||||
self.speak(error_msg, interrupt=False)
|
||||
return
|
||||
|
||||
self.speak(f"{executable_name} installed successfully. Launching now.", interrupt=False)
|
||||
|
||||
# Launch the application
|
||||
if launch_mode == "gui":
|
||||
command = f"GAME='{executable_name}' startx"
|
||||
else: # cli mode
|
||||
command = f"GAME='{executable_name}' /home/stormux/.clirc"
|
||||
|
||||
# Use the existing execute_current_item infrastructure by temporarily setting command
|
||||
# Save current state
|
||||
original_sections = self.sectionNames.copy()
|
||||
original_current_section = self.currentSection
|
||||
original_items = {}
|
||||
for section in self.menuSections:
|
||||
original_items[section] = self.menuSections[section].copy()
|
||||
|
||||
# Create temporary item to execute
|
||||
temp_section = "temp_install_launch"
|
||||
self.add_section(temp_section)
|
||||
self.add_item(temp_section, f"Launch {executable_name}", command)
|
||||
|
||||
# Set to the temporary section and item
|
||||
self.currentSection = len(self.sectionNames) - 1
|
||||
self.currentItemIndices[temp_section] = 0
|
||||
|
||||
# Execute the command using existing infrastructure
|
||||
self.execute_current_item()
|
||||
|
||||
# Restore original state
|
||||
self.sectionNames = original_sections
|
||||
self.currentSection = original_current_section
|
||||
self.menuSections = original_items
|
||||
|
||||
except Exception as e:
|
||||
error_msg = f"Error installing or launching {executable_name}: {e}"
|
||||
self.speak(error_msg, interrupt=False)
|
||||
|
||||
def update_bluetooth_menu_items(self):
|
||||
"""Update Bluetooth-related menu items in Accessories section"""
|
||||
if "Accessories" in self.menuSections:
|
||||
@@ -428,6 +485,36 @@ class VoicedMenu:
|
||||
self.add_item("Accessories", "Manage Bluetooth Devices",
|
||||
"GAME=blueman-manager startx")
|
||||
|
||||
def scan_documentation_files(self):
|
||||
"""Scan Documents directory for .md files and add them to help menu"""
|
||||
docs_dir = os.path.expanduser("~/Documents")
|
||||
|
||||
if not os.path.exists(docs_dir):
|
||||
return
|
||||
|
||||
try:
|
||||
# Get all .md files in Documents directory
|
||||
md_files = []
|
||||
for file in os.listdir(docs_dir):
|
||||
if file.endswith('.md'):
|
||||
file_path = os.path.join(docs_dir, file)
|
||||
if os.path.isfile(file_path):
|
||||
# Create a friendly display name from filename
|
||||
# Remove .md extension and replace underscores with spaces
|
||||
display_name = file[:-3].replace('_', ' ').title()
|
||||
md_files.append((display_name, file))
|
||||
|
||||
# Sort files alphabetically by display name
|
||||
md_files.sort(key=lambda x: x[0])
|
||||
|
||||
# Add each markdown file to the help section
|
||||
for display_name, filename in md_files:
|
||||
file_path = f"~/Documents/{filename}"
|
||||
self.add_item("Help and Documentation", display_name, f"GAME={file_path} /home/stormux/.clirc")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error scanning documentation files: {e}")
|
||||
|
||||
def add_section(self, sectionName):
|
||||
"""Add a new section to the menu"""
|
||||
if sectionName not in self.menuSections:
|
||||
@@ -998,15 +1085,9 @@ if __name__ == "__main__":
|
||||
|
||||
# Add help and documentation section
|
||||
menu.add_section("Help and Documentation")
|
||||
menu.add_item("Help and Documentation", "Navigating Help Documentation", "GAME=~/Documents/navigating_help.md /home/stormux/.clirc")
|
||||
menu.add_item("Help and Documentation", "Menu Controls", "GAME=~/Documents/game_menu_controls.md /home/stormux/.clirc")
|
||||
menu.add_item("Help and Documentation", "Game Notes", "GAME=~/Documents/game_notes.md /home/stormux/.clirc")
|
||||
menu.add_item("Help and Documentation", "Music Player", "GAME=~/Documents/music_player.md /home/stormux/.clirc")
|
||||
menu.add_item("Help and Documentation", "Terminal for Advanced Users", "GAME=~/Documents/terminal.md /home/stormux/.clirc")
|
||||
menu.add_item("Help and Documentation", "D L N A Server", "GAME=~/Documents/dlna.md /home/stormux/.clirc")
|
||||
menu.add_item("Help and Documentation", "Changing the Voice", "GAME=~/Documents/voices.md /home/stormux/.clirc")
|
||||
menu.add_item("Help and Documentation", "Change Log", "GAME=~/Documents/change_log.md /home/stormux/.clirc")
|
||||
menu.add_item("Help and Documentation", "Contacting Stormux", "GAME=~/Documents/contact.md /home/stormux/.clirc")
|
||||
# Dynamically scan and add all .md files from Documents directory
|
||||
menu.scan_documentation_files()
|
||||
# Add the IRC help item
|
||||
menu.add_item("Help and Documentation", "Get help on IRC", "GAME=IRC /home/stormux/.clirc")
|
||||
|
||||
# Add accessories section
|
||||
@@ -1015,6 +1096,8 @@ if __name__ == "__main__":
|
||||
menu.add_item("Accessories", "Local IP Address", "/usr/local/bin/ip_info.py local")
|
||||
menu.add_item("Accessories", "Remote IP Address", "/usr/local/bin/ip_info.py remote")
|
||||
menu.add_item("Accessories", "Web Browser", "GAME=Brave startx")
|
||||
menu.add_item("Accessories", "LibreOffice", lambda: menu.install_and_launch("libreoffice-still", "libreoffice", "gui"))
|
||||
menu.add_item("Accessories", "Thunderbird", lambda: menu.install_and_launch("thunderbird", "thunderbird", "gui"))
|
||||
|
||||
# Add system section
|
||||
menu.add_section("System")
|
||||
|
||||
Reference in New Issue
Block a user