Convenient Razer

Ubuntu on the Razer blade


On my longest experiment with linux laptops, a late-2016 Razer Blade 15". Although Razer has generally linux-compatible components in their laptops, the company does not seem particularly linux-friendly. There is a Linux support forum, but it’s depressingly full of many people having similar problems at each other. tl;dr you need to dual-boot windows to get firmware updates. Now that there are thunderbolt 3 GPU enclosures around, I would probably not bother with this headache of a GPU laptop next time (which is kind of the whole Razer thing). Rather I would buy an officially-supported linux laptop for my research needs, because my time is short.

General

See Roland Guelle’s excellent Razerblade HOWTO, ~~the xipherzero pages ~~, the Ubuntu community Razer page, and the archlinux Razer page.

Keyboard, trackpad, mouse

See also non-Razer specific Ubuntu keyboard and mouse stuff.

Keyboard lights

Install the dorky keyboard drivers and the dorky GUI, polychromatic.

sudo add-apt-repository ppa:openrazer/stable
sudo add-apt-repository ppa:polychromatic/stable
sudo apt install openrazer-meta polychromatic
# sudo gpasswd -a plugdev user  ## no longer needed?

This is reasonably smooth, but you can get into various kernel module difficulties. Also note that if you are running a custom user python (e.g. if you load up a virtualenv or anaconda python in your .bashrc) then this will not work, since openrazer inspects your shell path to find its python.

UPDATE: for some reason this doesn’t work on Ubuntu 19.10 for me. However the competing GUI RazerGenie works fine.

Anyway, after all that fussing, you now have a rainbow-coloured GUI to control your rainbow-coloured keyboard lights! Wheeeee! It works… sometimes.

Two finger right click

Use GNOME Tweaks to get hold-to-right-click which is I think supposed to be an accessibility feature. This is not 100% reliable. Some apps will then interpret the right click as a left and a right click. In 2020 accessibility is still a shambles.

Trackpad freezes

If trackpad motion freezes, restarting the xinput device fixes it for me.

xinput --list  # look for a "Synaptics" pointer id, which for me is usually but not always 15
xinput disable 15
xinput enable 15

I have also seen reloading the modules responsible as a recommendation but this does not work for me:

sudo modprobe -r usbhid; sudo modprobe -r psmouse;sudo modprobe psmouse;sudo modprobe  usbhid

NB run all those commands in a single line because modprobe -r usbhid disables the keyboard and it will be hard to enter partial commands.

Horizontal scrolling backwards

Per default, vertical scrolling is “natural” and horizontal is “traditional”.. UPDATE UPDATE: On ubuntu ≥ 19.10 the entire problem seems to have sublimated away and scrolling is consistent.

If you are stuck on an old version, Here is a generic xinput fix.

xinput --list  # look for a "Synaptics" pointer
xinput --watch-props <id>

finds and dumps info about the erroneous thingy which for me is a Synaptics TM2438-005 at id=15, and

xinput --set-prop <id> "Synaptics Scrolling Distance" -94 -94

fixes it.

It turns out there is a special synaptics command synclient, which also does it.

sudo apt install xserver-xorg-input-synaptics

AFAICT this is deprecated because it doesn’t use the modern libinput although they seem to coexist peacefully on my system so maybe I should not care about that until something breaks nastily.

UPDATE: installing synclient on recent ubuntu seems to cause the backwards horizontal bug. No longer recommended.

The archlinux backgrounder might make it clear if I were inclined to read it.

synclient VertScrollDelta=-94 HorizScrollDelta=-94

This needs to be run after laptop resume also which gets complicated. I needed to set up a script that will talk to X, in /home/me/bin/scrollrite.sh:

#!/bin/bash
#title          :scrollrite.sh
#notes          :Script gets called from /lib/systemd/system-sleep
#==========================================================================
sleep 5
declare -x DISPLAY=":0.0"
declare -x XAUTHORITY="/home/me/.Xauthority"
synclient VertScrollDelta=-94 HorizScrollDelta=-94

Power management/suspend/hibernate

Razer is all about a considered approach to power credit: New Matilda

Fails to sleep when lid closed

Things seem to go weird for me. Circumstantial evidence suggests nvidia drivers are involved, which apparently is common.

The problem produces the following error:

Freezing of tasks failed after 20.00 seconds
  (21 tasks refusing to freeze, wq_busy=21):
...<nvidia related stacktrace>

The problem seems to have vanished for me after aggressively updating to recent versions of all drivers.

Keeps on suspending again after suspending once

After the laptop has gone to sleep one time it has narcolepsy and keeps sleeping again?

I found this fix somewhere: append button.lid_init_state=open to the value of GRUB_CMDLINE_LINUX_DEFAULT="" in /etc/default/grub then

update-grub

to add this to the boot conf. Or wrangle it in grub customizer.

My screen never powers off even when laptop is idle

Weird, mine too. But no longer. I fixed it using dpms:

xset dpms 0 0 600

Logs out on suspend on battery

Still diagnosing this one. See the settings in /etc/systemd/logind.conf. Changing the following keys between hibernate and suspend changes some stuff:

HandleSuspendKey=suspend
HandleLidSwitch=suspend
HandleLidSwitchDocked=suspend
HandleLidSwitchExternalPower=suspend

I suspect you don’t need HandleLidSwitchDocked and HandleLidSwitchExternalPower but do not know which version is current.

Keyboard unresponsive after resume

Some weird xhci_hcd error seems to arise in the syslog. Correlated with power saving?

The following commands fix it for me, but I need to shell in to run them, so I have to SSH in to run them.

$ ls /sys/bus/pci/drivers/xhci_hcd/
0000:00:14.0@  0000:3a:00.0@  bind  new_id  remove_id  uevent  unbind
$ echo -n "0000:3a:00.0" | tee /sys/bus/pci/drivers/xhci_hcd/unbind
$ echo -n "0000:3a:00.0" | tee /sys/bus/pci/drivers/xhci_hcd/bind
$ echo -n "0000:00:14.0" | tee /sys/bus/pci/drivers/xhci_hcd/unbind
$ echo -n "0000:00:14.0" | tee /sys/bus/pci/drivers/xhci_hcd/bind

I wonder if this is related to the XHC problem, in which case this helps with resuming.

echo XHC | sudo tee /proc/acpi/wakeup

An automatically fancy scripted version is system-sleep-xhci.sh, and also a more elaborate and possibly better version is here. Once again, this need to be run on resume. The conetnet of those links here reproduced below:

#!/bin/bash

# Original script was using /bin/sh but shellcheck reporting warnings.

# NAME: custom-xhci_hcd
# PATH: /lib/systemd/system-sleep
# CALL: Called from SystemD automatically
# DESC: Suspend broken for USB3.0 as of Oct 25/2018 various kernels all at once

# DATE: Oct 28 2018.

# NOTE: From comment #61 at: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/522998
# adapted at https://askubuntu.com/a/1089078/1097650

TMPLIST=/tmp/xhci-dev-list

# Original script was: case "${1}" in hibernate|suspend)

case $1/$2 in
  pre/*)
    echo "$0: Going to $2..."
    echo -n '' > $TMPLIST
    for i in `ls /sys/bus/pci/drivers/xhci_hcd/ | egrep '[0-9a-z]+\:[0-9a-z]+\:.*$'`; do
        # Unbind xhci_hcd for first device XXXX:XX:XX.X:
        echo -n "$i" | tee /sys/bus/pci/drivers/xhci_hcd/unbind
        echo "$i" >> $TMPLIST
    done
        ;;
  post/*)
    echo "$0: Waking up from $2..."
    for i in `cat $TMPLIST`; do
        # Bind xhci_hcd for first device XXXX:XX:XX.X:
        echo -n "$i" | tee /sys/bus/pci/drivers/xhci_hcd/bind
    done
    rm $TMPLIST
    ;;
esac

There is some background theory here.

Wifi breaks after resume

This problem on Ubuntu 19.10 occasionally causes my laptop not to reconnect to the wifi after waking from suspend. Toggling the buttons in the wifi manager doesn’t fix it; I’m offline until reboot, or after putting the laptop to sleep and then waking it up.

Nothing obviously wrong in the logs except that the network connection times out. Since I cannot access the internet when the problem occurs, I will copy and paste various suggested solutions here so that I attempt fixes.

Restart network-manager.service

For systemd systems, try

sudo systemctl restart network-manager.service

If this works, you can create a script to automate it. Put the following in sudo nano /etc/systemd/system/wifi-resume.service:

#/etc/systemd/system/wifi-resume.service
#sudo systemctl enable wifi-resume.service
[Unit]
Description=Restart network-manager at resume
After=suspend.target
After=hibernate.target
After=hybrid-sleep.target

[Service]
Type=oneshot
ExecStart=/bin/systemctl restart network-manager.service

[Install]
WantedBy=suspend.target
WantedBy=hibernate.target
WantedBy=hybrid-sleep.target

Now to use it:

# activate
sudo systemctl enable wifi-resume.service
# check status
systemctl status wifi-resume.service

Without systemd, create a script in /etc/pm/sleep.d (any name), set the executable bit via chmod +x, and insert the following content:

case "${1}" in
    resume|thaw)
        # systemctl restart network-manager.service
        service NetworkManager restart
;;
esac

Other commands suggested:

# option 1
sudo iwlist $(ifconfig | grep -Po '^w\w+') scan
# option 2
sudo {
  service network-manager stop;
  sleep 5;
  sudo service network-manager start;
}`

Alternate interventions

Set some config flag that sometimes helps?

nmcli nm sleep false

Or, perhaps it is the wmac spoofing bug? To /etc/NetworkManager/NetworkManager.conf add the line

[device]
wifi.scan-rand-mac-address=no

AFAICT this last one is not my particular problem.

Fan control

Fan control is weird and sounds like a jet aircraft sounds only intermittently like a jet aircraft in the latest update. Perhaps fancontrol could help? or the razer specific fancontrol kernel module?

webcam

Notably inbuilt webcam is broken. Inbuilt webcam works fine in Ubuntu 19.10 in videoconferencing although weirdly not in the in-built webcam app Cheese.

If you are on an older version, try these? The archlinux page has some suggestions for the webcam thing. Specifically, put

options uvcvideo quirks=512

in /etc/modprobe.d/uvcvideo.conf.

That does not fix it for me.

NVMe drive not detected

Happens on certain drives

Add

nvme_core.default_ps_max_latency_us=200

to the boot string. This is something about power saving, plus possibly also firmware, which seems common. It also seems one can avoid this issue by buying the Samsung EVO SSDs.

Maybe also use nvme-cli to check drive health.

Make the fix permanent with /etc/default/grub then

sudo update-grub

Installer hangs

Add

nomodeset acpi_osi

to the kernel string. Doesn’t seem necessary with kernels >4.10.

Migrating disks

See the ubuntu resize instructions.


Warning! Experimental comments system! If is does not work for you, let me know via the contact form.

No comments yet!

GitHub-flavored Markdown & a sane subset of HTML is supported.