Backlight: Difference between revisions

imported>BenSchaeffner
No edit summary
imported>Samueldr
m WIP, cleaning and re-working sections
Line 1: Line 1:
{{expansion}}
{{expansion}}
== Introduction ==
== Introduction ==
This page documents methods for enabling backlight (aka screen brightness) control via hotkeys.
This page documents methods for controlling backlight (aka screen brightness) and tips to control it via hotkeys.


== <code>xbacklight</code> ==
== <code>xbacklight</code> ==
Line 7: Line 7:
<code>xbacklight</code> uses X to change the light settings. This can be inconvenient in some situations, e.g. for use with the {{nixos:option|services.actkbd}} service, which doesn't know about the X session. It, though, has an history of being more compatible with different hardware, especially newer hardware<sup>[citation needed]</sup>
<code>xbacklight</code> uses X to change the light settings. This can be inconvenient in some situations, e.g. for use with the {{nixos:option|services.actkbd}} service, which doesn't know about the X session. It, though, has an history of being more compatible with different hardware, especially newer hardware<sup>[citation needed]</sup>


To enable xbacklight via configuration.nix add:<br />
To install <code>xbacklight</code> globally, add this to your <tt>configuration.nix</tt>.
<code>environment.systemPackages = with pkgs; [ xorg.xbacklight ];</code>
<syntaxhighlight lang=nix>
  environment.systemPackages = with pkgs; [ xorg.xbacklight ];
</syntaxhighlight>
 
Alternatively, use <code>nix-env -iA nixos.xorg.xbacklight</code> to install it to your user profile.


== <code>light</code> ==
== <code>light</code> ==


<code>light</code> does not use X to change the light settings. This can be used in situations where the X service isn't available.</code>
<code>light</code> does not use X to change the light settings. This can be used in situations where the X service isn't available. While it does not use X, it will need some privileges to work. This means that it needs to either be installed in a specific way (with a SUID wrapper) or used using <code>sudo</code>, or ran with superuser privileges.
 
To enable the use of <code>light</code> with SUID wrappers, add this to your <tt>configuration.nix</tt>.
 
<syntaxhighlight lang=nix>
  programs.light.enable = true;
</syntaxhighlight>


To enable light via configuration.nix add:<br />
The following commands will allow you to test <code>light</code>:
<code>programs.light.enable = true;</code>
*<code>light -U 30</code> — the screen should become darker.
*<code>light -A 30</code> — the screen should become brighter.


A reboot may be required.
Be careful using <code>light -U</code>, as you might turn your backlight completely off! You will not be able to see what you're typing anymore.


To test:<p>
== Tips ==
<code> light -U 30</code> - the screen should become darker<br />
<code> light -A 30</code> - the screen should become brighter<br />
Be careful using <code>light -U</code>, as you might turn your backlight completely off, and not see what you're typing any more.


== Key mapping ==
=== Key mapping ===


Once the backend functionality of controlling the backlight is verified, you can assign that to an actual key. Different laptops and keyboards may map the hotkeys to different key codes.
Once the backend functionality of controlling the backlight is verified, you can assign that to an actual key. Different laptops and keyboards may map the hotkeys to different key codes.
Line 66: Line 74:
};</syntaxhighlight>
};</syntaxhighlight>
Tested with NixOS 18.03, and in combination with lightdm & i3.
Tested with NixOS 18.03, and in combination with lightdm & i3.
== Enabling actkbd service ==
== Using <tt>/proc/</tt> ==
<tt>...</tt>


== See also ==
== See also ==


* [https://wiki.archlinux.org/index.php/backlight Arch Linux wiki page about the backlight]
* [https://wiki.archlinux.org/index.php/backlight Arch Linux wiki page about the backlight]