usb mount and policykit [EN]

When you’re not on the ‘Desktop Environment‘ side and rather be in light linux config, you have to deal with annoying little problems. I’m using DWM as my tiled window manager and loving it for years. It’s fast, flexible and fun. My linux desktop is up and running after a few seconds… (ok, thanks also to the ssd 🙂 ).

But, after I upgraded to Ubuntu 14.04, I’ve lost the ability to mount my usb disks with the file manager (same problem with Nautilus or Thunar). I’m getting this frustrating “not authorized” message.
My work around was to ‘pmount’ the disk. It works but I need to search for the right device before, with dmesg, then provide the right syntax. Not so fun.

After digging a while, I found out that authorizations are managed with policykit. So after reading man page after man page, posts after posts, I found a way to easily mount my usb disks in my file manager.

Just edit a new policykit config file :

sudo nano /etc/polkit-1/localauthority/50-local.d/55-myconf.pkla

The number and the .pkla extension are mandatory to respect. The name ‘myconf’ is as you will.
Inside this file, insert those lines :

[Dealing with disks]
Identity=unix-group:plugdev
Action=org.freedesktop.udisks2.filesystem-mount;org.freedesktop.udisks2.eject-media;org.freedesktop.ud$
ResultAny=yes
ResultInactive=yes
ResultActive=yes

Now, we have to restart DBUS as it’s the service that launch the polkitd daemon

sudo restart dbus

If you launch, as I do, gnome-settings-daemon manually, you need to relaunch it after dbus

gnome-settings-daemon -r &

That’s it ! Plug a usb drive and use your file manager to browse it. No more ‘not authorized’ message !

Video background [EN]

Forget large background image for your web site. Now, comes video time.

So you want to put a nice video as background of your site but don’t know how to do ? “Fear you must not” said Yoda as it’s really simple.

First, have a look at the effect in action. Nice, isn’t it ?

First thing first, the html :

<video src="your-video.mp4"></video>
<div> your fantastic text here </div>

Now, the css magic :

video {
  z-index: -999;
  position: fixed;
  min-height: 100%;
  min-width: 100%;
}

The z-index indicates that the video layer is in the background. Everything with a higher index will appear above.

The position fixed is mandatory, to make sure the overlay plays well.

Finally, ensure that the video dimension takes all space available, with the min height and width tags to 100%.

If you would like to have your text centered horizontally and vertically, just add this css :

html, body { width: 100%; height: 100%; }
body {display:table;}
div {display: table-cell; vertical-align: middle; text-align: center;}

And that’s all !

This method works on all major browser : I tested it on Firefox, Chrome and Safari. It also works unmodified on IE9 !