{"record":{"id":"27b15e31e09fa972","repo":"d2phap/ImageGlass","slug":"ige-this-feature-is-not-supported-on-linux","errorCode":null,"errorMessage":"IGE: This feature is not supported on Linux.","messagePattern":"IGE: This feature is not supported on Linux\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"warning","filePath":"source/ImageGlass.Linux/Common/ServiceProviders/LinuxShellProvider.cs","lineNumber":189,"sourceCode":"        if (string.IsNullOrWhiteSpace(dirPath)) return;\n\n        try\n        {\n            Directory.CreateDirectory(dirPath);\n        }\n        catch { }\n\n        // Open the folder in the default file manager.\n        XdgPortal.ShowFolders(dirPath);\n    }\n\n\n    /// <summary>\n    /// <inheritdoc/>\n    /// </summary>\n    public Task<DefaultAppScope?> SetDefaultPhotoViewerAsync(string[] extensions, bool enable)\n    {\n        throw new NotSupportedException(\"IGE: This feature is not supported on Linux.\");\n    }\n\n\n    /// <summary>\n    /// <inheritdoc/>\n    /// </summary>\n    public Task SetLockScreenAsync(string filePath)\n    {\n        throw new NotSupportedException(\"IGE: This feature is not supported on Linux.\");\n    }\n\n\n    /// <summary>\n    /// <inheritdoc/>\n    /// </summary>\n    public void SetWallpaper(string filePath)\n    {\n        // Route through the Wallpaper portal so it works inside the Flatpak","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/d2phap/ImageGlass/blob/4a3c4feceffc5a8bb5e56ba836509634aaae47a9/source/ImageGlass.Linux/Common/ServiceProviders/LinuxShellProvider.cs#L171-L207","documentation":"Thrown by LinuxShellProvider.SetDefaultPhotoViewerAsync — the Linux implementation of IShellProvider cannot register ImageGlass as the system default photo viewer. Unlike Windows/macOS, Linux has no single portable default-app API: MIME handler registration is desktop-specific (gnome, kde, etc.) and the host chose not to implement any of them, so it throws NotSupportedException unconditionally.","triggerScenarios":"Produced at LinuxShellProvider.cs:189 the moment SetDefaultPhotoViewerAsync is called, regardless of arguments. Reached when the Linux app exposes a 'set as default photo viewer' action and the user triggers it.","commonSituations":"Settings page or first-run flow invoking SetDefaultPhotoViewerAsync on Linux because the UI did not hide the option for this platform; a feature that calls the shell provider generically without checking OS support; porting a Windows-centric feature to Linux without gating the call.","solutions":["Gate the UI/control that triggers SetDefaultPhotoViewerAsync on platform: hide or disable it on Linux (use Avalonia OnPlatform on IsVisible).","Catch NotSupportedException and show an informational 'not supported on Linux' message instead of crashing.","If the feature is required on Linux, implement MIME-handler registration per desktop environment and replace the throw with real logic.","Before calling, query the provider capability (or use OperatingSystem.IsWindows/macOS()) to skip the call on Linux."],"exampleFix":"// before (caller)\nawait Core.ShellProvider.SetDefaultPhotoViewerAsync(exts, enable);\n\n// after — guard on platform and surface gracefully\ntry { await Core.ShellProvider.SetDefaultPhotoViewerAsync(exts, enable); }\ncatch (NotSupportedException) { await ShowInfoAsync(\"Setting the default photo viewer is not supported on this OS.\"); }\n\n// XAML — hide the trigger on Linux\n<Button IsVisible=\"{OnPlatform False, Linux=False, Windows=True, macOS=True}\" .../>","handlingStrategy":"validation","validationCode":"// Only call the default-viewer API where supported.\nif (!OperatingSystem.IsWindows() && !OperatingSystem.IsMacOS())\n    return; // Linux unsupported\nawait Core.ShellProvider.SetDefaultPhotoViewerAsync(extensions, enable);","typeGuard":"static bool PlatformSupportsDefaultViewer() =>\n    OperatingSystem.IsWindows() || OperatingSystem.IsMacOS();","tryCatchPattern":"try { await Core.ShellProvider.SetDefaultPhotoViewerAsync(extensions, enable); }\ncatch (NotSupportedException) { await ShowInfoAsync(\"Setting the default photo viewer is not supported on this OS.\"); }","preventionTips":["Hide/disable the 'set as default photo viewer' control on Linux via Avalonia OnPlatform.","Query OperatingSystem.IsWindows/macOS() before calling the shell provider.","Do not let a generic 'set defaults' flow call unsupported provider methods.","If implementing on Linux, write per-desktop MIME registration and replace the throw."],"tags":["linux","platform","shell","not-supported","default-app"],"backgroundTag":null,"analyzedSha":"4a3c4feceffc5a8bb5e56ba836509634aaae47a9","analyzedAt":"2026-08-13T16:58:15.523Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}