# Least Action

Nontrivializing triviality..and vice versa.

## Intel Skylake graphics flicker on Arch Linux

Recently, I had the opportunity to install Arch Linux on a brand new laptop based on the Intel Skylake architecture. Immediately after installing Google Chrome, I began to experience intense screen flicker. I came across a post on the Arch Linux forums where someone suggested the following solution to this problem:

1. (As root), create a file named 20-intel.conf in /etc/X11/xorg.conf.d.
2. Open the file in your favorite editor (I use vim, so steps 1 and 2 can be combined) and enter the following lines in the file
Section "Device"
Identifier  "Intel Graphics"
Driver      "intel"
#Option      "AccelMethod"  "sna"
Option      "TearFree"    "true"
Option      "DRI"    "3"
EndSection


Now, restart X Windows, and the flicker should go away.

Written by Vivek

April 10, 2016 at 10:34

Posted in Linux

Tagged with ,

## Getting sound to work in Arch Linux

Make the following file in your home directory (~/) and save it as .asoundrc (note the leading .)

pcm.!default {
type hw
card 1
}

ctl.!default {
type hw
card 0
}

Written by Vivek

July 16, 2015 at 11:15

Posted in Linux

Tagged with ,

## ~/.xinitrc and /etc/X11/xorg.conf for Arch Linux Optimus configuration

~/.xinitrc

xrandr –setprovideroutputsource modesetting NVIDIA-0
xrandr –auto
#xrandr –output VGA-1-0 –off
#xrandr –output VGA-1-0 –left-of VGA-I-1 –mode 1920×1080 –gamma 1.2:1.2:1.2
xrandr –output VGA-I-1 –primary –mode 1920×1080
exec startkde

/etc/X11/xorg.conf (to be used with nvidia driver, not otherwise)

Section “ServerLayout”
Identifier “layout”
Screen 0 “nvidia”
Inactive “intel”
EndSection

Section “Device”
Identifier “nvidia”
Driver “nvidia”
BusID “PCI:1:0:0”
Option “ConstrainCursor” “0”
Option “nvidiaXineramaInfoOverride” “1920×1080+0, 1920×1080+0”
EndSection

Section “Screen”
Identifier “nvidia”
Device “nvidia”
Option “AllowEmptyInitialConfiguration” “Yes”
Option “ConnectedMonitor” “CRT-0”
Option “CustomEDID” “CRT-0:/sys/class/drm/card0-LVDS-1/edid”
Option “IgnoreEDID” “false”
Option “UseEDID” “true”
EndSection

Section “Device”
Identifier “intel”
Driver “modesetting”
BusID “PCI:0:2:0”
Option “AccelMethod” “sna”
EndSection

Section “Screen”
Identifier “intel”
Device “intel”
EndSection

Written by Vivek

July 15, 2015 at 02:47

Posted in Linux

Tagged with ,

## Installing Cadabra in Arch Linux

Cadabra is available on the AUR for Arch Linux, but one of the required libraries called conlie, has the wrong upstream URL in the default PKGBUILD.
conLiE.tar.gz is available here: http://www.filewatcher.com/m/conLiE.tar.gz.361170-0.html

A sample PKGBUILD for conlie, which you can edit while installing Cadabra, is listed below. I have changed the md5sum relative to the ones in the original (as of July 15, 2015, it hasn’t been updated).

# Contributor: Dariusz ‘quasi’ Panchyrz <quasi@aur.archlinux.org>

pkgname=conlie
pkgver=2.2.2
pkgrel=2
pkgdesc=”A Computer algebra package for Lie group computations”
arch=(‘i686’ ‘x86_64’)
url=”http://wwwmathlabo.univ-poitiers.fr/~maavl/LiE/&#8221;
install=$pkgname.install source=(http://wwwmathlabo.univ-poitiers.fr/~maavl/LiE/conLiE.tar.gz lie lie.1) md5sums=(‘2e98f252364d43557a322ea7eb677944’ ‘d4f5ad8b87479ef93734eee6d1629190’ ‘a47060395617ed656eaccde1a9e9ee93’) build() { cd LiE make } package() { cd LiE install -D Lie.exe$pkgdir/usr/bin/Lie.exe
install -D $srcdir/lie$pkgdir/usr/bin/lie

mkdir -p $pkgdir/usr/lib/lie for i in INFO.* LEARN.ind do cp$i $pkgdir/usr/lib/lie/ done install -D manual/manual.dvi$pkgdir/usr/share/doc/lie/manual.dvi
install -D README $pkgdir/usr/share/doc/lie-2.2.2/README install -D$srcdir/lie.1 \$pkgdir/usr/share/man/man1/lie.1
}

Written by Vivek

July 15, 2015 at 01:33

Posted in Linux

Tagged with ,

## Connecting to an MSCHAPV2-based wireless network in Arch Linux

