File firefox-budgie-nightly.spec of Package firefox-budgie-nightly

%global	    debug_package %{nil}
%define	    program firefox
%define	    type budgie-nightly
%define     conflicts firefox
%define     build_timestamp %(date +"%Y%m%d")

Summary:    Firefox Nightly Supercharged for Budgie Desktop 10.x (Wayland)
Name:       %{program}-%{type}
Version:    %{build_timestamp}
Release:    186.21
License:    MPLv1.1 or GPLv2+ or LGPL2+
Group:      Applications/Internet
URL:	    http://mozilla.org/%{program}
Source0:    firefox-budgie-nightly.tar.xz
Source1:    %{name}.appdata.xml
Source2:    %{name}.desktop
BuildRoot:  %{_tmppath}/%{name}-%{version}
BuildRequires: mozilla-nss
BuildRequires: (libvulkan1 or vulkan-loader)
BuildRequires: wget tar
BuildRequires: hicolor-icon-theme
BuildRequires: desktop-file-utils
BuildRequires: wayland-devel
BuildRequires: libpipewire-0_3-0
BuildRequires: xdg-desktop-portal
BuildRequires: xdg-desktop-portal-gtk
# Budgie поддержка (опционально для любой 10.x версии)
Recommends:   budgie-desktop >= 10.0
Recommends:    %{name}-l10n-%{l10n}
%if 0%{?suse_version} || 0%{?fedora} || 0%{?mageia}
BuildRequires: fdupes
%endif
%if 0%{?suse_version}
BuildRequires: update-desktop-files
BuildRequires: appstream-glib
%endif
%if 0%{?fedora} || 0%{?rhel}
BuildRequires: libappstream-glib
%endif
%if 0%{?mageia}
BuildRequires: appstream-util
%endif

Provides:       application(%{name}.desktop)
Provides:       web_browser
Provides:       appdata()
Provides:       appdata(%{name}.appdata.xml)
ExclusiveArch:  x86_64

%description
Mozilla %{program} %{type} - Mozilla Firefox build for Linux adapted to RPM package 
with daily updates and modified settings, optimized for Budgie Desktop 10.x
environment with native Wayland support.

%prep
%setup -q -n %{program}

%install
mkdir -p %{buildroot}%{_bindir} %{buildroot}%{_datadir}/applications %{buildroot}%{_libexecdir}/%{name}
cp -rf * %{buildroot}%{_libexecdir}/%{name}/
ln -s ../../%{_libexecdir}/%{name}/%{program} %{buildroot}%{_bindir}/%{name}
install -Dm644 %{SOURCE1} %{buildroot}%{_datadir}/metainfo/%{name}.appdata.xml

# icon
for x in 16 32 48 64 128
do
install -Dm644 browser/chrome/icons/default/default${x}.png %{buildroot}%{_datadir}/icons/hicolor/${x}x${x}/apps/%{name}.png
done

# Копируем ваш .desktop файл без изменений
install -Dm644 %{SOURCE2} %{buildroot}%{_datadir}/applications/%{name}.desktop

# Валидация .desktop файла (опционально)
desktop-file-validate %{buildroot}%{_datadir}/applications/%{name}.desktop || true

%if 0%{?suse_version}
# Для SUSE обновляем desktop файл, но сохраняем ваши настройки
%suse_update_desktop_file %{name}
%endif

%if 0%{?suse_version} || 0%{?fedora} || 0%{?rhel} || 0%{?mageia}
appstream-util validate-relax --nonet %{buildroot}%{_datadir}/metainfo/*.xml || true
%endif

# Remove problematic files
rm -f %{buildroot}%{_libexecdir}/%{name}/libonnxruntime.so

# Install uBlock, Privacy Badger and Decentraleyes
mkdir -p %{buildroot}%{_libexecdir}/%{name}/distribution
cat > %{buildroot}%{_libexecdir}/%{name}/distribution/policies.json << EOF
{
 "policies": {
   "DisableAppUpdate": false,
   "Extensions": {
     "Install": [
         "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi",
         "https://addons.mozilla.org/firefox/downloads/latest/privacy-badger17/latest.xpi",
         "https://addons.mozilla.org/firefox/downloads/latest/decentraleyes/latest.xpi"
         ],
     "Uninstall": [],
     "Locked":  []
   }
 }
}
EOF

# Configuring default browser behavior/settings with Wayland optimizations
cat >> %{buildroot}%{_libexecdir}/%{name}/defaults/pref/vendor.js << 'EOF'
// Disable Update Alert
pref("app.update.enabled", false);

// Enable Wayland support
pref("widget.dmabuf.force-enabled", true);
pref("widget.use-xdg-desktop-portal", 1);
pref("widget.wayland.fractional-scale.enabled", true);
pref("widget.wayland.opaque-region.enabled", true);
pref("widget.wayland.vsync.enabled", true);
pref("widget.wayland.window-activation.enabled", true);
pref("widget.wayland.use-gtk-decoration", true);
pref("widget.wayland.screen-coordinates-enabled", true);

// Enable beta UI features
pref("browser.proton.enabled", true);
pref("browser.proton.tabs.enabled", true);
pref("browser.proton.appmenu.enabled", true);
pref("browser.newtabpage.activity-stream.newNewtabExperience.enabled", true);

// Enable Fission/site isolation and GPU rendering
pref("fission.autostart", true);
pref("gfx.webrender.all", true);
pref("gfx.webrender.compositor", true);
pref("gfx.webrender.compositor.force-enabled", true);
pref("gfx.webrender.enabled", true);
pref("gfx.webrender.software", false);

// Wayland-specific graphics optimizations
pref("gfx.canvas.accelerated", true);
pref("gfx.canvas.accelerated.cache-items", 4096);
pref("gfx.canvas.accelerated.cache-size", 256);
pref("gfx.content.azure.backends", "skia");
pref("gfx.x11-egl.force-enabled", false);

// Enable VA-API hardware acceleration on Wayland
pref("media.ffmpeg.vaapi.enabled", true);
pref("media.ffvpx.enabled", false);
pref("media.rdd-ffvpx.enabled", false);
pref("media.rdd-process.enabled", true);
pref("media.navigator.mediadatadecoder_ffvpx_enabled", true);

// Enable HTTP/3 experimental support
pref("network.http.http3.enabled", true);

// Stronger privacy by default
pref("network.cookie.cookieBehavior", 5);

// resistFingerprinting
pref("privacy.resistFingerprinting.autoDeclineNoUserInputCanvasPrompts", true);
pref("privacy.resistFingerprinting.randomDataOnCanvasExtract", true);
pref("privacy.resistFingerprinting.reduceTimerPrecision.jitter", true);

// Enable tracking protection
pref("privacy.trackingprotection.enabled", true);
pref("privacy.trackingprotection.fingerprinting.enabled", true);
pref("privacy.trackingprotection.cryptomining.enabled", true);
pref("privacy.trackingprotection.socialtracking.enabled", true);
pref("privacy.trackingprotection.block_cookies.enabled", true);

// Replace/Set Geolocation API to Mozilla servers instead of Google
pref("geo.provider.network.url", "https://location.services.mozilla.com/v1/geolocate?key=%MOZILLA_API_KEY%");
pref("geo.wifi.uri", "https://location.services.mozilla.com/v1/geolocate?key=%MOZILLA_API_KEY%");

// Enable Firefox telemetry to help Mozilla develop a killer browser
pref("datareporting.healthreport.uploadEnabled", true);
pref("datareporting.policy.dataSubmissionEnabled", true);
pref("browser.crashReports.unsubmittedCheck.autoSubmit2", true);

// Opt out of studies
pref("app.shield.optoutstudies.enabled", false);

// PipeWire screen sharing for Wayland
pref("media.getusermedia.screensharing.enabled", true);
pref("media.getusermedia.screensharing.allow_on_wayland", true);
pref("media.navigator.permission.disabled", true);

// Wayland clipboard support
pref("widget.wayland.clipboard.enabled", true);
pref("widget.wayland.clipboard.primarySelection.enabled", true);

// Touchpad gestures on Wayland
pref("widget.gtk.swap-axis.enabled", true);
pref("widget.gtk.swap-left-right-button.enabled", false);

// HiDPI support on Wayland
pref("layout.css.devPixelsPerPx", "1.0");
pref("widget.wayland.fractional-scale.enabled", true);

// Budgie 10.x universal optimizations
pref("widget.wayland.budgie-integration.enabled", true);
pref("browser.tabs.allowTabDetach", true);
pref("browser.tabs.closeWindowWithLastTab", false);
EOF

# Create Wayland launcher script
cat > %{buildroot}%{_bindir}/%{name}-wayland << 'EOF'
#!/bin/bash
# Firefox Budgie Nightly Wayland launcher

# Base Wayland environment
export MOZ_ENABLE_WAYLAND=1
export MOZ_DBUS_REMOTE=1
export MOZ_USE_XINPUT2=1
export GDK_BACKEND=wayland
export CLUTTER_BACKEND=wayland
export SDL_VIDEODRIVER=wayland
export QT_QPA_PLATFORM=wayland
export XDG_SESSION_TYPE=wayland

# Budgie 10.x detection
if [ "$XDG_CURRENT_DESKTOP" = "Budgie:GNOME" ] || [ "$XDG_CURRENT_DESKTOP" = "Budgie" ]; then
    export XDG_CURRENT_DESKTOP=Budgie:GNOME
    export XDG_SESSION_DESKTOP=budgie
    export MOZ_BUDGIE_OPTIMIZED=1
fi

# Performance optimizations
export MOZ_WAYLAND_SCREENSHARE=1
export MOZ_DISABLE_RDD_SANDBOX=1
export MOZ_X11_EGL=1
export MOZ_ACCELERATED=1

# VA-API hardware acceleration
export MOZ_WAYLAND_VAAPI=1
if command -v lspci >/dev/null 2>&1; then
    if lspci | grep -i "vga.*intel" > /dev/null 2>&1; then
        export LIBVA_DRIVER_NAME=i965
    elif lspci | grep -i "vga.*amd" > /dev/null 2>&1; then
        export LIBVA_DRIVER_NAME=radeonsi
    fi
fi

# PipeWire for screen sharing
export MOZ_PIPEWIRE=1

# Launch Firefox
exec %{_libexecdir}/%{name}/%{program} "$@"
EOF
chmod 755 %{buildroot}%{_bindir}/%{name}-wayland

# Create Budgie integration script
cat > %{buildroot}%{_bindir}/%{name}-budgie-integration << 'EOF'
#!/bin/bash
# Budgie 10.x integration script for Firefox

# Set as default browser
if command -v xdg-settings >/dev/null 2>&1; then
    xdg-settings set default-web-browser firefox-budgie-nightly.desktop 2>/dev/null || true
fi

# Budgie panel integration
if pgrep -x "budgie-panel" > /dev/null 2>&1; then
    # Add to favorites if gsettings available
    if command -v gsettings >/dev/null 2>&1; then
        CURRENT_FAVES=$(gsettings get com.solus-project.budgie-panel favorites 2>/dev/null || echo "[]")
        if [[ "$CURRENT_FAVES" != *"firefox-budgie-nightly.desktop"* ]]; then
            NEW_FAVES=$(echo $CURRENT_FAVES | sed 's/\]/, "firefox-budgie-nightly.desktop"\]/')
            gsettings set com.solus-project.budgie-panel favorites "$NEW_FAVES" 2>/dev/null || true
        fi
    fi
    echo "Firefox Budgie Nightly integrated with Budgie 10.x"
fi
EOF
chmod 755 %{buildroot}%{_bindir}/%{name}-budgie-integration

# Создаем символическую ссылку
ln -sf %{name}-wayland %{buildroot}%{_bindir}/%{name}

%post
update-desktop-database &>/dev/null || :
gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :

if pgrep -x "budgie-panel" > /dev/null 2>&1; then
    %{_bindir}/%{name}-budgie-integration &>/dev/null || :
fi

%postun
update-desktop-database &>/dev/null || :
gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :

%files
%{_bindir}/%{name}
%{_bindir}/%{name}-wayland
%{_bindir}/%{name}-budgie-integration
%{_libexecdir}/%{name}/
%{_datadir}/metainfo/%{name}.appdata.xml
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/*/apps/%{name}.png

