diff --git a/README.md b/README.md index 544e7e2..d4bd250 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,14 @@ 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. Automatic switching at bootup is not available with this type of installation so the script must be run by the user after login to switch to the eGPU (see Usage section below). +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: @@ -26,13 +27,9 @@ 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: +To install/uninstall navigate to the downloaded location and run the install.sh script: ``` cd all-ways-egpu -``` - -Install: -``` chmod +x install.sh; sudo ./install.sh install ``` diff --git a/all-ways-egpu b/all-ways-egpu index 9f7fd59..fbd46cf 100644 --- a/all-ways-egpu +++ b/all-ways-egpu @@ -1,6 +1,6 @@ #!/usr/bin/env sh -VERSION=0.51.2 +VERSION=0.52.0 BINDIR=/usr/bin USER_IDS_DIR=/usr/share/all-ways-egpu CONFDIR=/etc/all-ways-egpu @@ -90,7 +90,7 @@ setupAutostart() { fi if [ "${1}" -eq 1 ]; then - echo "Note startup files will use system configuration, not user configuration" + echo "Note startup files will use first user's configuration" fi echo "Recommended if using Method 1: Attempt to re-enable the iGPU/initially disabled devices after login? [y/N]" @@ -702,6 +702,17 @@ if [ "$SUDO_USER" != "" ]; then EGPU_IDS="$USER_IDS_DIR"/egpu-bus-ids RETRY_FILE="$USER_IDS_DIR"/max-retry fi +else + # when run as root uses first user config if one is found. To override, specify user instead of * in next line + for HD in /home/*/.config; do + if [ -e "$HD"/all-ways-egpu/egpu-bus-ids ] || [ -e "$HD"/all-ways-egpu/user-bus-ids ]; then + USER_IDS_DIR="$HD"/all-ways-egpu + PCI_DEV="$USER_IDS_DIR"/user-bus-ids + EGPU_IDS="$USER_IDS_DIR"/egpu-bus-ids + RETRY_FILE="$USER_IDS_DIR"/max-retry + break + fi + done fi # sanity check Bus IDs format in existing files diff --git a/all-ways-egpu-reenable.desktop b/all-ways-egpu-reenable.desktop index be64b83..f2a4974 100644 --- a/all-ways-egpu-reenable.desktop +++ b/all-ways-egpu-reenable.desktop @@ -5,7 +5,7 @@ Comment=Re-enables iGPU after setting eGPU as primary for Wayland desktops Exec=systemctl start all-ways-egpu-user.service Terminal=false Type=Application -Version=0.51.2 +Version=0.52.0 Categories=System;Settings;Utility; Keywords=system;hardware; diff --git a/all-ways-egpu.desktop b/all-ways-egpu.desktop index f3ee440..ff72434 100644 --- a/all-ways-egpu.desktop +++ b/all-ways-egpu.desktop @@ -5,7 +5,7 @@ Comment=Script for setting eGPU as primary for Wayland desktops Exec=all-ways-egpu Terminal=true Type=Application -Version=0.51.2 +Version=0.52.0 Categories=System;Settings;Utility; Keywords=system;hardware; diff --git a/install.sh b/install.sh index b235d76..1d03b42 100755 --- a/install.sh +++ b/install.sh @@ -4,32 +4,41 @@ DESTDIR= BINDIR=/usr/bin CONFDIR=/etc/all-ways-egpu +initServices() { + # check if using systemd or openrc + if [ -e "$(command -v systemctl)" ]; then + cp systemd/all-ways-egpu.service "${DESTDIR}"${CONFDIR} + cp systemd/all-ways-egpu-user.service "${DESTDIR}"${CONFDIR} + cp systemd/all-ways-egpu-boot-vga.service "${DESTDIR}"${CONFDIR} + cp systemd/all-ways-egpu-shutdown.service "${DESTDIR}"${CONFDIR} + cp systemd/all-ways-egpu-set-compositor.service "${DESTDIR}"${CONFDIR} + cp all-ways-egpu-reenable.desktop "${DESTDIR}"${CONFDIR} + else + if [ -e "$(command -v rc-status)" ]; then + cp OpenRC/all-ways-egpu-openrc "${DESTDIR}"${CONFDIR} + cp OpenRC/all-ways-egpu-boot-vga-openrc "${DESTDIR}"${CONFDIR} + cp OpenRC/all-ways-egpu-set-compositor-openrc "${DESTDIR}"${CONFDIR} + fi + fi +} + case $1 in install) mkdir -p "${DESTDIR}"${BINDIR} cp all-ways-egpu "${DESTDIR}"${BINDIR} chmod +x "${DESTDIR}"${BINDIR}/all-ways-egpu mkdir -p "${DESTDIR}"${CONFDIR} - # check if using systemd or openrc - if [ -e "$(command -v systemctl)" ]; then - cp systemd/all-ways-egpu.service "${DESTDIR}"${CONFDIR} - cp systemd/all-ways-egpu-user.service "${DESTDIR}"${CONFDIR} - cp systemd/all-ways-egpu-boot-vga.service "${DESTDIR}"${CONFDIR} - cp systemd/all-ways-egpu-shutdown.service "${DESTDIR}"${CONFDIR} - cp systemd/all-ways-egpu-set-compositor.service "${DESTDIR}"${CONFDIR} - cp all-ways-egpu-reenable.desktop "${DESTDIR}"${CONFDIR} - else - if [ -e "$(command -v rc-status)" ]; then - cp OpenRC/all-ways-egpu-openrc "${DESTDIR}"${CONFDIR} - cp OpenRC/all-ways-egpu-boot-vga-openrc "${DESTDIR}"${CONFDIR} - cp OpenRC/all-ways-egpu-set-compositor-openrc "${DESTDIR}"${CONFDIR} - fi - fi + initServices cp all-ways-egpu.desktop "${DESTDIR}"/usr/share/applications ;; user-install) set -- "${DESTDIR}"/home/* + # Init services hard coded to first user path + sed -i 's,=all-ways-egpu,='"$1"'\/bin\/all-ways-egpu,' systemd/*.service + sed -i 's,="all-ways-egpu",="'"$1"'\/bin\/all-ways-egpu\",' OpenRC/*-openrc + mkdir -p "${DESTDIR}"${CONFDIR} + initServices for HD in "$@"; do mkdir -p "$HD"/bin cp all-ways-egpu "$HD"/bin