Arch Linux comes with “wifi-menu”, but this does not let you connect to a WPA2-based network which requires you to enter both a login-id as as well as a password. Some of these networks use MSCHAPV2, which due its vulnerabilities, is not recommended by the Arch community (see https://wiki.archlinux.org/index.php/WPA2_Enterprise). On the campus I am currently stationed in, we have a MSCHAPV2-based network known as WolfieNet-Secure, the alternative to which is an unsecured wifi connection. The university does not currently offer any Linux support and their instructions for configuring WolifeNet-Secure in Linux work only for Ubuntu (which comes with out of the box MSCHAPV2 support).

This is a quick and fast way to get such a network connection to work in Arch Linux. But this is not the best way, and I strongly suggest using it once to set up Arch Linux but switch to Network Manager once you have X Windows working. This is particularly important if you are behind such a network, cannot get access to a network cable, and must install Arch Linux off the net.

Step 1: Bring up the interface.

ip link set wlp5s0 up

Replace wlp5s0 with your wireless interface.

Step 2: As superuser, create a new file /etc/wpa_supplicant/example.conf, with the following

ctrl_interface=/run/wpa_supplicant
update_config=1

Step 3: Start wpa_supplicant using

wpa_supplicant -B -i wlp5s0 -c /etc/wpa_supplicant/example.conf

Step 4: Create a script which connects to the network.

#!/bin/bash

wpa_cli -wlps5s0 disconnect
wpa_cli -wlp5s0 set_network 0 auth_alg OPEN
wpa_cli -wlp5s0 set_network 0 key_mgmt WPA-EAP
wpa_cli -wlp5s0 set_network 0 pairwise CCMP
wpa_cli -wlp5s0 set_network 0 group CCMP
wpa_cli -wlp5s0 set_network 0 proto WPA2
wpa_cli -wlp5s0 set_network 0 eap PEAP
wpa_cli -wlp5s0 set_network 0 identity “login-id
wpa_cli -wlp5s0 set_network 0 phase1 “peapver=0”
wpa_cli -wlp5s0 set_network 0 phase2 “MSCHAPV2”
wpa_cli -wlp5s0 set_network 0 mode 0
wpa_cli -wlp5s0 set_network 0 ssid “WolfieNet-Secure”
wpa_cli -wlp5s0 select_network 0
wpa_cli -wlp5s0 enable_network 0
wpa_cli -wlp5s0 reassociate
wpa_cli -wlp5s0 status

Save this file in your /usr/bin or your home folder, for instance by an unimaginative name like “wificonnect” and then make it an executable using

chmod +x wificonnect

Step 5: run dhcpcd (this may be optional in some setups)

dhcpcd wlp5s0

Finally, add the script to your system startup. I find it convenient to actually execute it by hand for now. But if you work mostly in X Windows, then doing so manually may be an annoyance.

A drawback of the above script is that your password is stored in plaintext. This is easily fixable, and one can introduce a layer of encryption. Documentation for this is easily available on the internet and is a matter of common knowledge among experienced users of Linux, so I won’t go into this in more detail.

Notes:

1. dhcpcd will usually run by itself if you enabled it using

systemctl enable dhcpcd.service

Another issue is that on some laptops, due to shaky network adapter support, it may be useful to first connect to an open wifi network (if one is available) to get the interface running, before switching over to a secure wifi using the above script.

2. If you have multiple profiles, it may become necessary to change the number 0 which appears after each set_network command in the above script, to 1 or some other number. To verify this, one can run

wpa_cli

and type each line of the above script after removing the leading “spa_ctl -wlp5s0” statements. The add_network command will return a number, which if other than 0, must be entered in the script above.

There may be additional tweaks or caveats, which I may update in future.

Written by Vivek

July 12, 2015 at 21:27

Posted in Linux

Tagged with

## Calligraphic symbols in LaTeX

If you’re unhappy with the way the standard amsmath/amssymb packages display a caligraphic L, and you want a more curly/loopy L for your Lagrangian density, then here’s a way out.

1. Install the package texlive-calrsfs. I had to run “yum install texlive-calrsfs” as superuser to accomplish this on Fedora 20.

2. Declare the following headers above your document


3. The more loopy version of L is now mapped to \La, whereas the conventional version is \Lb.

Hope this helps!

Written by Vivek

July 18, 2014 at 10:35

Posted in LaTeX, Linux

## NVIDIA CUDA on Fedora 20 x86-64 with NVIDIA Optimus

So after weeks of experimentation, and frustration, I think I have finally gotten CUDA to work on my MSI GE 70 2OE-071 laptop. As you may know, NVIDIA Optimus is a technology that enables power-sharing and switching between Intel HD and NVIDIA GPUs on laptops. For some reason, MSI and some other manufacturers have disabled the option to disable Optimus technology from within the BIOS. Now as far as I know, Linux has shaky support for Optimus, and while I had no trouble with any Linux distro on my previous Dell XPS laptops (which did have Optimus) I just couldn’t get NVIDIA discrete graphics to work on my MSI “gaming” laptop, which is a shame, because much of my work involves (or has involved) the use of CUDA, and I am not eager to spend my programming time on Windows.

This is not an exhaustive guide, and I invite suggestions and corrections from users who may stumble upon this blog post. I tried to reproduce the scenario on my own laptop in order to make sure I didn’t miss anything.

Typically there are six stages in NVIDIA CUDA installation on Linux:

1. Get rid of the nouveau driver if you are installing the proprietary NVIDIA driver by hand.
2. Reboot, get to a text mode (sadly, init doesn’t work anymore, so if you’re a old Unix user like me, you have to google this up before you start playing with your system).
3. Install the NVIDIA device driver.
4. Reboot, make sure a basic X configuration works (known as the “graphical mode” nowadays).
5. Install the CUDA toolkit, and set PATH and LD_LIBRARY_PATH variables.
6. Compile CUDA samples.

Now I believe much of the errors you will face in steps 1 through 6 are from a partial understanding of the way the X Server and Linux work, and that is based on my own experience. Playing with Linux can be a humbling experience even for someone who has used it for over a decade! But this is quite a lot of fun if you can document everything, and remember what you did to get something to work. It also helps if you have a system to play with, so if you have issues with installing and re-installing the OS n times before you can get to perfection, then this guide isn’t for you. Sorry!

Stuff I had to get to run the CUDA samples:
gcc-g++ in Fedora
libXmu-devel in Fedora (this installs the libXmu libraries)

<UNDER CONSTRUCTION>

Written by Vivek

April 20, 2014 at 19:16

Posted in CUDA, Linux, Programming