Switching from integrated to dedicated gpu

Hello everyone.

Unfortunately i am an unproud owner of an Nvidia RTX 2070. Fortunately, i also own an Intel i5 with onboard graphics. For some time, i was using the RTX with proprietary drivers. But because Xorg doesnt like scaling on my 4K display i enabled Wayland with gnome. Which wasn’t a very good experience.
So i was looking for a way to switch from using Wayland with onboard Graphics for daily driving, and using Xorg with my RTX for gaming. After a long time of trying and a lot of help from a friend i found the following solution:
We created two modified xorg.conf files with different names. One using onboard graphics, and one using the RTX.
Then we modified my .zshrc with two aliases, which create a symlink between the original and the modified config files. Gdm gets restarted using the modified config file. From there i can log into either Gnome with Wayland (using onboard graphics), or Icewm with Xorg (using the RTX).
This solution seems to work well enough, but is a bit cumbersome. Because as i start the PC i have to check if Wayland or Xorg is active (I can do that by checking which input the display uses)
And when i want to switch from normal work to gaming or the other way round, i have to type in the alias, switch the window manager in the login screen and log in again.
Can anyone think of a more elegant solution?

Thanks a lot guys.
.
Here are the contents of my .zshrc:

USE_POWERLINE="true"
# Source manjaro-zsh-configuration
if [[ -e /usr/share/zsh/manjaro-zsh-config ]]; then
  source /usr/share/zsh/manjaro-zsh-config
fi
# Use manjaro zsh prompt
if [[ -e /usr/share/zsh/manjaro-zsh-prompt ]]; then
  source /usr/share/zsh/manjaro-zsh-prompt
fi

function _use_nvidia
{
sudo ln -svf /etc/X11/xorg.conf{.nvidia,}
sudo /usr/lib/gdm-runtime-config set daemon WaylandEnable false
sudo /usr/lib/gdm-runtime-config set daemon PreferredDisplayServer xorg
sudo systemctl restart display-manager
}

function _use_intel
{
sudo ln -svf /etc/X11/xorg.conf{.intel,}
sudo /usr/lib/gdm-runtime-config set daemon WaylandEnable true
sudo /usr/lib/gdm-runtime-config set daemon PreferredDisplayServer wayland
sudo systemctl restart display-manager
}

alias xorgnvidia="_use_nvidia"
alias xorgintel="_use_intel"

alias gaming="_use_nvidia"
alias productive="_use_intel"

Increase your chances of solving your issue:

Provide Information:

Did you try/use the hybrid Intel/Nvidia driver, which should give you Intel as main GPU and Nvidia as offloading GPU when asked (for example in Steam games)?

Hi. Thanks for your reply.
I did use the video-hybrid-intel-nvidia-prime driver, and it did work well on Xorg.
But in Wayland certain games wouldn’t start. And Wayland was buggy and unstable.

I might try to automate the process further. Get the script to automatically log into the new session.

I am a newbie and i am currently using Manjaro Gnome…need some help regarding GPU…can you help me?

Might be better starting a new thread and list your full system info and if you are using wayland or xorg. Think your card is supported by at least the 470 driver so nvidia prime should work for you