#!/bin/bash

DISCORD_PATH="/opt/discord"
RUNTIME_DIR="/run/user/$(id -u)"

bwrap \
  --ro-bind /usr /usr \
  --setenv __NV_PRIME_RENDER_OFFLOAD "1" \
--setenv __GLX_VENDOR_LIBRARY_NAME "nvidia" \
--setenv __VK_LAYER_NV_optimus "NVIDIA_only" \
  --ro-bind /lib /lib \
  --ro-bind /lib64 /lib64 \
  --ro-bind "$DISCORD_PATH" "$DISCORD_PATH" \
  --bind ~/.config/discord ~/.config/discord \
  --bind ~/Descargas ~/Descargas \
  --dev /dev \
  --dev-bind /dev/dri /dev/dri \
  --dev-bind /dev/nvidiactl /dev/nvidiactl \
  --dev-bind /dev/nvidia0 /dev/nvidia0 \
  --dev-bind /dev/nvidia-modeset /dev/nvidia-modeset \
  --proc /proc \
  --tmpfs /tmp \
  --unshare-all \
  --share-net \
  --ro-bind /etc/resolv.conf /etc/resolv.conf \
  --ro-bind /etc/hosts /etc/hosts \
  --bind "$RUNTIME_DIR/$WAYLAND_DISPLAY" "$RUNTIME_DIR/$WAYLAND_DISPLAY" \
  --bind "$RUNTIME_DIR/pulse" "$RUNTIME_DIR/pulse" \
  --bind "$RUNTIME_DIR/hypr" "$RUNTIME_DIR/hypr" \
  --setenv HOME "$HOME" \
  --setenv XDG_RUNTIME_DIR "$RUNTIME_DIR" \
  --setenv WAYLAND_DISPLAY "$WAYLAND_DISPLAY" \
  --setenv DBUS_SESSION_BUS_ADDRESS "$DBUS_SESSION_BUS_ADDRESS" \
  --setenv PULSE_SERVER "unix:$RUNTIME_DIR/pulse/native" \
  --setenv XDG_CURRENT_DESKTOP "Hyprland" \
  --setenv XDG_SESSION_TYPE "wayland" \
  --unsetenv DISPLAY \
  "$DISCORD_PATH/Discord" \
  --enable-features=UseOzonePlatform \
  --ozone-platform=wayland \
  --disable-gpu-sandbox \
  --ignore-gpu-blocklist

