Skip to content

Instantly share code, notes, and snippets.

@cornfeedhobo
Last active May 28, 2024 16:56
Show Gist options
  • Save cornfeedhobo/8f32430dc6c52b9a4776df91701b1d96 to your computer and use it in GitHub Desktop.
Save cornfeedhobo/8f32430dc6c52b9a4776df91701b1d96 to your computer and use it in GitHub Desktop.
Framework Laptop Customizations

Framework Laptop Customizations

This documents the changes made while installing OpenSUSE LEAP 15.3 on the Framework Laptop (1st edition).


Guided install

During the guided install, there are some minor changes that will make things smoother later.

Enlarged swap for hibernate

There is an option to enlarge swap to support hibernation, but it still fails to create a partition large enough.

  • Use the guided setup, then the expert partitioner, based on the guided setup
  • Delete the root and swap partitions
  • Add a new swap partition that is at least 200MiB larger than your physically installed memory
  • Add your remaining partitions
  • Note: LUKS encryption is still supported

Boot Loader

  • CPU Mitigations (optional): Auto + No SMT
  • Check that the installer has automatically populated resume=
  • Add mem_sleep_default=deep
  • Add acpi_osi="Windows 2020"

Networking

  • Set hostname (optional)

Reboot

Your laptop may freeze during reboot. The caps lock might flash rapidly. This is expected and will be resolved be the Post-Install changes. Hold down the power button until the laptop stops.


Post-Install Changes

Once the base system is installed, you will need to install and configure the necessary components.

Kernel

To make use of the newest features of the laptop, you'll need the newest backported kernel.

sudo zypper ar --priority 50 --refresh https://download.opensuse.org/repositories/Kernel:stable:Backport/standard/Kernel:stable:Backport.repo
sudo zypper ref
sudo zypper up --allow-vendor-change

Trackpad

X11

I found that the best way to configure the trackpad was with xorg.

/etc/X11/xorg.conf.d/99-framework.conf
Section "InputClass"
	Identifier "Framework Clickpad"
	MatchProduct "Touchpad"
	MatchDriver "synaptics"
	
	# Enable clicking
	Option "ClickPad" "true"
	Option "EmulateMidButtonTime" "0
	Option "ClickMethod" "clickfinger"
	Option "ClickFinger1" "1"
	Option "ClickFinger2" "3"
	Option "ClickFinger3" "2"
	
	# Disable tapping
	Option "TapButton1" "0"
	Option "TapButton2" "0"
	Option "TapButton3" "0"
	Option "MaxTapTime" "0"
	Option "SoftButtonAreas" "0 0 0 0 0 0 0 0"
	
	# Prevent Accidental Clicks
	Option "PalmDetect" "1"
	Option "PalmMinWidth" "5"
	Option "PalmMinZ" "40"
	
	# Calm the pad down while clicking
	Option "VertHysteresis" "5"
	Option "HorizHysteresis" "5"
	
	# Natural (reverse) scrolling
	Option "VertTwoFingerScroll" "1"
	Option "VertScrollDelta" "-90"
	Option "HorizTwoFingerScroll" "1"
	Option "HorizScrollDelta" "-90"
	
	# Smooth movement
	Option "MinSpeed" "1"
	Option "MaxSpeed" "2"
	Option "AccelerationProfile" "2"
	Option "ConstantDeceleration" "4"
	#Option "PressureMotionMinZ" "15"
EndSection

Touchegg

Touchegg is available in most repos, but you'll want the newest. There is one available in the X11:Unity reposity where you can grab the latest and install it manually.

Once installed, you can configure it:

~/.config/touchegg/touchegg.conf
  

    
      
        false
        qdbus-qt5 org.kde.kglobalaccel /component/kwin invokeShortcut 'Expose'
        begin
      
    

    
      
        false
        qdbus-qt5 org.kde.kglobalaccel /component/kwin invokeShortcut 'ExposeClass'
        begin
      
    

    
      
        false
        qdbus-qt5 org.kde.kglobalaccel /component/kwin invokeShortcut 'Switch to Previous Desktop'
        begin
      
    

    
      
        false
        qdbus-qt5 org.kde.kglobalaccel /component/kwin invokeShortcut 'Switch to Next Desktop'
        begin
      
    

    
      
        false
        XF86Back
        begin
      
    

    
      
        false
        XF86Forward
        begin
      
    

  


And you'll need a systemd user service to ensure it's stable across all power states

~/.config/systemd/user/touchegg.service
[Unit]
Description=Touchegg User Service

[Service]
ExecStartPre=/bin/sh -c 'killall -qw touchegg || true'
ExecStart=/usr/bin/touchegg
Restart=always
RestartSec=1s

[Install]
WantedBy=default.target

Finally you can enable the services:

sudo systemctl enable --now touchegg.service
systemctl enable --now --user touchegg.service

Suspend-then-hibernate

Systemd

/etc/systemd/logind.conf
HandleLidSwitch=suspend-then-hibernate
/etc/systemd/sleep.conf
HiberateDelaySec=60min
/etc/systemd/system.conf
RebootWatchdogSec=0

KDE Power Management

  • System Settings
    • Power Management
      • Energy Savings
        • On Battery
          • While asleep, hibernate after a period of inactivity
        • On Low Battery
          • While asleep, hibernate after a period of inactivity

Reboot

The laptop may freeze again. Hold down the power button until the laptop shuts off. This should be the last time it freezes during shutdown / reboot.

@wwalker
Copy link

wwalker commented Apr 16, 2022

Note - if the above /etc/X11/xorg.conf.d/99-framework.conf doesn't work for you, your framework probably isn't using the Synaptics driver. I removed the "MatchDriver Synaptic" line and logged out and back in, now it works for me.

@lkocman
Copy link

lkocman commented Apr 26, 2022

Taking as a last minute RFE for 15.4 @cornfeedhobo thank you for the effort this is perfect!

https://code.opensuse.org/leap/features/issue/75

@lkocman
Copy link

lkocman commented Apr 27, 2022

Typo in HiberateDelaySec=60min

@lkocman
Copy link

lkocman commented Apr 27, 2022

Just a highlight from today's openSUSE Release call, we could also look into fingerprint reader (install right packages by default). Smartcards could be next.

@ancorgs
Copy link

ancorgs commented Apr 27, 2022

Regarding the extra 200MiB for swap. Do we have any pointer to a technical document explaining why it would be needed?

I'm asking because, when we decided to rewrite the YaST storage stack (codename storage-ng), we made an strong commitment to only introduce that kind of adjustments if they are backed by a link pointing to some technical specification or any other authorized source. The old storage stack was full of adjustments, logic and numbers that were introduced because "John Doe says this is required" or "Mike Someone needed this for his system to work". We agreed that would be a no-go in the new code - no technical evidence, no code change. ;-)

On the other hand, I find strange the requisite of 200 extra MiB because is the first report we got about that being needed. We have been using swap == RAM for years and it seems to work to hibernate most systems out there. Does this happen consistently or only when the system is on heavy load (ie. with the RAM already full)? Is there something different in this hardware compared to the typical laptop that may explain that?

That being said, we left an open door for this kind of adjustments when we designed the volumes specification that the different products and system roles can use to define which partitions should be created. See adjust_by_ram at the description of a volume. We predicted that the RAM == swap rule would not be enough for everyone in the future and left the possibility of adding different behaviors specified by adjust_by_ram_mode. Adding 200 MiB (or a size specified in another parameter) could be one of those modes. But to be honest it still sounds quite arbitrary and I don't know whether is something we should do for all computers out there just because it worked for one person in one laptop.

@ancorgs
Copy link

ancorgs commented Apr 27, 2022

Regarding the extra 200MiB for swap. Do we have any pointer to a technical document explaining why it would be needed?

Some recent (and different) recommendations one can find on Internet:

  • RAM == size is fine
  • swap size should be equal to size of RAM plus the square root of the RAM size
  • RAM x 1.5 is likely enough to support hybrid suspend (which is likely the default kind of suspend nowadays)
  • according to the kernel documentation, by default Linux tries to make it fit in 2/5 of the available RAM size
  • all this can be adjusted using the image_size parameter of the kernel, so setting that to zero may help to hibernate using the minimal possible amount of swap
  • ...whatnot...

@cornfeedhobo
Copy link
Author

cornfeedhobo commented Apr 28, 2022

@ancorgs @lkocman

