Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added automated script to switch to old touchbar driver #553

Merged
merged 6 commits into from
Jul 5, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions docs/guides/postinstall.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,122 @@ blacklist cdc_mbim" >> /etc/modprobe.d/blacklist.conf'

Please note that this internal ethernet interface is required for various services including touchid that there currently is no Linux support for. In the future, if any of these services are supported, you'll need to undo this.

# How to use old touchbar driver

Some users want to use `apple-touchbar` driver instead of `tiny-dfr`, here's how to do so:

1. Create and edit the script file: `switch-touchbar-drv.sh`

2. Paste this content:

```bash
#!/bin/bash

# Switching to root
sudo $0

if [ "$EUID" -ne 0 ]; then
exit 1
fi

# Detecting Package Manager
PM_INSTALL=""
PM_REMOVE="null"

if apt --help >/dev/null 2>&1; then
echo "Debian-based OS are not supported!"
echo "Please use 'sudo touchbar --switch' instead."
exit 1
elif dnf >/dev/null 2>&1; then
echo "Fedora-based OS are not supported!"
exit 1
elif pacman -h >/dev/null 2>&1; then
PM_INSTALL="pacman -Sy"
PM_REMOVE="pacman -Rnsu"
else
echo "No valid package manager has been found!"
exit 1
fi

# Checking dependencies
echo "Cheking dependencies..."

if ! command -v git &>/dev/null; then # GIT
echo "git could not be found! Installing..."
$PM_INSTALL git
fi

if ! command -v dkms &>/dev/null; then # DKMS
echo "dkms could not be found! Installing..."
$PM_INSTALL dkms
fi

# SWITCH TO OLD DRIVER
if [[ "$1" == "--old" ]]; then

# Switching to old driver
echo "Switching to old driver..."

# Removing tiny-dfr
$PM_REMOVE tiny-dfr

# Blacklisting new driver
echo "Blacklisting new touchbar driver..."

sh -c 'echo "# Disable new Apple Touchbar driver
angelobdev marked this conversation as resolved.
Show resolved Hide resolved
blacklist hid_appletb_kbd
blacklist hid_appletb_bl" > /etc/modprobe.d/touchbar.conf'

# Installing old driver
echo "Cloning driver repo..."
git clone https://github.com/AdityaGarg8/apple-touchbar-drv /usr/src/apple-touchbar-0.1
dkms install -m apple-touchbar -v 0.1

# SWITCH TO NEW DRIVER
elif [[ "$1" == "--new" ]]; then

# Switching to new driver
echo "Switching to new driver..."

# Installing tiny-dfr
$PM_INSTALL tiny-dfr

# Removing blacklist conf
rm /etc/modprobe.d/touchbar.conf

# Removing old driver
dkms unbuild -m apple-touchbar -v 0.1 -k all
rm -r /usr/src/apple-touchbar-0.1

else

echo "Choose a valid option:"
echo "--new (Switches to the new driver)"
echo "--old (Switches to the old driver)"
exit 1

fi

# DONE!
echo "All done! You can now reboot..."
read -p "Do you want to reboot now? [y/N]" -n 1 -r -s
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Rebooting..."
reboot
fi
```

3. Make the script executable: `chmod +x switch-touchbar-drv.sh`

4. Run the script `./switch-touchbar-drv.sh --old`

!!! note
If you are on a Debian-based distro (e.g Ubuntu) just run `sudo touchbar --switch`

!!! note
If you want to revert changes run `./switch-touchbar-drv.sh --new`

# Suspend Workaround

S3 suspend has been broken since macOS Sonoma, it has never been fixed, but this workaround will make deep suspend work:
Expand Down