t2linux / T2-Debian-and-Ubuntu-Kernel

Ubuntu Kernel for T2 Macs.
128 stars 14 forks source link

Touchbar stops working after reboot #58

Closed Rom888 closed 8 months ago

Rom888 commented 8 months ago

After this command it starts working: sudo touchbar --restart

$ journalctl --boot=0 | grep tiny-dfr

Oct 26 11:20:53 mb systemd[1]: Started tiny-dfr.service - Tiny Apple silicon touch bar daemon.
Oct 26 11:20:53 mb tiny-dfr[792]: thread 'main' panicked at src/backlight.rs:46:40:
Oct 26 11:20:53 mb tiny-dfr[792]: called `Result::unwrap()` on an `Err` value: No backlight device found
Oct 26 11:20:53 mb tiny-dfr[792]: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Oct 26 11:20:53 mb systemd[1]: tiny-dfr.service: Main process exited, code=exited, status=101/n/a
Oct 26 11:20:53 mb systemd[1]: tiny-dfr.service: Failed with result 'exit-code'.
Oct 26 11:20:53 mb systemd[1]: tiny-dfr.service: Scheduled restart job, restart counter is at 1.
Oct 26 11:20:53 mb systemd[1]: Stopped tiny-dfr.service - Tiny Apple silicon touch bar daemon.
Oct 26 11:20:53 mb systemd[1]: Started tiny-dfr.service - Tiny Apple silicon touch bar daemon.
Oct 26 11:20:53 mb tiny-dfr[847]: thread 'main' panicked at src/backlight.rs:46:40:
Oct 26 11:20:53 mb tiny-dfr[847]: called `Result::unwrap()` on an `Err` value: No backlight device found
Oct 26 11:20:53 mb tiny-dfr[847]: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Oct 26 11:20:53 mb systemd[1]: tiny-dfr.service: Main process exited, code=exited, status=101/n/a
Oct 26 11:20:53 mb systemd[1]: tiny-dfr.service: Failed with result 'exit-code'.
Oct 26 11:20:54 mb systemd[1]: tiny-dfr.service: Scheduled restart job, restart counter is at 2.
Oct 26 11:20:54 mb systemd[1]: Stopped tiny-dfr.service - Tiny Apple silicon touch bar daemon.
Oct 26 11:20:54 mb systemd[1]: tiny-dfr.service: Start request repeated too quickly.
Oct 26 11:20:54 mb systemd[1]: tiny-dfr.service: Failed with result 'exit-code'.
Oct 26 11:20:54 mb systemd[1]: Failed to start tiny-dfr.service - Tiny Apple silicon touch bar daemon.

machine:

macOs: Ventura 13.2

Ubuntu 23.04
6.5.9-t2-lunar

MacBookPro16.1
Intel Core i9 2.3g

hybrid graphics:
Intel UHD graphics 630
AMD radeon pro 5500M
AdityaGarg8 commented 8 months ago

Does running sudo touchbar --restart turn it on?

Rom888 commented 8 months ago

Yes

AdityaGarg8 commented 8 months ago

Run this whole command:

cat <<EOF | sudo tee /etc/systemd/system/system/tiny-dfr.service
[Unit]
Description=Tiny Apple silicon touch bar daemon
After=systemd-user-sessions.service getty@tty1.service plymouth-quit.service systemd-logind.service
StartLimitIntervalSec=30
StartLimitBurst=2

[Service]
ExecStartPre=/bin/sleep 3
ExecStart=/usr/bin/tiny-dfr
Restart=always

[Install]
WantedBy=multi-user.target
EOF

cat <<EOF | sudo tee /usr/share/tiny-dfr/tiny-dfr.service
[Unit]
Description=Tiny Apple silicon touch bar daemon
After=systemd-user-sessions.service getty@tty1.service plymouth-quit.service systemd-logind.service
StartLimitIntervalSec=30
StartLimitBurst=2

