Skip to content

Instantly share code, notes, and snippets.

@wohali
Created January 5, 2019 06:44
Show Gist options
  • Save wohali/19630846736867f8a02a99de9b608e49 to your computer and use it in GitHub Desktop.
Save wohali/19630846736867f8a02a99de9b608e49 to your computer and use it in GitHub Desktop.
ThinkPad X1 Extreme with Debian 9 Settings

fix console font (bigger)

sudo dpkg-reconfigure console-setup
sudo setupcon

fix grub font size

sudo vi /etc/default/grub
GRUB_GFXMODE=1024x768
sudo update-grub2

fix firmware: failed to load i915/kbl_dmc_ver1_04.bin

sudo apt-get install intel-microcode firmware-linux-nonfree firmware-misc-nonfree

fix battery issues

sudo apt-get install tlp powerstat
sudo apt-get systemctl stop NetworkManager.service
sudo apt-get systemctl disable NetworkManager.service

bunch of edits to /etc/default/tlp

apt-get install -t stretch-backports acpi-call-dkms

then use tlp to fix things up

NOTE: Still need to recalibrate battery, see https://linrunner.de/en/tlp/docs/tlp-faq.html#erratic-battery

install nvidia binary driver

First

sudo apt install -t stretch-backports nvidia-driver nvidia-kernel-dkms vulkan-utils bumblebee-nvidia primus
reboot

this isn't necessary

now that it's working,

sudo apt install bbswitch-source module-assistant
m-a prepare
m-a update
m-a a-i bbswitch

go on

sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get install -t stretch-backports primus-libs:i386 libgl1-nvidia-glx:i386 

some tests

optirun glxgears -info
vblank_mode=0 primusrun glxgears
optirun -b none nvidia-settings -c :8

rEFInd

apt-get install refind
efibootmgr -c -d /dev/nvme0n1 -L "rEFInd" -l "\EFI\refind\refind_x64.efi"
cd /boot/efi/EFI/tools
wget https://github.com/tianocore/edk2/raw/master/ShellBinPkg/UefiShell/X64/Shell.efi

download and burn memtest86 usb stick, then copy the EFI/BOOT directory to /boot/efi/EFI/tools/memtest86 rename /boot/efi/EFI/tools/memtest86/mumblex64.efi to memtest86_x64.efi edit /boot/efi/EFI/refind/refind.conf:

showtools shell,memtest
use_graphics_for + linux,windows,grub
default_selection +

edit /boot/refind_linux.conf to ensure kernel flags are accurate

fix slow boot

sudo systemctl edit networking.service

and add:

[Service]
TimeoutStartSec=15sec

XTerm

fix middle-mouse in xterm flickering

needs rebind, middle-mouse-hold is grabbed by xinput for scrolling.

in .Xresources:

XTerm.vt100.translations: #override \n\
    Ctrl Meta <Btn1Down>: popup-menu(vtMenu) \n\
    Shift <Btn1Up>: exec-formatted("firefox --new-tab '%t'", PRIMARY)

all the XTerm settings

XTerm*utf8: 1
XTerm.termName: xterm-256color
XTerm.vt100.metaSendsEscape: true

XTerm.vt100.translations: #override \n\
    Ctrl Meta <Btn1Down>: popup-menu(vtMenu) \n\
    Shift <Btn1Up>: exec-formatted("firefox --new-tab '%t'", PRIMARY)

XTerm.vt100.saveLines: 99999
XTerm*SaveLines: 99999
XTerm*ScrollKey: true
XTerm*visualBell: true
XTerm.vt100.geometry: 90x24

! From http://web.archive.org/web/20090130061234/http://phraktured.net/terminal-colors/
!Theme Twelve
*foreground: rgb:ff/ff/ff
*background: rgb:00/00/00
*color0:     rgb:00/00/00
*color1:     rgb:bf/72/76
*color2:     rgb:86/af/80
*color3:     rgb:96/8a/38
*color4:     rgb:36/73/b5
*color5:     rgb:9a/70/b2
*color6:     rgb:7a/be/cc
*color7:     rgb:db/db/db
*color8:     rgb:66/92/af
*color9:     rgb:e5/50/5f
*color10:    rgb:87/bc/87
*color11:    rgb:e0/d9/5c
*color12:    rgb:1b/85/d6
*color13:    rgb:ad/73/ba
*color14:    rgb:33/8e/aa
*color15:    rgb:f4/f4/f4

XTerm*cursorColor: yellow
XTerm*cursorBlink: true
XTerm*charClass: 33:48,36-47:48,58-59:48,61:48,63-64:48,95:48,126:48

!fonts to look for: carlito?
xterm*faceName: Inconsolata:size=11
XTerm.vt100.faceNameDoublesize: WenQuanYi WenQuanYi Bitmap Song

useful for synaptics driver support

apt-get install xserver-xorg-input-synaptics xinput

HiDPI

X settings

Settings in .Xresources:

