<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Niklas Zantner</title>
    <description>The latest articles on DEV Community by Niklas Zantner (@niklaszantner).</description>
    <link>https://dev.to/niklaszantner</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F380980%2Fb1a0c1ad-64c3-4af1-8c71-d6357189f4e7.jpeg</url>
      <title>DEV Community: Niklas Zantner</title>
      <link>https://dev.to/niklaszantner</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/niklaszantner"/>
    <language>en</language>
    <item>
      <title>Enable the fingerprint reader on a t480s </title>
      <dc:creator>Niklas Zantner</dc:creator>
      <pubDate>Mon, 13 Jul 2020 17:49:59 +0000</pubDate>
      <link>https://dev.to/niklaszantner/enable-the-fingerprint-reader-on-a-t480s-3lm5</link>
      <guid>https://dev.to/niklaszantner/enable-the-fingerprint-reader-on-a-t480s-3lm5</guid>
      <description>&lt;p&gt;The fingerprint reader built into the Lenovo t480s is not supported by libfprint. Finally, a project at GitHub was able to get it running: &lt;a href="https://github.com/uunicorn/python-validity"&gt;https://github.com/uunicorn/python-validity&lt;/a&gt;. The project is already available to Arch users via the &lt;a href="https://aur.archlinux.org/packages/python-validity"&gt;AUR&lt;/a&gt; and for apt users via the install instructions at GitHub.&lt;/p&gt;

&lt;p&gt;You can verify if you have the supported fingerprint scanner via running &lt;code&gt;lsusb&lt;/code&gt; and looking for &lt;code&gt;06cb:009a&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you have such a USB device, you can install the package from the AUR and get it running via the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yay -S python-validity
sudo validity-sensors-firmware
sudo systemctl start python3-validity
fprintd-enroll
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;fprintd-enroll&lt;/code&gt; will ask you to enroll your right index finger and when you are using Gnome and GDM, you are ready to use your scanner. Just lock your screen and log in again with your finger.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Powersaving on a Thinkpad t480s running (Arch) Linux</title>
      <dc:creator>Niklas Zantner</dc:creator>
      <pubDate>Tue, 07 Jul 2020 20:46:14 +0000</pubDate>
      <link>https://dev.to/niklaszantner/powersaving-on-a-thinkpad-t480s-running-arch-linux-47p3</link>
      <guid>https://dev.to/niklaszantner/powersaving-on-a-thinkpad-t480s-running-arch-linux-47p3</guid>
      <description>&lt;p&gt;Recently I tuned my t480s to enable more power-saving features and settings. I used the following tools:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="http://manpages.ubuntu.com/manpages/bionic/man8/x86_energy_perf_policy.8.html"&gt;powertop&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/kitsunyan/intel-undervolt"&gt;intel-undervolt&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://linux.die.net/man/1/cpupower"&gt;cpupower&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://manpages.ubuntu.com/manpages/bionic/man8/x86_energy_perf_policy.8.html"&gt;x86_energy_perf_policy&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Powertop
&lt;/h2&gt;

&lt;p&gt;Powertop is used to auto-tune several power-saving settings. Creating a systemd-service at &lt;code&gt;/etc/systemd/system/powertop.service&lt;/code&gt; allows us to automatically run the auto-tune command on the system startup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Unit]
Description=Powertop tunings

[Service]
Type=oneshot
ExecStart=/usr/bin/powertop --auto-tune

[Install]
WantedBy=multi-user.target
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Don't forget to enable and run the service via:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl enable powertop.service --now
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Intel-Undervolt
&lt;/h2&gt;

&lt;p&gt;Intel-undervolt can be used to reduce the voltage used by several hardware components on intel based systems. The configuration is located at &lt;code&gt;/etc/intel-undervolt.conf&lt;/code&gt;. I edited the file to include the following settings. &lt;/p&gt;

&lt;p&gt;Warning, &lt;strong&gt;YOU MUST NOT JUST COPY THOSE!&lt;/strong&gt; Using values not suitable for your system can lead to voiding your warranty, or making your OS unstable. This can really f*ck up your system. On my Lenovo t480s with an i5-8250u everything works as expected.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;undervolt 0 'CPU' -125
undervolt 1 'GPU' -80
undervolt 2 'CPU Cache' -100
undervolt 3 'System Agent' -80
undervolt 4 'Analog I/O' 0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Again, don't forget to enable the corresponding systemd service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl enable intel-undervolt --now
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  cpupower and x86_energy_perf_policy
&lt;/h2&gt;

&lt;p&gt;Utilizing powertop and intel-undervolt as described is a one-time, zero interaction configuration. Additionally, I wanted to have the possibility to modify the power consumption of my Thinkpad manually. &lt;br&gt;
I created a small bash program called &lt;code&gt;power.sh&lt;/code&gt; to change some CPU related settings, based on a supplied command-line argument:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash

setPowerSave() {
  sudo x86_energy_perf_policy --all 'balance-power'
  sudo cpupower frequency-set --max 1600MHz
}

setPerformance() {
  sudo x86_energy_perf_policy --all 'balance-performance'
  sudo cpupower frequency-set --max 3400MHz
}

setSilent() {
  sudo x86_energy_perf_policy --all 'balance-power'
  sudo cpupower frequency-set --max 2400MHz
}

case $1 in

  bat)
    setPowerSave
    ;;

  sil)
    setSilent
    ;;

  ac)
    setPerformance
    ;;

  *)
    echo "The argument $1 is not supported"
    ;;
esac
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The script can process three different command-line arguments:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Argument value: &lt;code&gt;bat&lt;/code&gt;&lt;br&gt;&lt;br&gt;
Reduces the max frequency to 1600MHz and sets the performance hint to balance-power.&lt;br&gt;
Useful when the battery is key.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Argument value: &lt;code&gt;sil&lt;/code&gt;&lt;br&gt;&lt;br&gt;
Reduces the max frequency to 2400MHz and sets the performance hint to balance_performance. Keeps my system mostly silent, as the fan usually never turns on.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Argument value: &lt;code&gt;ac&lt;/code&gt;&lt;br&gt;&lt;br&gt;
Sets the max frequency to 3400MHz (the design maximum on my i5) and sets the performance hint to balance_performance. Useful when developing or running anything more performance intensive.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For convenience, I add an alias to my &lt;code&gt;.bashrc&lt;/code&gt; to be able to call my script via the shorthand &lt;code&gt;pwr&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alias pwr="sh ~./power.sh"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now I can execute &lt;code&gt;pwr bat&lt;/code&gt; to force my system into a custom power-save mode or &lt;code&gt;pwr ac&lt;/code&gt; when I want more performance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing the changes
&lt;/h2&gt;

&lt;p&gt;I used two commands to test my changes. &lt;/p&gt;

&lt;p&gt;Firstly, to test the power in watt being drawn from the battery when the device is off AC reading &lt;code&gt;power_now&lt;/code&gt; can be used:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat /sys/class/power_supply/BAT0/power_now
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Alternatively, &lt;a href="https://github.com/ClementTsang/bottom"&gt;btm&lt;/a&gt; can automatically read the file for you when called with the &lt;code&gt;--battery&lt;/code&gt; option like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;btm -g --hide_time -c --battery
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Secondly, intel-undervolt brings its own tool to monitor the power usage of the SOC, temperatures, and frequencies of the different cores:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;intel-undervolt measure
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Btw. I do not use TLP, as I had repeated problems with it, higher power usage, hot system especially when on AC, and no turbo mode are just some of them. And yes, I checked my config, reinstalled, and so on. As I am really happy with my current solution, I do not regret installing TLP.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

&lt;p&gt;Update 01.08.2020:&lt;br&gt;
Removed the part that undervolting could damage hardware. This is not correct as pointed out by Lukáš Hozda in the comments. Thanks! &lt;/p&gt;

</description>
      <category>linux</category>
      <category>powerusage</category>
      <category>battery</category>
      <category>mobile</category>
    </item>
  </channel>
</rss>
