Bug fix for install and launch applications.
This commit is contained in:
@@ -416,29 +416,10 @@ 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"""
|
||||
def install_and_launch(self, executable_name, launch_mode="gui"):
|
||||
"""Launch application via xinitrc (which handles installation if needed)"""
|
||||
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
|
||||
# Launch the application - xinitrc will handle installation
|
||||
if launch_mode == "gui":
|
||||
command = f"GAME='{executable_name}' startx"
|
||||
else: # cli mode
|
||||
@@ -470,7 +451,7 @@ class VoicedMenu:
|
||||
self.menuSections = original_items
|
||||
|
||||
except Exception as e:
|
||||
error_msg = f"Error installing or launching {executable_name}: {e}"
|
||||
error_msg = f"Error launching {executable_name}: {e}"
|
||||
self.speak(error_msg, interrupt=False)
|
||||
|
||||
def update_bluetooth_menu_items(self):
|
||||
@@ -1096,8 +1077,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"))
|
||||
menu.add_item("Accessories", "LibreOffice", lambda: menu.install_and_launch("libreoffice", "gui"))
|
||||
menu.add_item("Accessories", "Thunderbird", lambda: menu.install_and_launch("thunderbird", "gui"))
|
||||
|
||||
# Add system section
|
||||
menu.add_section("System")
|
||||
|
||||
Reference in New Issue
Block a user