!hidpi archwiki page
Xft.dpi: 180
Xft.autohint: 0
Xft.lcdfilter: lcddefault
Xft.hintstyle: hintfull
Xft.hinting: 1
Xft.antialias: 1
Xft.rgba: rgb
Xcursor.size: 48

more settings here: https://wiki.archlinux.org/index.php/HiDPI

Doozer's way

xrandr --newmode "2880x1620"  397.41  2880 3096 3416 3952  1620 1621 1624 1676  -HSync +Vsync 1>/dev/null 2>&1 || true
xrandr --addmode eDP-1 2880x1620
xrandr --output eDP-1 --mode 2880x1620

compton (X eye candy)

add to ~/.fluxbox/startup:

compton -bc -o 0.22 -m 0.88 &

settings in ~/.config/compton.conf:

#--------------------------------
#-------Backend Settings:--------
#--------------------------------
backend = "xrender";
#backend = "glx";                 # Use GLX backend for rendering
vsync = "opengl";                # Use OpenGL to implement vsync
glx-swap-method = 3;             # Use a triple-buffer
paint-on-overlay = true;         # Improves performance (usually) and reduces flickering
glx-no-stencil = true;           # Improves performance
glx-no-rebind-pixmap = true;     # Improves performance with rapid window changes, might n
ot work with some drivers
refresh-rate = "60";


#--------------------------------
#--------Shadow Settings:--------
#--------------------------------
shadow = true;                   # Enable drawing shadows on windows
shadow-radius = 8;               # The blur radius for shadows
shadow-offset-x = -8;            # The horizontal offset for shadows
shadow-offset-y = -8;            # The vertical offset for shadows
clear-shadow = true;             # Zero the part of the shadow's mask behind the window, m
ay break some applications
no-dock-shadow = true;           # Do not draw shadows on docks/panels
no-dnd-shadow = true;            # Do not draw shadows on DND windows
shadow-exclude = [               # Do not draw shadows on these specific applications:
   #"! name~=''",
    "n:e:Notification",
    "n:e:Plank",
    "n:e:Docky",
    "g:e:Synapse",
    "g:e:Kupfer",
    "g:e:Conky",
    "n:w:*dockbarx*",
   #"n:w:*Firefox*",
   #"n:w:*Chrome*",
   #"n:w:*Chromium*",
    "class_g ?= 'Notify-osd'",
    "class_g ?= 'Cairo-dock'",
    "class_g ?= 'Xfce4-notifyd'",
    "class_g ?= 'Xfce4-power-manager'",
   # See wiki.archlinux.org/index.php/Compton
    "class_g = 'Firefox' && argb",
    "_NET_WM_STATE@:32a *= '_NET_WM_STATE_HIDDEN'"
];

#--------------------------------
#--------Fading Settings:--------
#--------------------------------
fading = true;                   # Enable fading windows during opacity changes
no-fading-openclose = true;
fade-delta = 4;                  # The time between steps in a fade in milliseconds
fade-in-step = 0.03;             # The opacity change between steps while fading in
fade-out-step = 0.03;            # The opacity change between steps while fading out
detect-client-opacity = true;    # Prevent opacity from being ignored for some application
s


#--------------------------------
#--------Window Settings:--------
#--------------------------------
wintypes:                        # Change behavior for these specific types of windows:
{
    tooltip = { fade = true; shadow = false; };
};

detect-rounded-corners = true;

# Flicker fix?
unredir-if-possible = false;

# don't draw underlying tabbed windows
opacity-rule = [
  "95:class_g = 'XTerm' && !_NET_WM_STATE@:32a",
  "0:_NET_WM_STATE@[0]:32a *= '_NET_WM_STATE_HIDDEN'",
  "0:_NET_WM_STATE@[1]:32a *= '_NET_WM_STATE_HIDDEN'",
  "0:_NET_WM_STATE@[2]:32a *= '_NET_WM_STATE_HIDDEN'",
  "0:_NET_WM_STATE@[3]:32a *= '_NET_WM_STATE_HIDDEN'",
  "0:_NET_WM_STATE@[4]:32a *= '_NET_WM_STATE_HIDDEN'"
];

fluxbox menus - menumaker

pretty backgrounds

see the .fehbg setup in the archwiki fluxbox page

acpid / hotkeys

apt install acpid
acpi_listen

now press a key and see output, these will be $1 $2 $3 $4 params

see /usr/share/doc/acpid/README.Debian - create files like /etc/acpi/events/powerbtn with content like:

event=button/power .*
action=/etc/acpi/powerbtn.sh

all of my /etc/acpi/events files:

$ find /etc/acpi/events -type f -print -exec cat {} \;
/etc/acpi/events/brightness-down-support
event=video[/ ]brightnessdown .*
action=/etc/acpi/backlight.sh -
/etc/acpi/events/keyb-hotkey-support
event=ibm[/ ]hotkey LEN0268:00 00000080 00001315
action=aplay /usr/lib/libreoffice/share/gallery/sounds/left.wav
/etc/acpi/events/lid-support
event=button[ /]lid LID .*
action=aplay /usr/lib/libreoffice/share/gallery/sounds/ok.wav
/etc/acpi/events/mic-mute-support
event=button[ /]f20 .*
action=amixer set Capture toggle
/etc/acpi/events/mute-support
event=button[ /]mute .*
action=/etc/acpi/mute.sh
/etc/acpi/events/brightness-up-support
event=video[/ ]brightnessup .*
action=/etc/acpi/backlight.sh +
/etc/acpi/events/powerbtn-acpi-support
event=button[ /]power
action=/etc/acpi/powerbtn-acpi-support.sh
/etc/acpi/events/star-hotkey-support
event=ibm[/ ]hotkey LEN0268:00 00000080 00001311
action=aplay /usr/lib/libreoffice/share/gallery/sounds/kling.wav
/etc/acpi/events/volumedown-support
event=button[ /]volumedown .*
action=amixer set Master 5-
/etc/acpi/events/volumeup-support
event=button[ /]volumeup .*
action=amixer set Master 5+

and their support files in /etc/acpi:

$ for i in `ls /etc/acpi/*.sh`; do echo $i; cat $i; done
/etc/acpi/backlight.sh
#!/bin/bash
bl_dev=/sys/class/backlight/intel_backlight
step=250

case $1 in
  -) echo $(($(< $bl_dev/brightness) - $step)) >$bl_dev/brightness;;
  +) echo $(($(< $bl_dev/brightness) + $step)) >$bl_dev/brightness;;
esac
/etc/acpi/mute.sh
#!/bin/bash
now=$(amixer get Master | tr -d '[]' | grep "Playback.*%" |head -n1 |awk '{print $6}');
on="off"
off="on"
/usr/bin/amixer -q sset Master ${!now}
/usr/bin/amixer -q sset Speaker ${!now}
/usr/bin/amixer -q sset Headphone ${!now}
#/usr/bin/amixer -q sset Master toggle
#/usr/bin/amixer -q sset Speaker toggle
#/usr/bin/amixer -q sset Headphone toggle

/etc/acpi/powerbtn-acpi-support.sh
# trimmed - same as Debian default

stop auto-suspend on lid close

edit /etc/systemd/logind.conf

HandleLidSwitch=ignore
HandleLidSwitchDocked=ignore

then

systemctl restart systemd-logind

actual suspend key: Fn-4

fan control

https://wiki.archlinux.org/index.php/Fan_speed_control#ThinkPad_laptops

/etc/modprobe.d/thinkpad-acpi.conf:

options thinkpad_acpi fan_control=1

then:

apt install thinkfan lmsensors

in /etc/thinkfan.conf:

# Thinkpad X1 Extreme
#
tp_fan /proc/acpi/ibm/fan
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp1_input # Package sensor
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp2_input # Core 0
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp3_input # Core 1
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp4_input # Core 2
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp5_input # Core 3
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp6_input # Core 4
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp7_input # Core 5
#hwmon /sys/devices/virtual/hwmon/hwmon4/temp1_input # iwlwifi
hwmon /sys/devices/virtual/hwmon/hwmon2/temp1_input # pch_cannonlake (Intel gfx)
hwmon /sys/devices/virtual/hwmon/hwmon0/temp1_input # acpitz
hwmon /sys/devices/virtual/thermal/thermal_zone1/temp   # INT3400 (battery charger)


{ "level 0"
#    Sensor count:
#    1  2  3  4  5  6  7  8  9  10 
#    =============================
    (0  0  0  0  0  0  0  0  0  0)      # Temp at which to step down to previous level
    (63 63 63 63 63 63 63 .  63 30)     # Temp at which to step up to next level
}

{ "level 1"
    (57 57 57 57 57 57 57 .  57 27)
    (65 65 65 65 65 65 65 .  65 35)
}

{ "level 2"
    (59 59 59 59 59 59 59 .  59 29)
    (67 67 67 67 67 67 67 .  67 37)
}

{ "level 3"
    (61 61 61 61 61 61 61 .  61 31)
    (69 69 69 69 69 69 69 .  69 39)
}

{ "level 4"
    (63 63 63 63 63 63 63 .  63 33)
    (71 71 71 71 71 71 71 .  71 41)
}

{ "level 5"
    (65 65 65 65 65 65 65 .  65 35)
    (73 73 73 73 73 73 73 .  73 43)
}

{ "level 6"
    (67 67 67 67 67 67 67 .  67 37)
    (75 75 75 75 75 75 75 .  75 43)
}

{ "level 7"
    (69 69 69 69 69 69 69 .  69 39)
    (77 77 77 77 77 77 77 .  77 45)
}

{ "level disengaged"
    (71 71 71 71 71 71 71 .  71 41)
    (99 99 99 99 99 99 99 .  99 99)
}

test with thinkfan -n and sensors commands

when ready:

echo "START=yes" >> /etc/default/thinkfan
systemctl enable thinkfan
systemctl start thinkfan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment