Hibernate in Ubuntu 14.04, with iwlwifi

Update: After a lot of troubleshooting and testing different combinations of my kernel parameters; I conclude that it works a lot better when leaving pcie_aspm=force (think I got it from an Arch wiki?), and also never resume when docked if the computer was hibernated on battery. This seems to be working even with the linux-image-generic-lts-xenial kernel. You can check this pastebin with the results and combination that I’ve tested.

To enable hibernate in the menu, create /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla with the following content:

[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
ResultActive=yes

[Re-enable hibernate for multiple users by default in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate-multiple-sessions
ResultActive=yes

Update /etc/default/grub and add RESUME parameter set to your swap partition in GRUB_CMDLINE_LINUX_DEFAULT. Example:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i915.enable_fbc=1 i915.enable_rc6=7"

Don’t forget to run sudo update-grub2.

Check if iwlwifi has any dependencies:

$ lsmod | egrep "^iwlwifi"
iwlwifi               196608  1 iwlmvm

Add, in this case, iwlwifi and iwlmvm to /etc/pm/config.d/modules:

SUSPEND_MODULES="iwlmvm iwlwifi"

Create /etc/pm/sleep.d/99_wpa_supplicant:

#!/bin/sh

case "$1" in
resume|thaw)
/usr/bin/pkill wpa_supplicant
;;
esac

Don’t forget to make it executable, chmod +x /etc/pm/sleep.d/99_wpa_supplicant.

Killing wpa_supplicant on resume and thaw is needed due to bug #1311257.

And lastly, if you have TLP, make sure to restore previous device state on startup:

$ egrep "^RESTORE_" /etc/default/tlp
RESTORE_DEVICE_STATE_ON_STARTUP=1

Note: I had hibernate working perfect, but then I upgraded to linux-image-generic-lts-xenial which caused KernelOops on every thawn. After reverting back it worked great again. I’m guessing the reason is that the gfx stack (xserver-xorg-video-intel-xenial etc.) isn’t available in 14.04 (yet?).

Build i3-gaps in Docker

Automated way

So, the very automated way:

git clone git@github.com:mgor/docker-ubuntu-i3-gaps-builder.git
cd docker-ubuntu-i3-gaps-builder/
make

Packages available in packages/.

Build environment

First, get the build environment and start it:

git clone git@github.com:mgor/docker-ubuntu-pkg-builder.git
cd docker-ubuntu-pkg-builder
make

Dependencies

Install the needed dependencies:

apt update
apt install libxcb1-dev libxcb-keysyms1-dev \
libpango1.0-dev libxcb-util0-dev libxcb-icccm4-dev \
libyajl-dev libstartup-notification0-dev \
libxcb-randr0-dev libev-dev libxcb-cursor-dev \
libxcb-xinerama0-dev libxcb-xkb-dev libxkbcommon-dev \
libxkbcommon-x11-dev
apt-get build-dep i3

Build

Get i3-gaps from github[0].

git clone https://www.github.com/Airblader/i3 i3-gaps
cd i3-gaps

If you want to run on the stable branch:

git checkout gaps
git pull

Build the packages:

debuild -i -us -uc -b

If successful, the packages will be in ../. Transfer them to your host and install.

Customize Ubuntu and Unity

This is mostly a checklist for myself, might end up as a script, who knows?

Applications & Indicators

Unity Tweak Tool

sudo apt-get install unity-tweak-tool

Compiz Settings Manager

sudo apt-get install compizconfig-settings-manager

System Load indicator

sudo apt-get install indicator-multiload

Search for “System Load Indicator” in dash to enable it.

Workspace indicator

sudo apt-get install python-wnck python-appindicator
cd ~/Downloads
wget "http://ppa.launchpad.net/geod/ppa-geod/ubuntu/pool/main/i/indicator-workspaces/indicator-workspaces_0.6.4_all.deb"
sudo dpkg -i indicator-workspaces_0.6.4_all.deb
indicator-workspaces & disown

Right click on the indicator, chose “Preferences” and check “Start indicator at login”.

Redshift

sudo apt-get install redshift-gtk

Unity Launcher

Flatten launcher icons

Remove icon “backdrop” in the Unity launcher, to get a cleaner look.

git clone https://github.com/mjsolidarios/unity-flatify-icons.git
cd unity-flatify-icons
sh unity-flatify-icons.sh

Remove animations and decorations

Start the settings manager by pressing Alt+F2 and entering about:config. Go to the “Launcher” tab and scroll down to the bottom. Set “Launcher Backlight Mode” to “Backlight Always Off” and “Launcher Icon Launch Animation” to “None”.

Theming

Arc Unity/GTK3 theme

wget http://download.opensuse.org/repositories/home:Horst3180/xUbuntu_15.04/Release.key
sudo apt-key add - < Release.key && rm -rf Release.key sudo sh -c "echo 'deb http://download.opensuse.org/repositories/home:/Horst3180/xUbuntu_15.10/ /' >> /etc/apt/sources.list.d/arc-theme.list"
sudo apt-get update
sudo apt-get install arc-theme

Emerald-dark icon theme

sudo add-apt-repository ppa:noobslab/icons 
sudo apt-get update
sudo apt-get install emerald-icons-theme

Source Code Pro font

cd ~/Downlods
wget "https://github.com/adobe-fonts/source-code-pro/archive/2.010R-ro/1.030R-it.zip"
mkdir -p ~/.local/share/fonts
cd ~/.local/share/fonts
unzip ~/Downloads/1.030R-it.zip
fc-cache -f

X11 cursor

Using Obsidian theme which is downloadable from gnome-look.org.

cd ~/Downloads
wget http://gnome-look.org/CONTENT/content-files/73135-Obsidian.tar.bz2
cd /usr/share/icons
sudo tar jxvf ~/Downlods/Obsidian.tar.bz2
sudo update-alternatives --install /usr/share/icons/default/index.theme x-cursor-theme /usr/share/icons/Obsidian/index.theme 20
sudo update-alternatvies --set x-cursor-theme /usr/share/icons/Obsidian/index.theme
gsettings set org.gnome.desktop.interface cursor-theme "Obsidian" 
sudo cat <<EOF >> /etc/X11/Xresources/x11-common
Xcursor.size: 24
Xcursor.theme: Obsidian
EOF

Miscellaneous

Disable the grid in lightdm

This disables the grid both at login and after locking the screen.

gsettings set com.canonical.unity-greeter draw-grid false
sudo xhost +SI:localuser:lightdm
sudo su lightdm -s /bin/bash
gsettings set com.canonical.unity-greeter draw-grid false

Update a port to a newer version

So, you know a new version of a software has been released, but the port maintainer isn’t fast enough to satisfy your bleeding edge need; here’s how you’d do it:

  1. Update Makefile, variables like PORTVERSION and any other variables used to identify the package to download.
  2. Make sure that it is possible to download the new package and generate distinfo:
    make makesum
  3. Generate the pkg-plist file so that all the new files is correctly pointed out:
    make makeplist > pkg-plist
    awk '/etc\/rc.d\/plexmediaserver/,/^$/' pkg-plist > tmp && mv tmp pkg-plist
    
  4. Then it’s just a matter of re-installing the ports:
    make distclean && make && make reinstall clean

Courtesy of mikec_pt on the Plex Forums [plex.tv].

Terminology as terminal emulator

I was using E16 in the beginning of 21st century, waiting for E17 to come along…

The E17 project has some nice stuff going on, one of them being the terminal emulator (on steroids) Terminology.

How to install it, and make it the default alternative for x-terminal-emulator:

sudo add-apt-repository ppa:enlightenment-git/ppa
sudo apt-get update
sudo apt-get install terminology
sudo update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator /usr/bin/terminology 50
sudo dpkg-divert --local --rename --add /usr/bin/gnome-terminal
sudo ln -s /usr/bin/terminology /usr/bin/gnome-terminal

Read more here [ubuntuhandbook.org].

I haven’t found any way to change which terminal emulator is launched when right clicking on the desktop and choosing ‘Open Terminal’.

You can open System Settings, Keyboard, Shortcuts, Custom Shortcuts and add a new one binding it to ctrl + alt + t:

Name: Open Terminology
Command: terminology