diff --git a/main.py b/main.py index 1331aaf..9884b0e 100644 --- a/main.py +++ b/main.py @@ -159,10 +159,27 @@ def main(): log_level, ) - if not snapcast_settings.should_ignore_popup() or os.path.exists(snapcast_settings.read_setting("Snapclient/Custom_Path")) is False: - dialog = PathInputDialog("snapclient", log_level) - if dialog.exec() == QDialog.Accepted: - snapcast_settings.set_ignore_popup(dialog.ignore_popup_checkbox.isChecked()) + def is_executable(file_path): + return os.path.isfile(file_path) and os.access(file_path, os.X_OK) + + snapclient_path = snapcast_settings.read_setting("Snapclient/Custom_Path") + snapserver_path = snapcast_settings.read_setting("Snapserver/Custom_Path") + + if not snapcast_settings.read_setting("Snapclient/Ignore_Popup"): + if not is_executable(snapclient_path): + dialog = PathInputDialog("snapclient", log_level) + if dialog.exec() == QDialog.Accepted: + snapcast_settings.set_ignore_popup(dialog.ignore_popup_checkbox.isChecked()) + new_path = dialog.get_path() + snapcast_settings.write_setting("Snapclient/Custom_Path", new_path) + + if not snapcast_settings.read_setting("Snapserver/Ignore_Popup"): + if not is_executable(snapserver_path): + dialog = PathInputDialog("snapserver", log_level) + if dialog.exec() == QDialog.Accepted: + snapcast_settings.set_ignore_popup(dialog.ignore_popup_checkbox.isChecked()) + new_path = dialog.get_path() + snapcast_settings.write_setting("Snapserver/Custom_Path", new_path) combined_window.show() sys.exit(app.exec()) diff --git a/snapcast_gui/fileactions/snapcast_settings.py b/snapcast_gui/fileactions/snapcast_settings.py index d58154c..c3292d9 100644 --- a/snapcast_gui/fileactions/snapcast_settings.py +++ b/snapcast_gui/fileactions/snapcast_settings.py @@ -38,6 +38,7 @@ def ensure_settings(self) -> None: "Snapserver/autostart": False, "Snapserver/Config_Before_Start": "", "Snapserver/Config_After_Start": "", + "Snapserver/Ignore_Popup": True, "Shortcuts/Open_Settings": "Ctrl+O", "Shortcuts/Connect_Disconnect": "Ctrl+C", "Shortcuts/Toggle_Snapclient": "Ctrl+E", @@ -174,21 +175,3 @@ def remove_ip(self, ip: str) -> None: self.logger.debug( "IP Address {} removed from config file.".format(ip) ) - - def should_ignore_popup(self) -> bool: - """ - Reads the setting for ignoring the popup and returns its value. - - Returns: - bool: True if the popup should be ignored, False otherwise. - """ - return self.read_setting("Snapclient/Ignore_Popup") - - def set_ignore_popup(self, value: bool) -> None: - """ - Updates the setting for ignoring the popup. - - Args: - value (bool): The new value for the setting. - """ - self.update_setting("Snapclient/Ignore_Popup", str(value))