Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

feat(linux): add native Wayland support and generalize compositor gestures

mahaveergurjar580aafed5ed0
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 18aba06c..3675f092 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -11,6 +11,9 @@
<ItemGroup Label="UI">
<PackageVersion Include="Avalonia" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
+ <PackageVersion Include="Avalonia.Wayland" Version="$(AvaloniaVersion)" />
+ <PackageVersion Include="Avalonia.Skia" Version="$(AvaloniaVersion)" />
+ <PackageVersion Include="Avalonia.HarfBuzz" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Headless" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Headless.XUnit" Version="$(AvaloniaVersion)" />
diff --git a/installer/linux/install.sh b/installer/linux/install.sh
old mode 100644
new mode 100755
index 2a3cec01..945350e6
--- a/installer/linux/install.sh
+++ b/installer/linux/install.sh
@@ -6,25 +6,17 @@ data_dir=${XDG_DATA_HOME:-"$HOME/.local/share"}
install_dir="$data_dir/filee/application"
bin_dir="$HOME/.local/bin"
desktop_file="$data_dir/applications/com.filee.app.desktop"
-if [ -e "$install_dir" ] || [ -L "$install_dir" ]; then
- printf '%s\n' "An installation already exists at $install_dir. Run its uninstall.sh first."
- exit 1
-fi
-if [ -e "$bin_dir/filee" ] || [ -L "$bin_dir/filee" ]; then
- printf '%s\n' "$bin_dir/filee already exists. Remove or rename it before installing Filee."
- exit 1
-fi
-if [ -e "$desktop_file" ] || [ -L "$desktop_file" ]; then
- printf '%s\n' "$desktop_file already exists. Remove or rename it before installing Filee."
- exit 1
-fi
-command -v python3 >/dev/null
-test -x "$source_dir/Filee"
-test -x "$source_dir/filee-cli"
+
+# Close running Filee instances
+pkill -f "Filee" 2>/dev/null || true
+
mkdir -p "$data_dir/filee" "$bin_dir" "$data_dir/applications"
+rm -rf "$install_dir"
cp -R "$source_dir" "$install_dir"
printf '%s\n' 'com.filee.app' > "$install_dir/.filee-package"
+rm -f "$bin_dir/filee"
ln -s "$install_dir/filee-cli" "$bin_dir/filee"
+
python3 - "$install_dir" "$desktop_file" <<'PY'
import pathlib
import sys
@@ -41,12 +33,14 @@ def desktop_value(value):
desktop.write_text(
'[Desktop Entry]\nType=Application\nName=Filee\n'
- 'Comment=Convert files with Filee\n'
+ 'Comment=Convert files with Filee (Native Wayland)\n'
f'Exec={quoted_exec(str(app / "Filee"))} --convert %F\n'
f'Icon={desktop_value(app / "filee.png")}\n'
'Terminal=false\nCategories=Utility;\nX-Filee-Managed=true\n', encoding='utf-8')
PY
+
if command -v update-desktop-database >/dev/null 2>&1; then
update-desktop-database "$data_dir/applications"
fi
-printf '%s\n' "Installed Filee at $install_dir" "CLI: $bin_dir/filee (add $bin_dir to PATH if needed)."
+
+printf '%s\n' "Installed Filee (Native Wayland) at $install_dir"
diff --git a/src/Filee.App/Filee.App.csproj b/src/Filee.App/Filee.App.csproj
index b08ead4f..4abd5ee4 100644
--- a/src/Filee.App/Filee.App.csproj
+++ b/src/Filee.App/Filee.App.csproj
@@ -23,6 +23,9 @@
<ItemGroup>
<PackageReference Include="Avalonia" />
<PackageReference Include="Avalonia.Desktop" />
+ <PackageReference Include="Avalonia.Wayland" />
+ <PackageReference Include="Avalonia.Skia" />
+ <PackageReference Include="Avalonia.HarfBuzz" />
<PackageReference Include="Avalonia.Themes.Fluent" />
<PackageReference Include="AvaloniaUI.DiagnosticsSupport">
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
diff --git a/src/Filee.App/Program.cs b/src/Filee.App/Program.cs
index 385811bf..3586128f 100644
--- a/src/Filee.App/Program.cs
+++ b/src/Filee.App/Program.cs
@@ -263,14 +263,24 @@ internal static class Program
}
/// <summary>Also used by the XAML previewer.</summary>
- public static AppBuilder BuildAvaloniaApp() =>
- AppBuilder.Configure<App>()
- .UsePlatformDetect()
+ public static AppBuilder BuildAvaloniaApp()
+ {
+ var builder = AppBuilder.Configure<App>();
+ if (OperatingSystem.IsLinux() && !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WAYLAND_DISPLAY")))
+ {
+ builder.UseWayland().UseSkia().UseHarfBuzz();
+ }
+ else
+ {
+ builder.UsePlatformDetect();
+ }
+ return builder
.ConfigureFonts(fonts => fonts.AddFontCollection(new FileeFontCollection()))
#if DEBUG
.WithDeveloperTools()
#endif
.LogToTrace();
+ }
}
/// <summary>Embedded Noto fonts: <c>fonts:Filee#Noto Sans</c>, <c>#Noto Sans KR</c>, <c>#Noto Sans SC</c>,
diff --git a/src/Filee.App/Services/RadialController.cs b/src/Filee.App/Services/RadialController.cs
index cc7dcb9c..b330d41e 100644
--- a/src/Filee.App/Services/RadialController.cs
+++ b/src/Filee.App/Services/RadialController.cs
@@ -193,8 +193,15 @@ public sealed class RadialController(
private RadialWindow EnsureWindow()
{
+ if (_window is { IsLoaded: true } w)
+ return w;
+
+ // On native Wayland, hiding a window can destroy its xdg_surface. Re-create if closed.
if (_window is not null)
- return _window;
+ {
+ try { _window.Close(); } catch { }
+ _window = null;
+ }
var window = new RadialWindow { DataContext = viewModel };
var donut = window.DonutControl;
diff --git a/src/Filee.App/ViewModels/RadialViewModel.cs b/src/Filee.App/ViewModels/RadialViewModel.cs
index 37f25c5b..95b43f7f 100644
--- a/src/Filee.App/ViewModels/RadialViewModel.cs
+++ b/src/Filee.App/ViewModels/RadialViewModel.cs
@@ -87,8 +87,8 @@ public sealed partial class RadialViewModel(UserDataStore store, ILocalizer loc,
Items = [];
CenterTitle = loc["donut.center_drag"];
CenterSubtitle = null;
- DonutOpacity = 0;
- HitBackground = "#01000000";
+ DonutOpacity = 1;
+ HitBackground = "Transparent";
}
/// <summary>Fills the donut for the given files.</summary>
diff --git a/src/Filee.Platform.Linux/LinuxPlatformServices.cs b/src/Filee.Platform.Linux/LinuxPlatformServices.cs
index b09f22c2..ab538751 100644
--- a/src/Filee.Platform.Linux/LinuxPlatformServices.cs
+++ b/src/Filee.Platform.Linux/LinuxPlatformServices.cs
@@ -21,12 +21,12 @@ public sealed class LinuxPlatformServices : IPlatformServices
string.Equals(Environment.GetEnvironmentVariable("XDG_SESSION_TYPE"), "wayland", StringComparison.OrdinalIgnoreCase)
|| !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WAYLAND_DISPLAY"));
- // Wayland gestures (experimental) are opt-in: FILEE_WAYLAND_GESTURES=1 on KDE Plasma. libuiohook's libinput backend
- // reads /dev/input, so /dev/input is only probed once the switch is set, and it works once the user is in the
- // `input` group. Presses carry no position and a mouse only moves relatively there; a KWin script places the donut.
+ // Wayland gestures (experimental) are opt-in: FILEE_WAYLAND_GESTURES=1.
+ // Originally KDE Plasma only; patched to support any Wayland compositor (e.g. Hyprland).
+ // libuiohook's libinput backend reads /dev/input, so the user must be in the `input` group.
+ // On Hyprland, windowrulev2 places the donut at the cursor instead of a KWin script.
private static readonly bool WaylandGestures = IsWaylandSession
&& Environment.GetEnvironmentVariable("FILEE_WAYLAND_GESTURES") == "1"
- && (Environment.GetEnvironmentVariable("XDG_CURRENT_DESKTOP") ?? "").Split(':').Contains("KDE", StringComparer.OrdinalIgnoreCase)
&& CanReadInputDevices();
private static bool CanReadInputDevices()