Posted on Mon 30 January 2017

Linux on the Alienware 13 R3 (2017)

I recently bought a new laptop because my trusty old Thinkpad (x230) finally got a bit too old for my taste (apart from the battery it still works perfectly though!).

After a lot of searching around and gnashing of teeth - how can current laptops be barely faster than my 4 year old Thinkpad?! And what do you mean, the laptop comes with at most 16 GB of RAM and I can't even upgrade it?!

Finally, I settled on the Alienware 13.

As a gaming laptop, it has a quad core i7 - 7th gen Kaby Lake - and a great GPU, the GTX 1060. 3.5 TFlops in a laptop! Since I'm partial to a bit of machine learning, that kind of performance was very enticing. It's also fully upgradeable - 2 m2 slots for SSDs, as well as 2 SO-DIMMs for RAM.

Additionally, the Alienware 13 comes with a stunning OLED screen. Black is really absolutely black, and colors are extremely vibrant. The best display I've seen in any laptop so far.

So much for the hardware. But what about the software?

Not surprisingly, it ships with Windows. Perhaps more surprisingly, Linux support is surprisingly good: I installed the latest Ubuntu 16.10, and pretty much everything worked out of the box.

Due to my use of i3 as window manager, I did have to write two small scripts, one to control volume, another for display brightness while adjusting color temperature.

First, a short script to mute/unmute when pressing the function key:

#!/bin/bash

CURRENT_STATE=`amixer get Master | egrep 'Playback.*?\[o' | egrep -o '\[o.+\]'`

if [[ $CURRENT_STATE == '[on]' ]]; then
    amixer -q set Master mute
else
    amixer -q set Master unmute
    amixer -q set Speaker unmute
    amixer -q set Headphone unmute
fi

And another one to set the brightness when pressing the corresponding function keys:

#!/usr/bin/python
import os
import subprocess
import sys

brightness_file = '/home/mononofu/.brightness'

current_brightness = 1.0

if os.path.exists(brightness_file):
  with open(brightness_file) as f:
    current_brightness = float(f.read())

if len(sys.argv) == 2:
  current_brightness += float(sys.argv[1])
  current_brightness = min(1, max(0, current_brightness))
  with open(brightness_file, 'w') as f:
    f.write(str(current_brightness))

subprocess.check_call(
  ['redshift', '-o', '-l', '48.207043:15.513833',
   '-b', str(current_brightness)])

In the above script, I use redshift to adjust the color temperature of my display towards red during the evening. If you don't want that, you can set the brightness directly with xrandr --output eDP-1-1 --brightness 0.3.

Both these scripts are bound to the function keys in my i3 config:

# multimedia keys
bindsym XF86AudioLowerVolume exec "amixer -q set Master unmute; amixer -q set Speaker 5- unmute"
bindsym XF86AudioRaiseVolume exec "amixer -q set Master unmute; amixer -q set Speaker 5+ unmute"
bindsym XF86AudioMute exec /home/mononofu/bin/mute.sh

bindsym XF86MonBrightnessUp exec "/home/mononofu/bin/brightness 0.1"
bindsym XF86MonBrightnessDown exec "/home/mononofu/bin/brightness -0.1"

Additionally, the brightness script is called once a minute by cron to adjust the color temperature automatically for the night.

Tags: misc

© Julian Schrittwieser. Built using 開板. Theme by Giulio Fidente on github. .