Regarding the 200MiB recommendation:

  • It's sort of an arbitrary number I picked. I figured it would be enough for the filesystem metadata for most swap sizes. This should be calculable though.
  • Keep in mind that the current guided partitioner is broken. It always creates a swap that is too small. I haven't filed a bug on this yet.
  • Indeed, my research into the kernel documentation hints that swap doesn't actually have to be equal to the size of physical memory, but I think many applications expect this, for example, systemd wasn't happy until I made the final available swap size equal to physical memory.

Regarding the fingerprint reader, I did get it to work once, but it was cumbersome and error prone. I think one of my test installs did get it to work smoothly with the newest KDE on TW. I agree that ensuring the needed packages are available would be a good first start, then users can spend some months trying out different configurations until something consistent is discovered.

Since the guided partitioner is currently broken for creating correct swap partition sizes, it would be great to steer the conversation towards switch to swap files. They offer greater flexibility to the user, allowing them to expand system memory without having to re-partition. I have struggled to get hibernation to be stable for dedicated partitions, with my system always complaining about unmounting /var during resume (it still succeeds, but I don't know why it complains). I think I got swap files to work during one of my test installs, but then when I added LUKS encryption, it broke again, and by that time I was tired of testing installs. I had probably drilled through 30-40 of them. If this idea interests you, Arch's wiki has some decent documentation about it, including working around btrfs quirks.

I'm really glad this has been of some use. If you need to sync, I'm on libera irc, and I'll keep watching this thread.

@DaAwesomeP
Copy link

Hey @cornfeedhobo, thanks for this! I'm on the 12th gen Framework and Leap 15.4, so maybe some things are different, but I have a few questions:

@DaAwesomeP
Copy link

Update: For 12th gen to get the brightness/airplane mode keys to work, you need to prevent the conflicting ALS driver from loading:

echo "blacklist hid_sensor_hub" > /etc/modprobe.d/90-framework-als-blacklist.conf
mkinitrd

Note that the kernel parameter module_blacklist=hid_sensor_hub did not work and I specifically needed hid_sensor_hub in the modprobe file and not hid-sensor-hub.

@cornfeedhobo
Copy link
Author

@DaAwesomeP I won't be upgrading from the 11th gen for quite a while, but I can respond to the other questions:

What does acpi_osi="Windows 2020" workaround/fix/improve?

Shutting down hangs unless this is set.

How did you test/troubleshoot that mem_sleep_default=deep is required to get to S3 sleep?

Battery drain while asleep for 3 hours with and without it set. deep had less drain, but still more than I was happy with. I don't remember the hard numbers at this point and didn't document them, sorry.

Have you experimented with nvme.noacpi=1

No, I didn't try that. After reading this comment, I'm thinking that it might be worth trying with s2idle - it sounds like you'll get drain that is comparable to s3deep. I still think ~3%/hr is too much to tolerate, but maybe this means an optimal config could drop s3deep and still configure hibernation after 2-3 hours.

@brianjcohen
Copy link

brianjcohen commented May 28, 2024

@cornfeedhobo I'm trying to get suspend-then-hiberate going on Tumbleweed running KDE Plasma6. I know you're on LEAP but perhaps you or someone else here can help with a couple questions.

  • In Plasma6, the KDE Energy Saving setting 'After a period of inactivity' allows you to select one of 'Do Nothing', 'Sleep', 'Hibernate', and 'Shutdown' along with a time offset (eg. 'After 120 minutes'). Are you setting a value here?
  • Likewise, the setting for 'When laptop lid closed' can be set to one of 'Do Nothing', 'Sleep', 'Hibernate', 'Shutdown', 'Lock Screen', 'Turn Off Screen'. Does this setting matter.
  • In this thread comment, there are additional login.conf directives being suggested, instead of just the single HandleLidSwitch directive mentioned in this gist. Did it turn out that HandleLidSwitch was the only one that really mattered? https://community.frame.work/t/responded-linux-deep-sleep/2491/73

Edit: I'm finding some evidence that the systemd devs actually changed the meaning of suspend-then-hibernate within the last couple years and that it no longer means "transition from suspend to hibernate on my preferred offset": https://old.reddit.com/r/openSUSE/comments/1bfpebv/suspendthenhibernate_hibernate_timeout/

Edit: Scratch that. It looks like the systemd devs actually reverted that change. https://old.reddit.com/r/archlinux/comments/zczdnq/systemctl_suspendthenhibernate_not_working_anymore/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment