From ab845890aec7092ebc463ceccc5bef38bb6fb2f5 Mon Sep 17 00:00:00 2001 From: 28allday Date: Sun, 3 May 2026 14:03:40 +0100 Subject: [PATCH] Initial commit: install/uninstall scripts for NVIDIA GeForce NOW flatpak Targets the official com.nvidia.geforcenow flatpak (not the community electron build). Forces XWayland for Hyprland compatibility and injects a marker-bracketed windowrule into ~/.config/hypr/hyprland.conf so it takes effect on Omarchy (where ~/.config/hypr/windowrules.conf is not auto-sourced). Updated for Hyprland 0.54.3: - Uses modern `windowrule = ...` syntax (drops deprecated windowrulev2). - Idempotent marker block in hyprland.conf, with hyprctl reload. - Restarts Elephant so Walker picks up the new .desktop entry. --- .gitignore | 3 + LICENSE | 21 +++++ README.md | 57 ++++++++++++ install-geforcenow-native.sh | 156 +++++++++++++++++++++++++++++++++ uninstall-geforcenow-native.sh | 97 ++++++++++++++++++++ 5 files changed, 334 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100755 install-geforcenow-native.sh create mode 100755 uninstall-geforcenow-native.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5a22eff --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.swp +*~ +.DS_Store diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5acd172 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Gavin Nugent + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..bda9e7d --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +# geforcenow-native + +Install / uninstall scripts for the **official NVIDIA GeForce NOW Linux flatpak** +(`com.nvidia.geforcenow`) on Arch Linux + Hyprland (Omarchy-friendly). + +This wraps the upstream NVIDIA flatpak — it does **not** use the community +electron build. The scripts force XWayland (Wayland-native is broken under +Hyprland at time of writing), drop a launcher in `~/.local/bin/geforcenow`, +register a `.desktop` entry that survives flatpak overrides, and inject a +Hyprland windowrule that opens the app fullscreen. + +## Install + +```bash +./install-geforcenow-native.sh +``` + +What it does: +1. Installs Flatpak + Flathub if missing. +2. Adds the NVIDIA GeForce NOW user-scope flatpak remote and installs + `com.nvidia.geforcenow`. +3. Forces the app onto XWayland (`--nosocket=wayland --socket=x11`). +4. Adds a `~/.local/bin/geforcenow` wrapper that sets `SDL_VIDEODRIVER=x11`. +5. Writes `~/.local/share/applications/com.nvidia.geforcenow.desktop` + pointing at the wrapper, with `StartupWMClass=GeForceNOW` so the + windowrule matches. +6. Appends a marker-bracketed block to `~/.config/hypr/hyprland.conf` + adding `windowrule = fullscreen, class:^(GeForceNOW)$` and reloads + Hyprland. +7. Restarts Walker's Elephant backend so the new entry shows up. + +## Uninstall + +```bash +./uninstall-geforcenow-native.sh +``` + +Removes the flatpak, the user remote, the launcher, both desktop entries, +the app data under `~/.var/app/`, the Hyprland marker block (and any +legacy pre-marker `GeForceNOW` lines), then reloads Hyprland and +restarts Elephant. + +Flatpak and Flathub are intentionally left installed — they're often shared +with other apps. + +## Notes + +- Tested on Hyprland 0.54.3 with Omarchy. Uses the modern `windowrule` + syntax (no `windowrulev2`). +- The windowrule lives in `hyprland.conf` because Omarchy's stock + `hyprland.conf` does not source `~/.config/hypr/windowrules.conf`. +- Re-running the installer is safe — the marker block is stripped and + re-added, so duplicates can't accumulate. + +## License + +MIT diff --git a/install-geforcenow-native.sh b/install-geforcenow-native.sh new file mode 100755 index 0000000..a04d83c --- /dev/null +++ b/install-geforcenow-native.sh @@ -0,0 +1,156 @@ +#!/bin/bash +# GeForce NOW Linux Installer for Arch Linux / Hyprland (Omarchy-aware) +# Installs the official NVIDIA GeForce NOW flatpak and wires it up for XWayland. + +set -e + +echo "=== GeForce NOW Installer for Arch Linux ===" +echo "" + +if [ "$EUID" -eq 0 ]; then + echo "ERROR: Do not run this script as root. Run as your normal user." + exit 1 +fi + +# 1/4 - Flatpak +echo "[1/4] Checking for Flatpak..." +if ! command -v flatpak &> /dev/null; then + echo " Flatpak not found. Installing..." + sudo pacman -S --noconfirm flatpak + echo " Flatpak installed." +else + echo " Flatpak is already installed." +fi + +# 2/4 - Flathub +echo "[2/4] Checking Flathub repository..." +if ! flatpak remotes --system | grep -q "flathub"; then + echo " Adding Flathub repository..." + sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo + echo " Flathub added." +else + echo " Flathub is already configured." +fi + +# 3/4 - Runtime +echo "[3/4] Installing Flatpak runtime dependencies..." +flatpak install -y --system flathub org.freedesktop.Platform//24.08 2>/dev/null || true + +# 4/4 - GeForce NOW +echo "[4/4] Installing GeForce NOW..." +flatpak remote-add --user --if-not-exists GeForceNOW https://international.download.nvidia.com/GFNLinux/flatpak/geforcenow.flatpakrepo +flatpak install -y --user GeForceNOW com.nvidia.geforcenow + +# Force XWayland (Wayland-native breaks under Hyprland) +echo "[+] Configuring for XWayland mode..." +flatpak override --user --nosocket=wayland com.nvidia.geforcenow +flatpak override --user --socket=x11 com.nvidia.geforcenow + +# Make Flatpak app .desktop entries discoverable by app launchers +echo "[+] Configuring environment for Flatpak apps..." +XDG_LINE="export XDG_DATA_DIRS=\"\${XDG_DATA_DIRS:-/usr/local/share:/usr/share}:/var/lib/flatpak/exports/share:\$HOME/.local/share/flatpak/exports/share\"" + +add_xdg_line() { + local file="$1" + [ -f "$file" ] || return 0 + if ! grep -q "flatpak/exports/share" "$file" 2>/dev/null; then + { + echo "" + echo "# Flatpak app directories for desktop entries and icons" + echo "$XDG_LINE" + } >> "$file" + echo " Added to $file" + fi +} + +if [ -f "$HOME/.bash_profile" ]; then + add_xdg_line "$HOME/.bash_profile" +elif [ -f "$HOME/.profile" ]; then + add_xdg_line "$HOME/.profile" +fi +add_xdg_line "$HOME/.zshrc" + +# Launcher script +LAUNCHER_DIR="$HOME/.local/bin" +mkdir -p "$LAUNCHER_DIR" + +cat > "$LAUNCHER_DIR/geforcenow" << 'LAUNCHER' +#!/bin/bash +# GeForce NOW launcher for Hyprland (XWayland) +exec flatpak run --nosocket=wayland \ + --env=SDL_VIDEODRIVER=x11 \ + com.nvidia.geforcenow \ + "$@" +LAUNCHER +chmod +x "$LAUNCHER_DIR/geforcenow" + +# Desktop entry override +DESKTOP_DIR="$HOME/.local/share/applications" +mkdir -p "$DESKTOP_DIR" +rm -f "$DESKTOP_DIR/geforcenow.desktop" +rm -f "$HOME/Desktop/com.nvidia.geforcenow.desktop" 2>/dev/null || true + +ICON_PATH="$HOME/.local/share/flatpak/exports/share/icons/hicolor/512x512/apps/com.nvidia.geforcenow.png" + +cat > "$DESKTOP_DIR/com.nvidia.geforcenow.desktop" << EOF +[Desktop Entry] +Version=1.0 +Name=NVIDIA GeForce NOW +GenericName=NVIDIA GeForce NOW +Comment=Play games from the cloud with GeForce NOW +Exec=$LAUNCHER_DIR/geforcenow +Icon=$ICON_PATH +Terminal=false +Type=Application +Categories=Network;Game; +Keywords=nvidia;geforce;cloud;gaming;stream; +StartupWMClass=GeForceNOW +X-Flatpak=com.nvidia.geforcenow +EOF + +update-desktop-database "$DESKTOP_DIR" 2>/dev/null || true + +# Hyprland window rule — append a marker block to ~/.config/hypr/hyprland.conf. +# Idempotent: re-running strips the old block before appending a new one. +# (Omarchy doesn't auto-source ~/.config/hypr/windowrules.conf, so we target +# hyprland.conf directly.) +HYPR_CONF="$HOME/.config/hypr/hyprland.conf" +BEGIN_MARKER="# >>> geforcenow-native >>>" +END_MARKER="# <<< geforcenow-native <<<" + +if [ -f "$HYPR_CONF" ]; then + echo "[+] Adding Hyprland window rule for fullscreen launch..." + # Strip any prior block + sed -i "/$BEGIN_MARKER/,/$END_MARKER/d" "$HYPR_CONF" + { + echo "" + echo "$BEGIN_MARKER" + echo "# GeForce NOW - fullscreen on launch" + echo "windowrule = fullscreen, class:^(GeForceNOW)$" + echo "$END_MARKER" + } >> "$HYPR_CONF" + echo " Window rule injected into $HYPR_CONF" + + # Reload Hyprland if running + hypr_root="${XDG_RUNTIME_DIR:-/run/user/$UID}/hypr" + if [ -d "$hypr_root" ]; then + for sock in "$hypr_root"/*/.socket.sock; do + [ -e "$sock" ] || continue + inst="${sock%/.socket.sock}"; inst="${inst##*/}" + HYPRLAND_INSTANCE_SIGNATURE="$inst" hyprctl reload >/dev/null 2>&1 || true + break + done + fi +fi + +# Refresh Walker so the new .desktop entry shows up +systemctl --user restart elephant.service 2>/dev/null || true + +echo "" +echo "=== Installation Complete ===" +echo "" +echo "You can launch GeForce NOW by:" +echo " 1. 'NVIDIA GeForce NOW' in your application launcher (Walker / rofi / etc.)" +echo " 2. Running 'geforcenow' from terminal" +echo "" +echo "Note: The app runs in XWayland mode for Hyprland compatibility." diff --git a/uninstall-geforcenow-native.sh b/uninstall-geforcenow-native.sh new file mode 100755 index 0000000..f4d5095 --- /dev/null +++ b/uninstall-geforcenow-native.sh @@ -0,0 +1,97 @@ +#!/bin/bash +# GeForce NOW Uninstaller for Arch Linux / Hyprland (Omarchy-aware) +# Removes the official NVIDIA GeForce NOW flatpak and everything the +# installer added. Leaves Flatpak / Flathub alone (other apps may use them). + +echo "=== GeForce NOW Uninstaller ===" +echo "" + +# 1/6 - Flatpak app +echo "[1/6] Removing GeForce NOW flatpak..." +if flatpak uninstall -y --user com.nvidia.geforcenow 2>/dev/null; then + echo " Removed." +else + echo " Not installed." +fi + +# 2/6 - Flatpak remote +echo "[2/6] Removing GeForce NOW flatpak remote..." +if flatpak remote-delete --user GeForceNOW 2>/dev/null; then + echo " Removed." +else + echo " Not present." +fi + +# 3/6 - Launcher +echo "[3/6] Removing launcher script..." +if [ -e "$HOME/.local/bin/geforcenow" ]; then + rm -f "$HOME/.local/bin/geforcenow" + echo " Removed." +else + echo " Not present." +fi + +# 4/6 - Desktop entries +echo "[4/6] Removing desktop entries..." +rm -f "$HOME/.local/share/applications/com.nvidia.geforcenow.desktop" +rm -f "$HOME/.local/share/applications/geforcenow.desktop" +rm -f "$HOME/Desktop/com.nvidia.geforcenow.desktop" 2>/dev/null +update-desktop-database "$HOME/.local/share/applications/" 2>/dev/null +echo " Removed." + +# 5/6 - App data +echo "[5/6] Removing app data..." +if [ -d "$HOME/.var/app/com.nvidia.geforcenow" ]; then + rm -rf "$HOME/.var/app/com.nvidia.geforcenow" + echo " Removed." +else + echo " Not present." +fi + +# 6/6 - Hyprland window rule +echo "[6/6] Removing Hyprland window rule..." +HYPR_CONF_DIR="$HOME/.config/hypr" +BEGIN_MARKER="# >>> geforcenow-native >>>" +END_MARKER="# <<< geforcenow-native <<<" + +# Modern: strip the marker block from hyprland.conf +if [ -f "$HYPR_CONF_DIR/hyprland.conf" ] && grep -q "$BEGIN_MARKER" "$HYPR_CONF_DIR/hyprland.conf" 2>/dev/null; then + sed -i "/$BEGIN_MARKER/,/$END_MARKER/d" "$HYPR_CONF_DIR/hyprland.conf" + echo " Removed marker block from $HYPR_CONF_DIR/hyprland.conf" +fi + +# Legacy: scrub any stray pre-marker lines from older installs +for conf in "$HYPR_CONF_DIR/hyprland.conf" "$HYPR_CONF_DIR/windowrules.conf" "$HYPR_CONF_DIR/windows.conf"; do + if [ -f "$conf" ] && grep -q "GeForceNOW" "$conf" 2>/dev/null; then + sed -i '/# GeForce NOW/d' "$conf" + sed -i '/GeForceNOW/d' "$conf" + echo " Cleaned legacy lines from $conf" + fi +done + +# Reload Hyprland if running +hypr_root="${XDG_RUNTIME_DIR:-/run/user/$UID}/hypr" +if [ -d "$hypr_root" ]; then + for sock in "$hypr_root"/*/.socket.sock; do + [ -e "$sock" ] || continue + inst="${sock%/.socket.sock}"; inst="${inst##*/}" + HYPRLAND_INSTANCE_SIGNATURE="$inst" hyprctl reload >/dev/null 2>&1 || true + break + done +fi + +# Walker / Elephant refresh +rm -rf "$HOME/.cache/walker" 2>/dev/null +systemctl --user restart elephant.service 2>/dev/null || true + +# Reset flatpak overrides (no-op if app already gone) +flatpak override --user --reset com.nvidia.geforcenow 2>/dev/null || true + +echo "" +echo "=== Uninstall Complete ===" +echo "" +echo "GeForce NOW has been removed from your system." +echo "" +echo "Note: Flatpak and Flathub were left installed (other apps may use them)." +echo " To also remove Flatpak completely, run:" +echo " sudo pacman -Rns flatpak"