Skip to content

Commit 0b70fb8

Browse files
authored
Added automated script to switch to old touchbar driver (#553)
1 parent e7a65c1 commit 0b70fb8

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

docs/guides/postinstall.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,125 @@ blacklist cdc_mbim" >> /etc/modprobe.d/blacklist.conf'
142142
143143
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.
144144

145+
# How to use old touchbar driver
146+
147+
Some users want to use `apple-touchbar` driver instead of `tiny-dfr`, here's how to do so:
148+
149+
1. Create and edit the script file: `switch-touchbar-drv.sh`
150+
151+
2. Paste this content:
152+
153+
```bash
154+
#!/bin/bash
155+
156+
# Switching to root
157+
sudo $0
158+
159+
if [ "$EUID" -ne 0 ]; then
160+
exit 1
161+
fi
162+
163+
# Detecting Package Manager
164+
PM_INSTALL=""
165+
PM_REMOVE="null"
166+
167+
if apt --help >/dev/null 2>&1; then
168+
echo "Debian-based OS are not supported!"
169+
echo "Please use 'sudo touchbar --switch' instead."
170+
exit 1
171+
elif dnf >/dev/null 2>&1; then
172+
echo "Fedora-based OS are not supported!"
173+
exit 1
174+
elif pacman -h >/dev/null 2>&1; then
175+
PM_INSTALL="pacman -Sy"
176+
PM_REMOVE="pacman -Rnsu"
177+
else
178+
echo "No valid package manager has been found!"
179+
exit 1
180+
fi
181+
182+
# Checking dependencies
183+
echo "Cheking dependencies..."
184+
185+
if ! command -v git &>/dev/null; then # GIT
186+
echo "git could not be found! Installing..."
187+
$PM_INSTALL git
188+
fi
189+
190+
if ! command -v dkms &>/dev/null; then # DKMS
191+
echo "dkms could not be found! Installing..."
192+
$PM_INSTALL dkms
193+
fi
194+
195+
# SWITCH TO OLD DRIVER
196+
if [[ "$1" == "--old" ]]; then
197+
198+
# Switching to old driver
199+
echo "Switching to old driver..."
200+
201+
# Removing tiny-dfr
202+
$PM_REMOVE tiny-dfr
203+
204+
# Blacklisting new driver
205+
echo "Blacklisting new touchbar driver..."
206+
207+
cat <<- EOF > /etc/modprobe.d/touchbar.conf
208+
# Disable new Apple Touchbar driver
209+
blacklist appletbdrm
210+
blacklist hid_appletb_kbd
211+
blacklist hid_appletb_bl
212+
EOF
213+
214+
# Installing old driver
215+
echo "Cloning driver repo..."
216+
git clone https://github.com/AdityaGarg8/apple-touchbar-drv /usr/src/apple-touchbar-0.1
217+
dkms install -m apple-touchbar -v 0.1
218+
219+
# SWITCH TO NEW DRIVER
220+
elif [[ "$1" == "--new" ]]; then
221+
222+
# Switching to new driver
223+
echo "Switching to new driver..."
224+
225+
# Installing tiny-dfr
226+
$PM_INSTALL tiny-dfr
227+
228+
# Removing blacklist conf
229+
rm /etc/modprobe.d/touchbar.conf
230+
231+
# Removing old driver
232+
dkms unbuild -m apple-touchbar -v 0.1 -k all
233+
rm -r /usr/src/apple-touchbar-0.1
234+
235+
else
236+
237+
echo "Choose a valid option:"
238+
echo "--new (Switches to the new driver)"
239+
echo "--old (Switches to the old driver)"
240+
exit 1
241+
242+
fi
243+
244+
# DONE!
245+
echo "All done! You can now reboot..."
246+
read -p "Do you want to reboot now? [y/N]" -n 1 -r -s
247+
echo
248+
if [[ $REPLY =~ ^[Yy]$ ]]; then
249+
echo "Rebooting..."
250+
reboot
251+
fi
252+
```
253+
254+
3. Make the script executable: `chmod +x switch-touchbar-drv.sh`
255+
256+
4. Run the script `./switch-touchbar-drv.sh --old`
257+
258+
!!! note
259+
If you are on a Debian-based distro (e.g Ubuntu) just run `sudo touchbar --switch`
260+
261+
!!! note
262+
If you want to revert changes run `./switch-touchbar-drv.sh --new`
263+
145264
# Suspend Workaround
146265
147266
S3 suspend has been broken since macOS Sonoma, it has never been fixed, but this workaround will make deep suspend work:

0 commit comments

Comments
 (0)