Brightness Control with Nvidia Optimus on Ubuntu
Tags: ubuntu, linux, productivity, troubleshooting
Published: 2019-07-09 20:37:57

---
title: Brightness Control with Nvidia Optimus on Ubuntu
published: true
description: You can have one but not the other (as far as I know)
tags: ubuntu, linux, productivity, troubleshooting
---

Having recently installed [Pop!_OS](https://system76.com/pop) (an Ubuntu derivative) in a dual boot setup for my laptop, I've found that it has been a nearly painless experience, especially since the proprietary NVIDIA drivers come pre-installed. 

However, one of the issues that I've found in my installation is the lack of brightness control via keyboard. Interestingly enough, hitting `Fn+F3` or `Fn+F4` (which normally would decrease/increase the screen brightness on Windows for me) does nothing on Linux, while the volume controls (`Fn+F9` and `Fn+F10` for me) did what they needed to without a hiccup.

So what was happening? After writing this post, I still have no idea.

#Fixing the Backlight Issue
One of the "fixes" that I found was adding a configuration file for the X11 server to work with my integrated Intel graphics. I will outline below, perhaps it'll help someone else with better hardware support.

I downloaded [`xbacklight`](https://linux.die.net/man/1/xbacklight) through `apt`, and followed the short guide found on [It's FOSS](https://itsfoss.com/fix-brightness-ubuntu-1310/), which I'll outline below:
####NOTE: this fix is for those with integrated graphics from Intel.
Create the config file for the X server to use.
`sudo touch /usr/share/X11/xorg.conf.d/20-intel.conf`
Open it in a text editor.
`sudo gedit /usr/share/X11/xorg.conf.d/20-intel.conf`
And add the following in the file:
```
Section "Device"
        Identifier  "card0"
        Driver      "intel"
        Option      "Backlight"  "intel_backlight"
        BusID       "PCI:0:2:0"
EndSection
```
Log out and back in (and possibly restart your system), and the `xbacklight` commands should work as intended
##Bonus
Try adding keyboard shortcuts for `xbacklight -dec <percent>` and `xbacklight -inc <percent>`. I recreated my brightness controls to run `xbacklight -10` and `xbacklight +10` to decrease/increase the brightness by 10% each time.

---

#But wait, why are my games running so poorly?
As it turns out, I lost the ability to use my NVIDIA graphics card after this fix.

After I did the above fix, I went to play some graphic-intensive games, that I knew worked prior when using the NVIDIA card, and found them running at a snail's pace, almost as if *they were using integrated graphics.*

But `system76-power` (Pop!_OS' graphics switcher) shows that I'm using my dedicated graphics card. What's going on?

Opening up `nvidia-settings` through the terminal shows an error (aside from the seemingly ubiquitous GTK errors) along with an empty GUI: 
```
ERROR: Unable to load info from any available system
```

Well that can't be good right?

Now, I didn't want to install other graphic switchers (i.e. `bumblebee`, NVIDIA Prime) because attempting to replace the `system76-power` package results in the entire desktop environment trying to uninstall itself, and I'm not quite ready to live in a terminal-only Linux world. What else could I do?

---

#It's a Trade-Off
Turns out, as you can probably already guess, that including that `20-intel.conf` file for the X server stopped my NVIDIA card from functioning in a way that `system76-power` didn't notice.

To be sure, I reinstalled the distribution (Thankfully, I had set my home directory to live in a separate partition) and repeated my steps. I then deleted the `20-intel.conf` file from where I created it, and rebooted.

The results? My graphics card was back in action, and the games I tested worked flawlessly. But I no longer had the ability to tweak the brightness outside of using the slider in the system status menu.

---

#Looking Forward
There were plenty of other possible fixes, like [overwriting the kernel parameter for brightness](https://askubuntu.com/questions/428467/brightness-in-ubuntu-12-04), that isn't something I'm too keen to do; I still need a couple layers of abstraction to feel comfortable fiddling with my system. I will, however, be trying out some of the answers in this [StackOverflow answer](https://askubuntu.com/questions/1034305/brightness-problem-ubuntu-18-04-lts). Maybe the GRUB editing will end up working for me.


Let me know what you think, and perhaps leave some possible fixes in the comments!