Choose Optimus Switch GPU while booting

Hello
I have an Optimus Lapto(AMD+Nvidia), and I was thinking fi there is any way for me to add GPU selection while booting. If I am on adapter I can choose Hybrid/Nvidia, but on battery I would like to boot to integrated only.

1 Like

You could add a systemd unit that triggers during boot, checks whether you are on battery or not, and runs the specific command you use to choose the specific setup.

5 Likes

You could add a systemd unit that triggers during boot, checks whether you are on battery or not, and runs the specific command you use to choose the specific setup.

I am not so proficient with what this is and how I should do so. What I thought was there is an option to set boot options with kernel boot parameter to choose, but I have no idea how to add custom boot entries.

What @jonathon is referring to is, writing a systemd service to run the commands automatically for you at system start up.

https://wiki.archlinux.org/index.php/Systemd

Wrting a service that runs at startup is fairly simple. It would then launch a script to check if you are on battery, and switch adapters if you are.

Have you done any significant amount of searching on this issue?

If you search thoroughly you may find someone has already written something similar to address this issue already.

1 Like

I do not think that would work, since this app changes the GPU by completely killing the X server and changing the xorg config. Using a systemd service would kind of slow it down, would it not?

Which app?

I would not think this would require a very complex script to execute the commands you would require. I think you are underestimating the speed of modern computers.

A systemd service runing a simple script executes pretty much in the blink of an eye. I can’t see it adding any significant delay to the boot process.

Again:

If you search you may find someone has already done this for you. If you’re waiting for us to do your searching you could find that a long wait. Generally, those who help themselves find the most success here (as in life).

1 Like

optimus-manager

Depending how you install it.
Current AUR package version is not compatible with AMD/nvidia combination yet.
The master branch of the application is compatible with AMD/nvidia, but you have to install it manually, according to their installation instructions.

This app provides a kernel boot parameter for the (optimus-manager) startup mode, that you can add in grub default settings, although I don't see (from quick review) a method to provide 2-3 entries, each for one mode.
But the same thing can be accomplished with standard usage features (change mode and reboot).

1 Like

Current AUR package version is not compatible with AMD/nvidia combination yet.
The master branch of the application is compatible with AMD/nvidia, but you have to install it manually, according to their installation instructions.

I am on the optimus-manager-git version which supports AMD and Nvidia.

This app provides a kernel boot parameter for the (optimus-manager) startup mode, that you can add in grub default settings, although I don’t see (from quick review) a method to provide 2-3 entries, each for one mode.

Yes I know there is a kernel boot parameter, that is why I wanted to know how do I add duplicate entries in GRUB. I never did it before so I wanted to know if it was possible to do so.

Manually only. After each time grub is generated, you may edit grub.cfg to clone an entry and edit to add a second option.

For automatic (one time set) you may ask the developer, if they have some advice.

Of course, you can edit grub command line params when booting, adding your specific option.

3 Likes

After each time grub is generated, you may edit grub.cfg to clone an entry and edit to add a second option.

So this grub.cfg can be edited to make duplicate entries? Sweet.
I have used rEFInd till date, no much idea about GRUB.

It doesn’t make things easier, since grub.cfg is auto-generated after each btrfs snapshot (package install, upgrade, uninstall).

2 Likes