ewagner12 / all-ways-egpu

Configure eGPU as primary under Linux Wayland desktops
MIT License
170 stars 11 forks source link

all-ways-egpu

Configures eGPU as primary under Linux Wayland desktops.

Note this script is not designed to replace existing solutions such as gswitch or egpu-switcher. If you have an Xorg based desktop, these solutions are still the best option and should be preferred over this script. For more info on why this script exists and how it works, see the wiki.

Installation:

Releases (Recommended):

Download and install the latest release using the following one line command:

cd ~; curl -qLs  https://github.com/ewagner12/all-ways-egpu/releases/latest/download/all-ways-egpu.zip  -o all-ways-egpu.zip; unzip all-ways-egpu.zip; cd all-ways-egpu-main; chmod +x install.sh; sudo ./install.sh install; cd ../; rm -rf all-ways-egpu.zip all-ways-egpu-main

If the above command fails due to a non-writable /usr then go to the next section below.

Steam Deck/User Installation:

This following installation method is specifically for those using Steam Deck/SteamOS 3.0 or any other distro (such as Fedora Silverblue) where the system files are read-only:

cd ~; curl -qLs  https://github.com/ewagner12/all-ways-egpu/releases/latest/download/all-ways-egpu.zip  -o all-ways-egpu.zip; unzip all-ways-egpu.zip; cd all-ways-egpu-main; chmod +x install.sh; sudo ./install.sh user-install; cd ../; rm -rf all-ways-egpu.zip all-ways-egpu-main

Note that running the command above adds ~/bin to your path in Bash. If using a different shell be sure to add ~/bin to your path in your shell.

Git

Clone the repo to get the latest from github:

git clone https://github.com/ewagner12/all-ways-egpu.git

To install/uninstall navigate to the downloaded location and run the install.sh script:

cd all-ways-egpu
chmod +x install.sh; sudo ./install.sh install

Uninstallation:

all-ways-egpu uninstall

Usage:

As of version 0.30+ all functions can also be accessed through a menu system by simply clicking on the icon in your application menu or using the command all-ways-egpu. It is recommended to setup using option 1 and then switch to the eGPU using option 4 (Method 2). You may try out each of the methods to see which one works best for you.

If you want to skip the menu system, the following terminal commands can also be used. To setup the script based on your hardware:

all-ways-egpu setup

Method 1: Force iGPU off (Legacy/Alternate Method)

To enable forcing the chosen iGPU devices off (so that the display manager uses the eGPU)

all-ways-egpu configure egpu

To disable forcing the chosen iGPU devices off

all-ways-egpu configure internal

Method 2: Switch boot_vga (Recommended Method)

This method simply switches the boot_vga indicator flag that many Wayland compositors use in choosing the primary GPU. This is a less extreme method that may work better or have fewer side effects for some than Method 1. However, further testing is required to ensure it will work with any particular Wayland compositor. Currently, GNOME's mutter, Sway's wl_roots and KDE Plasma's KWin seem to work with this method in my testing.

all-ways-egpu set-boot-vga egpu

additional info can be found using the help flag.

Method 3: Set Compositor Variables (Desktop Specific)

This method sets the variables specifically used by the compositors mutter (GNOME), KWin (KDE Plasma), and wlroots (Sway and others). This hints to these desktops to use the eGPU as primary. This only works on those compositors specifically and may not always force applications to use the eGPU. This method may be combined with Method 2.

Currently this method is most useful for GNOME when Method 2 doesn't work.

all-ways-egpu set-compositor-primary egpu

Extra Steps:

If the option "Attempt to re-enable these iGPU/initially disabled devices after boot" is chosen in the setup, after logging in, the script will prompt for your password each time to attempt to re-enable the iGPU (if not already done).

Given Polkit version >= 0.106 (check with pkaction --version) the password prompt can be bypassed by adding the following:

Create file: /etc/polkit-1/rules.d/57-manage-egpu.rules

with following contents: (replace user-name with your specific login username as given by the command: whoami)

// Allow user-name to manage all-ways-egpu-user.service;
// fall back to implicit authorization otherwise.
polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.systemd1.manage-units" &&
        action.lookup("unit") == "all-ways-egpu-user.service" &&
        subject.user == "user-name") {
        return polkit.Result.YES;
    }
});

For Polkit version < 0.106:

Create file: /etc/polkit-1/localauthority/50-local.d/57-manage-egpu.pkla

with the following contents: (replace group-name with your specific group as given by the command: id -g -n $USER)

[User permissions]
Identity=unix-group:group-name
Action=org.freedesktop.systemd1.manage-units
ResultActive=yes

Other Potential Issues: