You are not logged in.

#1 2022-06-17 04:29:10

hematinik
Member
Registered: 2022-03-23
Posts: 34

[SOLVED] How to set vgaswitcheroo mode to IGD at boot time?

I usually prefer using Integrated graphics on my laptop and after trying all kinds of graphic switching solutions I ended up with the Kernel's vgaswitcheroo and I love it. the problem is that I have to run this command as root every time after startup and then proceed with a logout-login

echo DIGD>/sys/kernel/debug/vgaswitcheroo/switch

I could not find a way to set this mode as default at boot so I don't have to do that every time. could somebody please help me on how to do that?

Last edited by hematinik (2022-06-19 07:35:39)

Offline

#2 2022-06-17 08:12:44

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,650

Re: [SOLVED] How to set vgaswitcheroo mode to IGD at boot time?

You could use sysctl configs should be

kernel.debug.vgaswitcheroo.switch = 1

but check with sysctl -a first if this is even exposed.

If it isn't you could make a systemd service that just runs this, e.g. /etc/systemd/service/switchtoIGPU.service

[Unit]
Description=Switching to igpu service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/sh -c "echo DIGD > /sys/kernel/debug/vgaswitcheroo/switch"
[Install]
WantedBy=multi-user.target

and enable with

systemctl enable switchtoIGPU.service

Offline

#3 2022-06-18 11:31:03

hematinik
Member
Registered: 2022-03-23
Posts: 34

Re: [SOLVED] How to set vgaswitcheroo mode to IGD at boot time?

Thank you @V1del for your consideration, I tried the systemd approach and it didn't work. I could confirm that I'm still on the discrete graphics using `glxheads` and the following command:

cat /sys/kernel/debug/vgaswitcheroo/switch

I noticed that you suggested "/etc/systemd/service/switchtoIGPU.service" instead of "/etc/systemd/system/switchtoIGPU.service" I guess? because in that case `systemctl` would not be able to find the service.

Offline

#4 2022-06-18 11:46:03

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,650

Re: [SOLVED] How to set vgaswitcheroo mode to IGD at boot time?

a whoops yeah a typo on my part, did you check the service status? It is possible that the command runs before the vgaswitcheroo file node is present in which case you might have to delay execution with an explicit sleep or so

Offline

#5 2022-06-19 07:34:16

hematinik
Member
Registered: 2022-03-23
Posts: 34

Re: [SOLVED] How to set vgaswitcheroo mode to IGD at boot time?

You are a lifesaver Sir! adding sleep did the trick. this is the modified service in case anyone might find helpful in future:

# /etc/systemd/system/switchtoIGPU.service
[Unit]
Description=Switching to igpu service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/sh -c "sleep 5 && echo DIGD>/sys/kernel/debug/vgaswitcheroo/switch"
[Install]
WantedBy=multi-user.target

Note: the 5 seconds is an overkill for sure, I'd go with 1 or 2 personally so you can decrease the delay and see how things go.

Offline

Board footer

Powered by FluxBB