gswitch
gswitch copied to clipboard
gswitch not detecting thunderbolt at start
System76 Oryx Pro Manjaro Linux 5.10.32-1-MANJARO
When logging onto the system, it defaults to internal dGPU. During install, I ran:
sudo systemctl enable gswitch
Verified that the service was running with
sudo systemctl status gswitch
Service shows inactive but that the service does run on startup as shown in this:
Apr 30 18:33:19 OryxPro-Manjaro systemd[1]: Started Automatic GPU switching service.
Apr 30 18:33:20 OryxPro-Manjaro gswitch[17231]: You are already set up. Would you like to reload? (Y/n)
Apr 30 18:33:20 OryxPro-Manjaro systemd[1]: gswitch.service: Succeeded.
I'm not entirally sure if this is an issue on your end or my computers end as it does appear that the service ran without issue and it would have switched to my eGPU, however I have to then go in and manually run:
sudo gswitch egpu
Only after running above command does my pc switch.
I have recently come from Pop!_OS and this wasn't an issue.
Same thing happens for me, almost.
- If I booted with out the eGPU before, and I'm booting now with eGPU, gswitch works fine and both egpu-connected monitors are activated
- If I booted with eGPU before, and booting now with eGPU then it doesn't work. I land on an error message that
lightdm couldn't load
on the terminal -
- I need to go to TTY1, run
gswitch egpu
to activate the first monitor
- I need to go to TTY1, run
-
- get back to TTY1 and run it again for the second monitor
- If I booted with eGPU before and I'm now with out it connected, the laptop monitor works as expected.
It's not a big issue, I'm used to it every morning I boot up the office, but it would be nice to figure out how to solve this.
I guess it's worth mentioning I'm running lightdm
using Debian. The issue remains throughout the years in every debian stable/testing version and all kernels (currently on 6.4).
# systemctl status gswitch
○ gswitch.service - Automatic GPU switching service
Loaded: loaded (/etc/systemd/system/gswitch.service; enabled; preset: enabled)
Active: inactive (dead) since Mon 2023-09-04 08:36:32 EEST; 14min ago
Duration: 471ms
Main PID: 1402 (code=exited, status=0/SUCCESS)
CPU: 165ms
Σεπ 04 08:36:31 dragoon systemd[1]: Started gswitch.service - Automatic GPU switching service.
Σεπ 04 08:36:32 dragoon gswitch[1713]: find: ‘/sys/bus/pci/devices/0000:0b:00.0/drm/card*/card*’: No such file or directory
Σεπ 04 08:36:32 dragoon gswitch[1578]: You are already set up. Would you like to reload? (Y/n)
Σεπ 04 08:36:32 dragoon systemd[1]: gswitch.service: Deactivated successfully.
@bserem Hey man, thanks for the status message! That's so weird because in that case gswitch doesn't really do anything. When you boot with the service it defaults to assuming you don't have the eGPU plugged in. It then checks which PCI devices are matching 'vga' and then checks if any of those match the one you have entered in your config. If it finds the card from your config it looks to see whether the config is linked in place (which it should be since you had it before shutting down) and then doesn't do anything. Maybe that's too fast for your laptop?
Try this:
gswitch.patch
--- /usr/bin/gswitch 2021-11-01 10:51:09.000000000 +0100
+++ /usr/bin/gswitch 2023-09-04 10:53:18.721294645 +0200
@@ -186,6 +186,7 @@
switch_internal
;;
boot)
+ sleep 5
MODE="internal"
for HEX_ID in $(lspci | grep -i 'vga' | cut -f 1 -d ' '); do
DEC_ID=""
Adding a delay didn't change anything. Thanks for the hint though.
I'm not sure why it doesn't files the card*/card*
file when it boots by it does work when I run it manually. Nor why I have to run it twice for the second monitor to wake up.
But like I said, it's a minor thing. Booting up in the morning takes a bit more and that's it. Other than that your script is a lifesaver and I've been using it for more than a year now.
Thanks!
Did you try setting the delay something more extreme, like 60 seconds? Just to rule it out. Why it doesn't find any files could be because they haven't appeared yet in the boot process. SystemD is very aggressive with firing off everything it can as fast as inhumanly possible :smile: There's also the possibility that no matter the delay the files will always appear after gswitch
has run and that could be why it works when you run it manually again afterwards.
And you have to run it AGAIN to wake up your second monitor!? What the heck!? Xorg being Xorg maybe? Man that sucks, I'd really like to understand why your laptop behaves that way, the machines I've had never had any issues. I've never tested it on Debian either, only Ubuntu and OpenSUSE. But you know what, I have a spare drive I can install that on! I'll get back to you once I've tested it on my hardware. It might not be much but at least it's something.
I'd hate to put you through that, honestly :)
I'm using an old T480s thinkpad with a Sonnet Puck eGPU. It is an old (by new standards) machine, so it might as well be it. However, if I boot without the egpu and then boot with it connected, everything works (dual monitors too).
Something fancy, or it could be something that I broke when I first got the egpu and before finding your repo. Sadly I don't have spares with thunderbolt.
ps: that was a very accurate description of systemd
That's not any older than the laptops I've run it on; ThinkPad P50, t470s and x280 with an Akitio Node and Razer Core X so it should just work ™
Well you can't stop me! Besides I haven't installed Debian on a laptop in a long time, it'll be fun!
It is with great regret and much delight that I can report that Debian 12 works out of the box (on my computer™) with gswitch
! :upside_down_face: In fact it's what I'm writing from right now!
This is a clean install with KDE and as such uses SDDM as display manager instead of LightDM and I followed my own (bad) practice of authorizing all Thunderbolt devices that are plugged in with the udev
rule explained in the README.
It was a little finicky at first- like SDDM was by default set to Wayland now- so I had to log out and change to Xorg. Then when I had logged in and wanted to shutdown the shutdown button didn't do anything- none of them (Sleep,Hibernate,Restart,Shutdown,Log out) did- so I had to systemctl halt
it but after next boot I tried the buttons again and it worked. All of my three monitors worked right off the bat, I just had to set their placement and priority and after shutdown (or reboot) and startup everything comes back up as it should.
I'll try other DMs and check my udev rules. Hopefully I can avoid installing the OS from scratch (I can't recall if this started as debian9 or debian10).
I have Manjaro 23 and after installing gswitch,
egpu did not switch, but when execute the gswitch boot
command, the system switches to the external card.
For me it worked after adding After=multi-user.target
in the service.
[Unit]
Description=Automatic GPU switching service
After=multi-user.target
[Service]
ExecStart=/usr/bin/gswitch boot
[Install]
WantedBy=graphical.target