Skip to content

Instantly share code, notes, and snippets.

@jpeletier
Last active January 20, 2020 20:08
Show Gist options
  • Save jpeletier/ff8d43072d8ddba2f0d4685d0e3bcc09 to your computer and use it in GitHub Desktop.
Save jpeletier/ff8d43072d8ddba2f0d4685d0e3bcc09 to your computer and use it in GitHub Desktop.
Tweaks for Ubuntu 18.04 in Surface Book 2
Eliminate hiss:
run:
amixer -c 0 sset 'Auto-Mute Mode' Disabled && sudo alsactl store
create /etc/modprobe.d/sound.conf with the following content:
options snd-hda-intel model=generic
Hibernate
Follow https://fitzcarraldoblog.wordpress.com/2018/07/14/configuring-lubuntu-18-04-to-enable-hibernation-using-a-swap-file/
For swap partition: https://help.ubuntu.com/community/SwapFaq
In both cases, there has to be an entry in /etc/fstab
Add the following to /etc/pm/config.d/hibernate_mode:
HIBERNATE_MODE="shutdown"
Add the following to /etc/systemd/sleep.conf
[Sleep]
HibernateMode=shutdown
The above will prevent the machine from rebooting after you try to hibernate.
Ubuntu 19.10:
When installing the Kernel, it does not set it for automatic boot, you have to select it manually.
NVIDIA: Change the mode to "On Demand". The default is "performance" and makes the fans to spin all the time.
The hiss problem does not happen in Ubuntu 19.10
Enable sleep on lid close:
sudo /etc/default/grub
Add this to GRUB_CMDLINE_LINUX_DEFAULT:
acpi_sleep=nonvs
(In addition of other things that may be there)
for example:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_sleep=nonvs"
then `sudo update-grub`
## Enable hibernate option in menu:
1.- Update the policy kit
sudo nano /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
Copy paste the following value and save the file
```
[Re-enable hibernate by default in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes
[Re-enable hibernate by default in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.handle-hibernate-key;org.freedesktop.login1;org.freedesktop.login1.hibernate-m$
ResultActive=yes
```
### Configure Lid switch actions. If you want the laptop to automatically enter hibernation when you close the lid, we need to configure them here:
sudo nano /etc/systemd/logind.conf
The file contains several action that can be configured during login process. The one that is relevant for our purposes is:
HandleLidSwitch=hibernate
Additonally, if you own a laptop dock and you would like to be able to use your laptop when it’s connected to an external monitor while the lid is closed, uncomment:
#HandleLidSwitchDocked=ignore
to
HandleLidSwitchDocked=ignore
…and save the file
## Enable wakeup on keypress
1.- Find the keboard:
grep . /sys/bus/usb/devices/*/product , eg:
```
/sys/bus/usb/devices/1-1.1/product:L2 USB2 Hub
/sys/bus/usb/devices/1-1.3/product:Surface Keyboard
/sys/bus/usb/devices/1-1/product:L1 USB2 Hub
/sys/bus/usb/devices/2-1/product:L1 USB3 Gen1 Hub
/sys/bus/usb/devices/usb1/product:xHCI Host Controller
```
2.- set the wakeup file to "enabled" for the
Keyboard is in "1-1.3", so to enable wakeup:
echo "enabled" | sudo tee /sys/bus/usb/devices/1-1.3/power/wakeup
Change is not permanent. To make it permanent, write a init.d script:
3.- Create init.d script so this is set on boot:
sudo nano /etc/init.d/keyboardwakeup
```
#!/bin/bash
echo enabled > /sys/bus/usb/devices/1-1.3/power/wakeup
```
sudo chmod +x /etc/init.d/keyboardwakeup
sudo ln -s /etc/init.d/keyboardwakeup /etc/rc3.d/S01keyboardwakeup
Source: https://askubuntu.com/questions/848698/wake-up-from-suspend-using-wireless-usb-keyboard-or-mouse-for-any-linux-distro/1155666#1155666
## Mixed DPI configuration
1.- Set scale to 200% in Gnome Display Settings. The low-DPI monitor content will look huge.
2.- Set the monitor positions as desired
3.- To fix some flickering problems when scaling, add the following file:
`/usr/share/X11/xorg.conf.d/20-intel.conf` with this content:
```
Section "Device"
Identifier "Intel Graphics"
Driver "intel"
EndSection
```
(More info on this on https://unix.stackexchange.com/a/379825).
4.- use arandr (xrandr gui, apt-get install arandr) to arrange the monitors in the desired way. Save the configuration as a script
5.- Modify the generated script adding `--scale 2x2` after the `--output` switch that refers to the low DPI monitor.
6.- Modify `~/.profile` to run this script with a sleep on session startup:
```
function configMonitors() {
sleep 8
if xrandr | grep "eDP1 connected primary 3240x2160+0+1440"; then
homemonitors.sh # <-- script generated by arandr
fi
}
configMonitors &
```
In this example we use a grep to cheaply detect whether the desired monitor is actually present.
It may be possible to automate on monitor plug-in as well. Didn't test it: https://unix.stackexchange.com/questions/527679/run-an-x-program-when-a-monitor-is-plugged-in
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment