From be0fc25e72203310f268221a132c5d765874b02c Mon Sep 17 00:00:00 2001 From: Almamu Date: Sat, 17 May 2025 03:23:05 +0200 Subject: [PATCH] chore: better error reporting for parameters, highlighting --help usage. fixess #303 and should improve #275 --- .../background-doesn-t-load-properly.md | 31 -------- .github/ISSUE_TEMPLATE/bug-report.yml | 58 ++++++++++++++ .../ISSUE_TEMPLATE/compatibility-issue.yml | 46 +++++++++++ .github/ISSUE_TEMPLATE/feature-request.yml | 32 ++++++++ .github/ISSUE_TEMPLATE/installation-help.yml | 38 +++++++++ .github/ISSUE_TEMPLATE/other-issues.md | 10 --- .github/ISSUE_TEMPLATE/refactor.yml | 22 ++++++ .../Application/CApplicationContext.cpp | 60 +++++++------- src/main.cpp | 79 ++++++++++--------- 9 files changed, 270 insertions(+), 106 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/background-doesn-t-load-properly.md create mode 100644 .github/ISSUE_TEMPLATE/bug-report.yml create mode 100644 .github/ISSUE_TEMPLATE/compatibility-issue.yml create mode 100644 .github/ISSUE_TEMPLATE/feature-request.yml create mode 100644 .github/ISSUE_TEMPLATE/installation-help.yml delete mode 100644 .github/ISSUE_TEMPLATE/other-issues.md create mode 100644 .github/ISSUE_TEMPLATE/refactor.yml diff --git a/.github/ISSUE_TEMPLATE/background-doesn-t-load-properly.md b/.github/ISSUE_TEMPLATE/background-doesn-t-load-properly.md deleted file mode 100644 index a495e85..0000000 --- a/.github/ISSUE_TEMPLATE/background-doesn-t-load-properly.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -name: Background doesn't load properly -about: Use this to report backgrounds that are not loading (cannot find files, black - image, effects not working, etc) -title: "[BGFIX]" -labels: bug -assignees: Almamu - ---- - -**Wallpaper Engine Background(s)** - -Link(s) to the background(s) in the steam workshop or their background ID(s). - -**Console output** - -When a background cannot be loaded, it's usually due to some unexpected error that is logged into the terminal. Please attach the program's output so we can properly debug it if needed. - -**Screenshots** - -If you have any screenshot of it working on Windows that'll help so we can compare both outputs - -**Desktop (please complete the following information):** - -- OS: [e.g. Arch Linux] - - Desktop Environment: [e.g. GNOME, CINNAMON, KDE...] - - Window Manager: [if in doubt, just leave it empty] - -**Additional context** - -Any additional information about your setup diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml new file mode 100644 index 0000000..539bb2c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -0,0 +1,58 @@ +name: "Bug Report" +description: "Report a bug or unexpected behavior." +labels: [bug] +body: + - type: markdown + attributes: + value: | + Please fill out this form to report a bug. + - type: input + id: summary + attributes: + label: Bug Summary + description: Briefly describe the bug. + validations: + required: true + - type: textarea + id: steps + attributes: + label: Steps to Reproduce + description: Step-by-step instructions to reproduce the bug. + validations: + required: true + - type: textarea + id: expected + attributes: + label: Expected Behavior + validations: + required: false + - type: textarea + id: actual + attributes: + label: Actual Behavior / Logs + validations: + required: false + - type: input + id: os + attributes: + label: Operating System and Version + validations: + required: true + - type: input + id: de + attributes: + label: Desktop Environment (GNOME, KDE, etc.) + validations: + required: true + - type: input + id: x11_wayland + attributes: + label: Display Server (X11/Wayland) + validations: + required: true + - type: textarea + id: extra + attributes: + label: Additional Context or Screenshots + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/compatibility-issue.yml b/.github/ISSUE_TEMPLATE/compatibility-issue.yml new file mode 100644 index 0000000..93b7e88 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/compatibility-issue.yml @@ -0,0 +1,46 @@ +name: "Wallpaper Compatibility Issue" +description: "Report a problem with a specific Wallpaper Engine wallpaper." +labels: [compatibility, wallpaper] +body: + - type: input + id: wallpaper + attributes: + label: Wallpaper Name, URL or ID + validations: + required: true + - type: textarea + id: issue + attributes: + label: Describe the Issue + validations: + required: true + - type: textarea + id: expected + attributes: + label: Expected Behavior + validations: + required: false + - type: textarea + id: logs + attributes: + label: Logs or Crash Output + validations: + required: false + - type: input + id: os + attributes: + label: Operating System and Version + validations: + required: true + - type: input + id: de + attributes: + label: Desktop Environment (GNOME, KDE, etc.) + validations: + required: true + - type: input + id: x11_wayland + attributes: + label: Display Server (X11/Wayland) + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml new file mode 100644 index 0000000..df19832 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -0,0 +1,32 @@ +name: "Feature Request" +description: "Propose a new feature or enhancement." +labels: [enhancement] +body: + - type: markdown + attributes: + value: | + Use this form to suggest new features or improvements. + - type: textarea + id: feature + attributes: + label: Describe the Feature + validations: + required: true + - type: textarea + id: problem + attributes: + label: Problem this Feature Addresses (if any) + validations: + required: false + - type: textarea + id: alternatives + attributes: + label: Alternatives Considered + validations: + required: false + - type: textarea + id: context + attributes: + label: Additional Context or Mockups + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/installation-help.yml b/.github/ISSUE_TEMPLATE/installation-help.yml new file mode 100644 index 0000000..f7e40d6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/installation-help.yml @@ -0,0 +1,38 @@ +name: "Installation/Usage Help" +description: "Request help with installing or using linux-wallpaperengine." +labels: [question, support] +body: + - type: markdown + attributes: + value: | + Need help? Fill this out so we can assist you better. + - type: textarea + id: issue + attributes: + label: What are you trying to do, and what's the problem? + validations: + required: true + - type: textarea + id: attempted + attributes: + label: What have you tried so far? + validations: + required: false + - type: textarea + id: error_logs + attributes: + label: Errors or Log Output + validations: + required: false + - type: input + id: system + attributes: + label: OS, Desktop Environment, X11/Wayland + validations: + required: true + - type: input + id: install_method + attributes: + label: Installation Method (e.g., AUR, Flatpak, build from source) + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/other-issues.md b/.github/ISSUE_TEMPLATE/other-issues.md deleted file mode 100644 index fe3bad5..0000000 --- a/.github/ISSUE_TEMPLATE/other-issues.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -name: Other issues -about: Use this to report general issues with the software -title: '' -labels: '' -assignees: Almamu - ---- - - diff --git a/.github/ISSUE_TEMPLATE/refactor.yml b/.github/ISSUE_TEMPLATE/refactor.yml new file mode 100644 index 0000000..d03baa6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/refactor.yml @@ -0,0 +1,22 @@ +name: "Code Cleanup / Refactor" +description: "Suggest internal improvements like refactoring or technical debt cleanup." +labels: [refactor, maintenance] +body: + - type: textarea + id: what + attributes: + label: What needs improvement? + validations: + required: true + - type: textarea + id: why + attributes: + label: Why is this necessary or beneficial? + validations: + required: false + - type: textarea + id: impact + attributes: + label: Potential Impact on Users + validations: + required: false diff --git a/src/WallpaperEngine/Application/CApplicationContext.cpp b/src/WallpaperEngine/Application/CApplicationContext.cpp index 34a8ef3..581cabe 100644 --- a/src/WallpaperEngine/Application/CApplicationContext.cpp +++ b/src/WallpaperEngine/Application/CApplicationContext.cpp @@ -255,44 +255,48 @@ CApplicationContext::CApplicationContext (int argc, char* argv []) : " Runs the background 2317494988 on two screens, one on HDMI-1 and the other on HDMI-2\n\n" ); - program.parse_known_args (argc, argv); + try { + program.parse_known_args (argc, argv); - if (this->settings.general.defaultBackground.empty ()) { - throw std::runtime_error ("No default background specified. Either --bg/-b or must be specified"); - } + if (this->settings.general.defaultBackground.empty ()) { + throw std::runtime_error ("At least one background ID must be specified"); + } - this->settings.audio.volume = std::max(0, std::min (this->settings.audio.volume, 128)); - this->settings.screenshot.delay = std::max (0, std::min (this->settings.screenshot.delay, 5)); + this->settings.audio.volume = std::max(0, std::min (this->settings.audio.volume, 128)); + this->settings.screenshot.delay = std::max (0, std::min (this->settings.screenshot.delay, 5)); - // use std::cout on this in case logging is disabled, this way it's easy to look at what is running - std::stringbuf buffer; - std::ostream bufferStream (&buffer); + // use std::cout on this in case logging is disabled, this way it's easy to look at what is running + std::stringbuf buffer; + std::ostream bufferStream (&buffer); - bufferStream << "Running with: "; + bufferStream << "Running with: "; - for (int i = 0; i < argc; i ++) { - bufferStream << argv [i]; - bufferStream << " "; - } + for (int i = 0; i < argc; i ++) { + bufferStream << argv [i]; + bufferStream << " "; + } - std::cout << buffer.str() << std::endl; - // perform some extra validation on the inputs - this->validateAssets (); - this->validateScreenshot (); + std::cout << buffer.str() << std::endl; + // perform some extra validation on the inputs + this->validateAssets (); + this->validateScreenshot (); - // setup application state - this->state.general.keepRunning = true; - this->state.audio.enabled = this->settings.audio.enabled; - this->state.audio.volume = this->settings.audio.volume; - this->state.mouse.enabled = this->settings.mouse.enabled; + // setup application state + this->state.general.keepRunning = true; + this->state.audio.enabled = this->settings.audio.enabled; + this->state.audio.volume = this->settings.audio.volume; + this->state.mouse.enabled = this->settings.mouse.enabled; #if DEMOMODE - sLog.error ("WARNING: RUNNING IN DEMO MODE WILL STOP WALLPAPERS AFTER 5 SECONDS SO VIDEO CAN BE RECORDED"); - // special settings for demomode - this->settings.render.maximumFPS = 30; - this->settings.screenshot.take = false; - this->settings.render.pauseOnFullscreen = false; + sLog.error ("WARNING: RUNNING IN DEMO MODE WILL STOP WALLPAPERS AFTER 5 SECONDS SO VIDEO CAN BE RECORDED"); + // special settings for demomode + this->settings.render.maximumFPS = 30; + this->settings.screenshot.take = false; + this->settings.render.pauseOnFullscreen = false; #endif /* DEMOMODE */ + } catch (const std::runtime_error& e) { + throw std::runtime_error (std::string (e.what()) + ". Use " + std::string (argv[0]) + " --help for more information"); + } } int CApplicationContext::getArgc () const { diff --git a/src/main.cpp b/src/main.cpp index 068579f..54f8db3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,47 +20,52 @@ void initLogging () { } int main (int argc, char* argv[]) { - // if type parameter is specified, this is a subprocess, so no logging should be enabled from our side - bool enableLogging = true; - std::string typeZygote = "--type=zygote"; - std::string typeUtility = "--type=utility"; + try { + // if type parameter is specified, this is a subprocess, so no logging should be enabled from our side + bool enableLogging = true; + std::string typeZygote = "--type=zygote"; + std::string typeUtility = "--type=utility"; - for (int i = 1; i < argc; i ++) { - if (strncmp (typeZygote.c_str(), argv[i], typeZygote.size()) == 0) { - enableLogging = false; - break; - } else if (strncmp (typeUtility.c_str(), argv[i], typeUtility.size()) == 0) { - enableLogging = false; - break; + for (int i = 1; i < argc; i ++) { + if (strncmp (typeZygote.c_str(), argv[i], typeZygote.size()) == 0) { + enableLogging = false; + break; + } else if (strncmp (typeUtility.c_str(), argv[i], typeUtility.size()) == 0) { + enableLogging = false; + break; + } } - } - if (enableLogging) { - initLogging (); - } + if (enableLogging) { + initLogging (); + } - WallpaperEngine::Application::CApplicationContext appContext (argc, argv); + WallpaperEngine::Application::CApplicationContext appContext (argc, argv); + + // halt if the list-properties option was specified + if (appContext.settings.general.onlyListProperties) + return 0; + + app = new WallpaperEngine::Application::CWallpaperApplication (appContext); + + // attach signals to gracefully stop + std::signal (SIGINT, signalhandler); + std::signal (SIGTERM, signalhandler); + std::signal (SIGKILL, signalhandler); + + // show the wallpaper application + app->show (); + + // remove signal handlers before destroying app + std::signal (SIGINT, SIG_DFL); + std::signal (SIGTERM, SIG_DFL); + std::signal (SIGKILL, SIG_DFL); + + delete app; - // halt if the list-properties option was specified - if (appContext.settings.general.onlyListProperties) return 0; - - app = new WallpaperEngine::Application::CWallpaperApplication (appContext); - - // attach signals to gracefully stop - std::signal (SIGINT, signalhandler); - std::signal (SIGTERM, signalhandler); - std::signal (SIGKILL, signalhandler); - - // show the wallpaper application - app->show (); - - // remove signal handlers before destroying app - std::signal (SIGINT, SIG_DFL); - std::signal (SIGTERM, SIG_DFL); - std::signal (SIGKILL, SIG_DFL); - - delete app; - - return 0; + } catch (const std::exception& e) { + std::cerr << e.what () << std::endl; + return 1; + } } \ No newline at end of file