[Service]
ExecStartPre=/bin/sleep 3
ExecStart=/usr/bin/tiny-dfr
Restart=always

[Install]
WantedBy=multi-user.target
EOF

sudo touchbar --restart
AdityaGarg8 commented 8 months ago

Then see if this is fixed or not

Rom888 commented 8 months ago

It worked after the first reboot, but didn't work after the second.

AdityaGarg8 commented 8 months ago

again, is is working if you run sudo tiny-dfr after second reboot?

Rom888 commented 8 months ago

sudo tiny-dfr or sudo touchbar --restart ?

AdityaGarg8 commented 8 months ago

Either works

AdityaGarg8 commented 8 months ago

If yes, then try this. Note that it would delay the turning on of touchbar by 7 seconds, so be a bit patient.

cat <<EOF | sudo tee /etc/systemd/system/system/tiny-dfr.service
[Unit]
Description=Tiny Apple silicon touch bar daemon
After=systemd-user-sessions.service getty@tty1.service plymouth-quit.service systemd-logind.service
StartLimitIntervalSec=30
StartLimitBurst=2

[Service]
ExecStartPre=/bin/sleep 7
ExecStart=/usr/bin/tiny-dfr
Restart=always

[Install]
WantedBy=multi-user.target
EOF

cat <<EOF | sudo tee /usr/share/tiny-dfr/tiny-dfr.service
[Unit]
Description=Tiny Apple silicon touch bar daemon
After=systemd-user-sessions.service getty@tty1.service plymouth-quit.service systemd-logind.service
StartLimitIntervalSec=30
StartLimitBurst=2

[Service]
ExecStartPre=/bin/sleep 7
ExecStart=/usr/bin/tiny-dfr
Restart=always

[Install]
WantedBy=multi-user.target
EOF

sudo touchbar --restart
Rom888 commented 8 months ago

no, doesn't work after: sudo touchbar --restart

AdityaGarg8 commented 8 months ago

what does sudo tiny-dfr show.

Rom888 commented 8 months ago

if I run sudo tiny-dfr touchbar stars working but I don't get control back in the terminal, no response

AdityaGarg8 commented 8 months ago

ctrl+c to get control of terminal (this will turn off the touchbar). And run the command I sent which delayed it by 7 seconds

AdityaGarg8 commented 8 months ago

After running that command, restart.

Rom888 commented 8 months ago

it doesn't work after reboot

lemmyg commented 8 months ago

Has stop working after Ubuntu pkg update. Did you try to remove the config in /etc/tiny-drf.conf and reinstall the pkg?

AdityaGarg8 commented 8 months ago

if you do this:

Run sudo systemctl disable --now tiny-dfr

Then restart. The touchbar won't turn on after restart.

Then run sudo systemctl enable --now tiny-dfr and wait for 10 sec, does touchbar turn on?

Rom888 commented 8 months ago

Did you try to remove the config in /etc/tiny-drf.conf and reinstall the pkg?

No

lemmyg commented 8 months ago

Try to remove and reinstall

On Thu, 26 Oct 2023, 5:22 pm Rom888, @.***> wrote:

Did you try to remove the config in /etc/tiny-drf.conf and reinstall the pkg?

No

— Reply to this email directly, view it on GitHub https://github.com/t2linux/T2-Ubuntu-Kernel/issues/58#issuecomment-1781445316, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEFKRHAFFUL5E7RVAEGFBADYBKE3TAVCNFSM6AAAAAA6RNSCZWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBRGQ2DKMZRGY . You are receiving this because you commented.Message ID: @.***>

AdityaGarg8 commented 8 months ago

make sure you remove /etc/tiny-dfr.conf.orj before you reinstall

sudo rm /etc/tiny-dfr.conf.orj
sudo apt remove tiny-dfr
sudo apt autoremove
sudo apt update
sudo apt install tiny-dfr
Rom888 commented 8 months ago

I don't have /etc/tiny-dfr.conf.orj only /etc/tiny-dfr.conf

Rom888 commented 8 months ago

Reinstalled, touchbar starts working then ran sudo systemctl disable --now tiny-dfr then restarted, but the touchbar turned on after restart.

AdityaGarg8 commented 8 months ago

So your problem is fixed now.

Rom888 commented 8 months ago

I reconfigured it using touchbar --mode and after that it doesn't work

$ sudo tiny-dfr
thread 'main' panicked at src/main.rs:620:53:
called `Result::unwrap()` on an `Err` value: TOML parse error at line 11, column 23
   |
11 | [layers.primary_layer = "special"
   |                       ^
invalid table header
expected `.`, `]`

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
alex-007 commented 8 months ago

I see that in the /etc/tiny-dfr.conf the headers of the section doesn't close ']'

[time]
use_24_hr = 1

[layers.primary_layer = "specialextended"
buttons = [
    { label = "F1", key = "Key::F1", mode = "text" },
...
alex-007 commented 8 months ago

BTW reverting back to tiny-dfr to 0.1.3-5 and sudo cp /etc/tiny-dfr.conf.orj /etc/tiny-dfr.conf restores the touchbar after reboot

alex-007 commented 8 months ago

OK. I found the following:

  1. when you install the new tiny-dfr, it puts the new config which is OK
  2. you can change it manually and it immediately shows the changes in the touchbar (I changed the layers.tertiary2_layer_buttons to show F7-F12 buttons for the debugging my applications and it worked)
  3. But when you try to modify the config with help of touchbar (like sudo touchbar --mode) it ruins the config. First 2 sections received the names [layers.primary_layer = "specialextended" and [layers.secondary_layer = "function" (no closing brackets ']')
alex-007 commented 8 months ago

I couldn't find where to put patch for touchbar. So here it is to fix the issue

--- touchbar_old        2023-10-26 16:41:03.569827697 -0400
+++ touchbar    2023-10-26 16:54:20.411835314 -0400
@@ -102,10 +102,10 @@

 echo -e "\nEnter the mode do you want to display by default on the touchbar:"
 get_mode
-sed -i "s/primary_layer.*/primary_layer = \"$mode\"/g" /etc/tiny-dfr.conf
+sed -i "s/primary_layer[ ]*=.*/primary_layer = \"$mode\"/g" /etc/tiny-dfr.conf
 echo -e "\nEnter the mode that you want to be displayed on the touchbar after pressing fn key:"
 get_mode
-sed -i "s/secondary_layer.*/secondary_layer = \"$mode\"/g" /etc/tiny-dfr.conf
+sed -i "s/secondary_layer[ ]*=.*/secondary_layer = \"$mode\"/g" /etc/tiny-dfr.conf
 cat <<EOF
AdityaGarg8 commented 8 months ago

PR over here

https://github.com/AdityaGarg8/t2-ubuntu-repo/blob/main/.github/scripts/touchbar

alex-007 commented 8 months ago

https://github.com/AdityaGarg8/t2-ubuntu-repo/pull/8

AdityaGarg8 commented 8 months ago

Check 0.1.4-2

Rom888 commented 8 months ago

'touchbar --mode' works now

but the touchbar still doesn't work after reboot:

$ journalctl --boot=0 | grep tiny-dfr
Oct 27 08:15:12 mb systemd[1]: Started tiny-dfr.service - Tiny Apple silicon touch bar daemon.
Oct 27 08:15:12 mb tiny-dfr[846]: thread 'main' panicked at src/backlight.rs:46:40:
Oct 27 08:15:12 mb tiny-dfr[846]: called `Result::unwrap()` on an `Err` value: No backlight device found
Oct 27 08:15:12 mb tiny-dfr[846]: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Oct 27 08:15:12 mb systemd[1]: tiny-dfr.service: Main process exited, code=exited, status=101/n/a
Oct 27 08:15:12 mb systemd[1]: tiny-dfr.service: Failed with result 'exit-code'.
Oct 27 08:15:12 mb systemd[1]: tiny-dfr.service: Scheduled restart job, restart counter is at 1.
Oct 27 08:15:12 mb systemd[1]: Stopped tiny-dfr.service - Tiny Apple silicon touch bar daemon.
Oct 27 08:15:12 mb systemd[1]: Started tiny-dfr.service - Tiny Apple silicon touch bar daemon.
Oct 27 08:15:12 mb tiny-dfr[922]: thread 'main' panicked at src/backlight.rs:46:40:
Oct 27 08:15:12 mb tiny-dfr[922]: called `Result::unwrap()` on an `Err` value: No backlight device found
Oct 27 08:15:12 mb tiny-dfr[922]: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Oct 27 08:15:12 mb systemd[1]: tiny-dfr.service: Main process exited, code=exited, status=101/n/a
Oct 27 08:15:12 mb systemd[1]: tiny-dfr.service: Failed with result 'exit-code'.
Oct 27 08:15:12 mb systemd[1]: tiny-dfr.service: Scheduled restart job, restart counter is at 2.
Oct 27 08:15:12 mb systemd[1]: Stopped tiny-dfr.service - Tiny Apple silicon touch bar daemon.
Oct 27 08:15:12 mb systemd[1]: tiny-dfr.service: Start request repeated too quickly.
Oct 27 08:15:12 mb systemd[1]: tiny-dfr.service: Failed with result 'exit-code'.
Oct 27 08:15:12 mb systemd[1]: Failed to start tiny-dfr.service - Tiny Apple silicon touch bar daemon.
Oct 27 08:15:14 mb systemd[1]: tiny-dfr.service: Start request repeated too quickly.
Oct 27 08:15:14 mb systemd[1]: tiny-dfr.service: Failed with result 'exit-code'.
Oct 27 08:15:14 mb systemd[1]: Failed to start tiny-dfr.service - Tiny Apple silicon touch bar daemon.
AdityaGarg8 commented 8 months ago

Let's try this. In case the touchbar is not able to start on boot, it waits for 5 sec and starts it again, and in total makes 5 such attempts. So wait for a min after restarting.

cat <<EOF | sudo tee /etc/systemd/system/system/tiny-dfr.service
[Unit]
Description=Tiny Apple silicon touch bar daemon
After=systemd-user-sessions.service getty@tty1.service plymouth-quit.service systemd-logind.service
StartLimitIntervalSec=500
StartLimitBurst=5

[Service]
ExecStart=/usr/bin/tiny-dfr
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target
EOF

cat <<EOF | sudo tee /usr/share/tiny-dfr/tiny-dfr.service
[Unit]
Description=Tiny Apple silicon touch bar daemon
After=systemd-user-sessions.service getty@tty1.service plymouth-quit.service systemd-logind.service
StartLimitIntervalSec=500
StartLimitBurst=5

[Service]
ExecStart=/usr/bin/tiny-dfr
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo touchbar --restart
Rom888 commented 8 months ago

It started working, but it doesn't work after reboot.

$ journalctl --boot=0 | grep tiny-dfr
Oct 27 08:44:52 mb systemd[1]: Started tiny-dfr.service - Tiny Apple silicon touch bar daemon.
Oct 27 08:44:52 mb tiny-dfr[860]: thread 'main' panicked at src/backlight.rs:46:40:
Oct 27 08:44:52 mb tiny-dfr[860]: called `Result::unwrap()` on an `Err` value: No backlight device found
Oct 27 08:44:52 mb tiny-dfr[860]: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Oct 27 08:44:52 mb systemd[1]: tiny-dfr.service: Main process exited, code=exited, status=101/n/a
Oct 27 08:44:52 mb systemd[1]: tiny-dfr.service: Failed with result 'exit-code'.
Oct 27 08:44:52 mb systemd[1]: tiny-dfr.service: Scheduled restart job, restart counter is at 1.
Oct 27 08:44:52 mb systemd[1]: Stopped tiny-dfr.service - Tiny Apple silicon touch bar daemon.
Oct 27 08:44:52 mb systemd[1]: Started tiny-dfr.service - Tiny Apple silicon touch bar daemon.
Oct 27 08:44:52 mb tiny-dfr[924]: thread 'main' panicked at src/backlight.rs:46:40:
Oct 27 08:44:52 mb tiny-dfr[924]: called `Result::unwrap()` on an `Err` value: No backlight device found
Oct 27 08:44:52 mb tiny-dfr[924]: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Oct 27 08:44:52 mb systemd[1]: tiny-dfr.service: Main process exited, code=exited, status=101/n/a
Oct 27 08:44:52 mb systemd[1]: tiny-dfr.service: Failed with result 'exit-code'.
Oct 27 08:44:52 mb systemd[1]: tiny-dfr.service: Scheduled restart job, restart counter is at 2.
Oct 27 08:44:52 mb systemd[1]: Stopped tiny-dfr.service - Tiny Apple silicon touch bar daemon.
Oct 27 08:44:52 mb systemd[1]: tiny-dfr.service: Start request repeated too quickly.
Oct 27 08:44:52 mb systemd[1]: tiny-dfr.service: Failed with result 'exit-code'.
Oct 27 08:44:52 mb systemd[1]: Failed to start tiny-dfr.service - Tiny Apple silicon touch bar daemon.
Noah4730 commented 8 months ago

Also having same errors with touchbar except it doesn't work at all for me. running Kubuntu.

Host: MacBookPro15,2 1.0 Kernel: 6.1.60-t2-mantic Uptime: 7 mins Packages: 2223 (dpkg) Shell: bash 5.2.15 Resolution: 1680x1050 DE: Plasma 5.27.8 WM: KWin Theme: [Plasma], Breeze [GTK2/3] Icons: [Plasma], breeze [GTK2/3] Terminal: konsole Terminal Font: CaskaydiaCove Nerd Font Mono 13 CPU: Intel i5-8279U (8) @ 4.100GHz GPU: Intel CoffeeLake-U GT3e [Iris Plus Graphics 655] Memory: 2104MiB / 15839MiB

Rom888 commented 8 months ago

after reboot:

$ ls /etc/systemd/system/system/tiny-dfr.service
ls: cannot access '/etc/systemd/system/system/tiny-dfr.service': No such file or directory
AdityaGarg8 commented 8 months ago

after reboot:

$ ls /etc/systemd/system/system/tiny-dfr.service
ls: cannot access '/etc/systemd/system/system/tiny-dfr.service': No such file or directory

Its /etc/systemd/system/tiny-dfr.service

Also, if you want only the F keys and media controls, you can switch to the older mode by sudo touchbar --switch

AdityaGarg8 commented 8 months ago

Also having same errors with touchbar except it doesn't work at all for me. running Kubuntu.

Host: MacBookPro15,2 1.0 Kernel: 6.1.60-t2-mantic Uptime: 7 mins Packages: 2223 (dpkg) Shell: bash 5.2.15 Resolution: 1680x1050 DE: Plasma 5.27.8 WM: KWin Theme: [Plasma], Breeze [GTK2/3] Icons: [Plasma], breeze [GTK2/3] Terminal: konsole Terminal Font: CaskaydiaCove Nerd Font Mono 13 CPU: Intel i5-8279U (8) @ 4.100GHz GPU: Intel CoffeeLake-U GT3e [Iris Plus Graphics 655] Memory: 2104MiB / 15839MiB

You are using an LTS kernel, tiny-dfr won't work on that. Remove it by running sudo apt remove tiny-dfr

After removing, boot into macOS and then back to linux

Rom888 commented 8 months ago

applied this (...systemd/system/tiny...):

cat <<EOF | sudo tee /etc/systemd/system/tiny-dfr.service
[Unit]
Description=Tiny Apple silicon touch bar daemon
After=systemd-user-sessions.service getty@tty1.service plymouth-quit.service systemd-logind.service
StartLimitIntervalSec=500
StartLimitBurst=5

[Service]
ExecStart=/usr/bin/tiny-dfr
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target
EOF

After the first reboot everything is fine

$ journalctl --boot=0 | grep tiny-dfr
Oct 27 08:58:54 mb systemd[1]: Started tiny-dfr.service - Tiny Apple silicon touch bar daemon.

After the second and third reboot it also works:

$ journalctl --boot=0 | grep tiny-dfr
Oct 27 09:04:45 mb systemd[1]: Started tiny-dfr.service - Tiny Apple silicon touch bar daemon.
Oct 27 09:04:45 mb tiny-dfr[833]: thread 'main' panicked at src/backlight.rs:46:40:
Oct 27 09:04:45 mb tiny-dfr[833]: called `Result::unwrap()` on an `Err` value: No backlight device found
Oct 27 09:04:45 mb tiny-dfr[833]: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Oct 27 09:04:45 mb systemd[1]: tiny-dfr.service: Main process exited, code=exited, status=101/n/a
Oct 27 09:04:45 mb systemd[1]: tiny-dfr.service: Failed with result 'exit-code'.
Oct 27 09:04:50 mb systemd[1]: tiny-dfr.service: Scheduled restart job, restart counter is at 1.
Oct 27 09:04:50 mb systemd[1]: Stopped tiny-dfr.service - Tiny Apple silicon touch bar daemon.
Oct 27 09:04:50 mb systemd[1]: Started tiny-dfr.service - Tiny Apple silicon touch bar daemon.
AdityaGarg8 commented 8 months ago

applied this (...systemd/system/tiny...):

cat <<EOF | sudo tee /etc/systemd/system/tiny-dfr.service
[Unit]
Description=Tiny Apple silicon touch bar daemon
After=systemd-user-sessions.service getty@tty1.service plymouth-quit.service systemd-logind.service
StartLimitIntervalSec=500
StartLimitBurst=5

[Service]
ExecStart=/usr/bin/tiny-dfr
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target
EOF

After the first reboot everything is fine

$ journalctl --boot=0 | grep tiny-dfr
Oct 27 08:58:54 mb systemd[1]: Started tiny-dfr.service - Tiny Apple silicon touch bar daemon.

After the second and third reboot it also works:

$ journalctl --boot=0 | grep tiny-dfr
Oct 27 09:04:45 mb systemd[1]: Started tiny-dfr.service - Tiny Apple silicon touch bar daemon.
Oct 27 09:04:45 mb tiny-dfr[833]: thread 'main' panicked at src/backlight.rs:46:40:
Oct 27 09:04:45 mb tiny-dfr[833]: called `Result::unwrap()` on an `Err` value: No backlight device found
Oct 27 09:04:45 mb tiny-dfr[833]: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Oct 27 09:04:45 mb systemd[1]: tiny-dfr.service: Main process exited, code=exited, status=101/n/a
Oct 27 09:04:45 mb systemd[1]: tiny-dfr.service: Failed with result 'exit-code'.
Oct 27 09:04:50 mb systemd[1]: tiny-dfr.service: Scheduled restart job, restart counter is at 1.
Oct 27 09:04:50 mb systemd[1]: Stopped tiny-dfr.service - Tiny Apple silicon touch bar daemon.
Oct 27 09:04:50 mb systemd[1]: Started tiny-dfr.service - Tiny Apple silicon touch bar daemon.

Isn't this the same as I asked you to do before?

Rom888 commented 8 months ago

You asked me this: cat <<EOF | sudo tee /etc/systemd/system/system/tiny-dfr.service

but it looks like it should be: cat <<EOF | sudo tee /etc/systemd/system/tiny-dfr.service

AdityaGarg8 commented 8 months ago

Ooh my bad

AdityaGarg8 commented 8 months ago

Make sure you do /usr/share/tiny-dfr/tiny-dfr.service as well

Rom888 commented 8 months ago

Yes, I just copied it.