Swapfile instead of a swap partition

First create the file to use for swap. I use /swapfile.

sudo dd if=/dev/zero of=/swapfile bs=1M count=2000

The above command would create a 2 GB file, feel free to adjust the size to fit your need.

Now set the correct permissions on the swapfile.

sudo chown root:root /swapfile
sudo chmod 600 /swapfile

Now setup that file to be used for swap.

sudo mkswap /swapfile

Enable the swapfile.

sudo swapon /swapfile

To have the swapfile automatically loaded on boot, add this to /etc/fstab.

/swapfile none swap sw 0 0

Now if you run free -m you can check that it lists the correct amount of swap.

Show week numbers in the Gnome DateTime Indicator

The date/time indicator in the Gnome3 panel does not show week numbers by default.

To change this run this command:

gsettings set com.canonical.indicator.datetime show-week-numbers true

At least in Elementary OS I found not GUI way of changing this.

Plexgear WR1 configuration on RasPlex

I recently bought a Raspberry Pi 2 for the TV in my sons playroom so that we can watch movies with Plex on our old TV. I got a Raspberry Pi 2 kit that contained all the needed parts:

  • Raspberry Pi 2
  • Transparent casing
  • Power adapter
  • 8 GB micro SD card (preinstalled with Kodi)
  • TPLink USB Wifi adapter
  • Plexgear WR1 remote

Since I want to use it as a Plex client I went with the RasPlex distribution for Raspberry Pi. Works well, easy to install, just DD the image over to the sd card:

dd if=RasPlex-RPi2.RP-1.0.2.img of=/dev/mmcblk0 bs=1MB


Make sure to use the correct output device so that you don't overwrite anything important. You can find the device name with either fdisk or lsblk.

Once up and running I noticed that some of the buttons on the remote did not work. Which made it impossible to go back to the main menu from after starting a movie. I did some searches and found that the remote came with a manual for how to configure the keys using an Kodi add-on. Bummer since I installed RasPlex :)

So after some tinkering I managed to create my own keymap configuration for configuring the remote in RasPlex.

First I enabled the "Enable debug logging" option under Preferences / System / Advanced. Not sure if it was required but I rebooted after that as well. Then I started pressing the buttons that did not work a couple of times.

After that connect to RasPles using SSH, and go to /storage/.plexht/temp and run this command to filter out the keypresses in the log

less plexhometheater.log | grep OnKey

From that output I could see that the buttons that did not work was home and leftwindows.

Then I created created my own keyboard.xml file in /storage/.plexht/userdata/keymaps with the following content:


I assigned the keys Back and ContextMenu, but if you want other actions you can look at the default keyboard.xml file in /usr/share/XBMC/system/keymaps.

VIM save with sudo

A colleague of mine did the mistake of opening a file in vim without using sudo and when he was going to save the file he did not have permissions to do it.

He then googled and found a way to save the file without reopening the file and retyping the changes.

When saving a file in vim you use the :w command, and without any parameters it will save the buffer to the current file. You could also type a filename as parameter which would act like a "save as" leaving the current file unchanged.

You can also type:

:w !sudo sh -c "cat > %"

What is happening here is when using a command as a parameter to :w the buffer is sent as input to that command, which will be captured by cat and then written to %, the percent sign is a symbol for the current file.

You can also add this mapping to your .vimrc file for a nice shortcut

cmap w!! w !sudo sh -c "cat > %"