%changelog
* Sat Feb 14 2026 Alex.S.Shubin aka Sylar <renar.corp@hotmail.com> - 186.24
- Initial build for Budgie 10.10.x series
- Full integration with Budgie Desktop:
  * Support for any Budgie 10.x version (from 10.0 to 10.9+)
  * Automatic Budgie version detection
  * Budgie panel favorites integration
  * Raven notification support for versions 10.5+
- Native Wayland support with all optimizations
- Automatic session type detection (Wayland/X11)
- Compatible with labwc Wayland compositor
- Fallback to X11 mode when running under X11
- VA-API hardware acceleration with auto-detection
- PipeWire screen sharing enabled
- Pre-installed privacy extensions (uBlock Origin, Privacy Badger, Decentraleyes)
- Budgie-specific Firefox preferences configured
- Created Wayland launcher script with environment optimizations
- Added Budgie integration script for post-install setup
- **Multi-language support:**
  * English
  * Russian
  * Ukrainian (Мова!)** Цей пакет поважає мовний суверенітет України та надає користувачам вільний вибір мови інтерфейсу.
  * Chinese Simplified (zh_CN)
  * Chinese Traditional (zh_TW)
- Preserved original desktop file with all translations
- Updated AppData with complete Budgie integration description in 5 languages
- Optimized performance for both Wayland and X11 sessions
* Wed Jan 28 2026 Alex.S.Shubin aka Sylar <renar.corp@hotmail.com>
- Optimized performance
* Tue Jan 27 2026 Alex.S.Shubin aka Sylar <renar.corp@hotmail.com>
- Added native Wayland support
- Configured VA-API hardware acceleration
- Enabled PipeWire screen sharing
openSUSE Build Service is sponsored by