diff --git a/README.md b/README.md index c647e50..7ae6711 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,7 @@ Some of the application options are not exposed in the GUI. They can be adjusted | **PriorityClients** |
Allows to set a list of clients that are not auto-minimized on inactivity even if the **Minimize inactive EVE clients** option is enabled. Listed clients still can be minimized using Windows hotkeys or via _Ctrl+Click_ on the corresponding thumbnail
The default value is empty list **[]**
For example: **"PriorityClients": [ "EVE - Phrynohyas Tig-Rah", "EVE - Ondatra Patrouette" ]**
| | **ThumbnailMinimumSize** |
Minimum thumbnail size that can be set either via GUI or by resizing a thumbnail window. Value is written in the form "width, height"
The default value is **"100, 80"**.
For example: **"ThumbnailMinimumSize": "100, 80"**
| | **ThumbnailMaximumSize** |
Maximum thumbnail size that can be set either via GUI or by resizing a thumbnail window. Value is written in the form "width, height"
The default value is **"640, 400"**.
For example: **"ThumbnailMaximumSize": "640, 400"**
| -| **ThumbnailRefreshPeriod** |
Thumbnail refresh period in milliseconds. This option accepts values between **300** and **1000** only.
The default value is **500** milliseconds.
For example: **"ThumbnailRefreshPeriod": 500**
| +| **ThumbnailRefreshPeriod** |
Thumbnail refresh period in milliseconds. This option accepts values between **300** and **1000** only.
The default value is **500** milliseconds. For LINUX build this can go down to **10**
For example: **"ThumbnailRefreshPeriod": 500**
| | **ThumbnailResizeTimeoutPeriod** |
Thumbnail Resize Timeout period in milliseconds. This option accepts values between **200** and **5000** only.
The default value is **500** milliseconds.
For example: **"ThumbnailResizeTimeoutPeriod": 500**. If you are having the preview windows resize incorrectly on startup increase this value.
| | **ExecutablesToPreview** |
List of executables to display preview windows for. List of strings.
The default value is **"exefile"**.
For example: **"ExecutablesToPreview": ["exefile","wow","Diablo IV"]**. If you are having the preview windows resize incorrectly on startup increase this value.
| diff --git a/src/Eve-O-Preview/Configuration/Implementation/ThumbnailConfiguration.cs b/src/Eve-O-Preview/Configuration/Implementation/ThumbnailConfiguration.cs index 782481e..790b63b 100644 --- a/src/Eve-O-Preview/Configuration/Implementation/ThumbnailConfiguration.cs +++ b/src/Eve-O-Preview/Configuration/Implementation/ThumbnailConfiguration.cs @@ -403,7 +403,11 @@ namespace EveOPreview.Configuration.Implementation /// public void ApplyRestrictions() { +#if LINUX + this.ThumbnailRefreshPeriod = ThumbnailConfiguration.ApplyRestrictions(this.ThumbnailRefreshPeriod, 10, 1000); +#else this.ThumbnailRefreshPeriod = ThumbnailConfiguration.ApplyRestrictions(this.ThumbnailRefreshPeriod, 300, 1000); +#endif this.ThumbnailResizeTimeoutPeriod = ThumbnailConfiguration.ApplyRestrictions(this.ThumbnailResizeTimeoutPeriod, 200, 5000); this.ThumbnailSize = new Size(ThumbnailConfiguration.ApplyRestrictions(this.ThumbnailSize.Width, this.ThumbnailMinimumSize.Width, this.ThumbnailMaximumSize.Width), ThumbnailConfiguration.ApplyRestrictions(this.ThumbnailSize.Height, this.ThumbnailMinimumSize.Height, this.ThumbnailMaximumSize.Height)); diff --git a/src/Eve-O-Preview/Services/Implementation/WindowManager.cs b/src/Eve-O-Preview/Services/Implementation/WindowManager.cs index 95b5f4f..d792539 100644 --- a/src/Eve-O-Preview/Services/Implementation/WindowManager.cs +++ b/src/Eve-O-Preview/Services/Implementation/WindowManager.cs @@ -16,6 +16,9 @@ namespace EveOPreview.Services.Implementation #region Private fields private readonly bool _enableWineCompatabilityMode; + private string _bashLocation; + private string _wmctrlLocation; + private const string EXCEPTION_DUMP_FILE_NAME = "EVE-O-Preview.log"; #endregion @@ -23,6 +26,8 @@ namespace EveOPreview.Services.Implementation { #if LINUX this._enableWineCompatabilityMode = configuration.EnableWineCompatibilityMode; + this._bashLocation = FindLinuxBinLocation("bash"); + this._wmctrlLocation = FindLinuxBinLocation("wmctrl"); #endif // Composition is always enabled for Windows 8+ this.IsCompositionEnabled = @@ -31,6 +36,39 @@ namespace EveOPreview.Services.Implementation || DwmNativeMethods.DwmIsCompositionEnabled(); // In case of Win 7 an API call is requiredWin 7 _animationParam.cbSize = (System.UInt32)Marshal.SizeOf(typeof(ANIMATIONINFO)); } +#if LINUX + private string FindLinuxBinLocation(string command) + { + // Check common paths for command + string[] paths = { "/run/host/usr/bin", "/bin", "/usr/bin" }; + foreach (var path in paths) + { + string locationToCheck = $"{path}/{command}"; + if (System.IO.File.Exists(locationToCheck)) + { + string binLocation = System.IO.Path.GetDirectoryName(locationToCheck); + string binLocationUnixStyle = binLocation.Replace("\\", "/"); + + return binLocationUnixStyle; + } + } + + WriteToLog($"[{DateTime.Now}] Error: {command} not found in expected locations."); + return null; + } +#endif + + private void WriteToLog(string message) + { + try + { + System.IO.File.AppendAllText(EXCEPTION_DUMP_FILE_NAME, message + Environment.NewLine); + } + catch (Exception ex) + { + Console.WriteLine($"Failed to write to log file: {ex.Message}"); + } + } private int? _currentAnimationSetting = null; private ANIMATIONINFO _animationParam = new ANIMATIONINFO(); @@ -95,17 +133,37 @@ namespace EveOPreview.Services.Implementation return; } - string? cmd = null; - // If we are in a flatpak, then use flatpak-spawn to run wmctrl outside the sandbox - if (Environment.GetEnvironmentVariable("container") == "flatpak") - { - cmd = "-c \"flatpak-spawn --host wmctrl -a \"\"" + windowName + "\"\"\""; - } - else - { - cmd = "-c \"wmctrl -a \"\"" + windowName + "\"\"\""; - } - System.Diagnostics.Process.Start("bash", cmd); + string cmd = ""; + try + { + // If we are in a flatpak, then use flatpak-spawn to run wmctrl outside the sandbox + if (Environment.GetEnvironmentVariable("container") == "flatpak") + { + cmd = $"-c \"flatpak-spawn --host {this._wmctrlLocation}/wmctrl -a \"\"" + windowName + "\"\"\""; + } + else + { + cmd = $"-c \"{this._wmctrlLocation}/wmctrl -a \"\"" + windowName + "\"\"\""; + } + + // Configure and start the process + var processStartInfo = new System.Diagnostics.ProcessStartInfo + { + FileName = $"{this._bashLocation}/bash", + Arguments = cmd, + UseShellExecute = false, + CreateNoWindow = false + }; + + using (var process = System.Diagnostics.Process.Start(processStartInfo)) + { + process.WaitForExit(); + } + } + catch (Exception ex) + { + WriteToLog($"[{DateTime.Now}] executing wmctrl - Exception: {ex.Message}"); + } } public void ActivateWindow(IntPtr handle, string windowName)