Remove annoying update pop-ups from Ubuntu Oneiric(12.04)

Open /etc/xdg/autostart/update-notifier.desktop, find NoDisplay and edit it to false.


Update-notifier will then show up in the application gnome-session-properties, where it can be disabled. When disabled, a modified version of update-notifier.desktop is written to ~/.config/autostart/.

Manual recovery from Windows 7 System Image Backup(VHD) using Ubuntu/Linux

Windows 7 system image backup saves the whole windows partition in raw format inside a VHD-file(Virtual Hard Disk). The VHD format is also used in virtual environments, as Hyper-V and Virtualbox. Unfortunately Windows system restore is limited in the capability to restore to another disk layout. But with the use of vdfuse in virtualbox-fuse(universe) it’s possible to restore the partitions manually with a Ubuntu Live system. Then you are in complete control yourself, disk layout etc.

This was done to restore a system disk(crashed SSD) to a regular hard drive which was already in use (contained the backups). The partition on the regular hard drive was moved to make room for the system partitions in the beginning, and the backup was mounted through vdfuse and restored with dd.

Walk through
Prepare a Ubuntu Live system(USB, cdrom, etc) and boot it. Partition the new disk with GParted. In my special case, I moved my existing partition to the right/end of disk. Then I noted the new placement:

sudo fdisk -l /dev/sdb

I’m not sure where Windows system image stores (if it does) the MBR, but you could search through the WindowsImageBackup folder for a file of 512 bytes. Most likely, it manually creates the partitions and writes a fresh boot sector. This can also be done by creating the partitions and using a Windows install disc/USB to repair the startup. There should be a 100MB “System reserved” primary partition with bootflag enabled, and the Windows partition itself. Here I just copy the working MBR from the crashed disk:

sudo dd if=/dev/sda of=/dev/sdb bs=512 count=1

Then I added the already moved partition (the data is still there, we just lost the reference to the partition when moving MBR from sda to sdb).

sudo fdisk /dev/sdb

If you haven’t a moved a partition, skip this step: Reboot computer, use an Windows install disk to check the integrity of the moved partition (chkdsk), when done boot Ubuntu again.

Add universe to apt sources(/etc/apt/sources.list):

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb precise universe can be replaced with your local mirror. Usually the local mirror is named, where XX is your country code (no for Norwegian ->
Update apt and install virtualbox-fuse:

sudo apt-get update
sudo apt-get install virtualbox-fuse

Mount the partition which contains the backup (WindowsImageBackup directory). Find the VHD-files. Create two empty directories and mount the VHD-files(read only):

sudo mkdir /media/f1
sudo mkdir /media/f2
vdfuse -r image-file1.vhd /media/f1
vdfuse -r image-file2.vhd /media/f2

Inside the VHD-files, there is a Partition1 file. This is the raw image of the partition backed up. In f1/f2 you should find one Partition1 file which is 100MB, and another which is the same size as your Windows partition. You could mount these files to look at the backup:

sudo mkdir /media/temp
sudo mount -o loop,ro /media/f1/Partition1 /media/temp
ls /media/temp
sudo umount /media/temp

When ready, use dd to copy its contents to you new partition:

sudo dd if=/media/f1/Partition1 of=/dev/sdXX bs=64M

if is the input file, of is the output file. XX is the partition, one character and one number. sda1 is sda’s first partition, sdc3 is sdc’s third partition.

Umount the partition with the backups, reboot and cross your fingers.

roundcube, sqlite2, ubuntu 11.10 and cherokee

Roundcube only supports sqlite2(RC v0.7.1). Unfortunately Ubuntu 11.10 doesn’t have sqlite2 available in the repos(not sure why, security?), and MySQL/PostgreSQL seems like an overkill for a single user roundcube installation.

Fix: install php5-sqlite and get sqlite2 from natty(11.04). The module is actually loaded by default(/etc/php5/cgi/conf.d/sqlite.ini) but missing in the oneiric package.

apt-get install php5-sqlite
dpkg -x php5-sqlite_5.3.5-1ubuntu7.7_i386.deb /tmp
cp /tmp/usr/lib/php5/20090626+lfs/ /usr/lib/php5/20090626+lfs/
service cherokee restart


XBMC and pulseaudio master volume (Ubuntu 11.10)

If you use XBMC as standalone in Ubuntu(choose it in the login screen), volume control is limited to XBMC as a source in pulseaudio. If you login to Gnome/Unity/whatever, and forget to set sound level to 100% before you logout, XBMC sound volume will suffer from this.

You can control sound volume in terminal with

pactl set-sink-volume # n%

# is a number of a so called sink, which is the same as an output device(analog, HDMI, SPDIF, etc). n% is percentage of volume. This will set sink 0 to 100% volume:

pactl set-sink-volume 0 100%

You need to find out which number your default output device is:

pactl list sinks

Should output something like this:

Sink #0
	Name: alsa_output.pci-0000_00_1b.0.analog-stereo
	Description: Intern lyd Analog Stereo
	Driver: module-alsa-card.c
	Sample Specification: s16le 2ch 44100Hz
	Channel Map: front-left,front-right
	Owner Module: 4
	Mute: no
	Volume: 0:  90% 1:  90%
	        0: -2,75 dB 1: -2,75 dB
	        balance 0,00
	Base Volume: 100%
	             0,00 dB

Play some music and test(music should mute 1 second):

pactl set-sink-volume 0 0%; sleep 1; pactl set-sink-volume 0 90%

To get XBMC set volume to 100% before startup we create a new command called xbmc-standalone-max-volume. Do this as root:

cp /usr/bin/xbmc-standalone /usr/bin/xbmc-standalone-max-volume
nano /usr/bin/xbmc-standalone-max-volume

In xbmc-standalone-max-volume find pulse start section and add three lines after it:

PULSE_START="$(which start-pulseaudio-x11)"
if [ -n "$PULSE_START" ]; then
  PULSE_SESSION="$(which pulse-session)"
  if [ -n "$PULSE_SESSION" ]; then
# set volume to 100%
PACTL="$(which pactl)"
$PACTL set-sink-volume 0 100%

Now edit XBMC session:

nano /usr/share/xsession/XBMC.desktop

Change Exec and TryExec:

[Desktop Entry]
Comment=This session will start XBMC Media Center

You may also do the same with xbmc -> xbmc-max-volume, but when inside gnome you could simply use your keyboard and Alt-Tab, set volume up, and Alt-Tab back.

Howto pause pm-suspend when program is running

I have a backintime running every hour. Sometimes, it’s running when I suspend/hibernate the machine. The suspend will fail, because backintime refuses to suspend. BIT will fail because network is pulled down. Then we have backintime running forever, and suspend/hibernate failing forever too(until you kill BIT manually).

This script will wait until backintime is done, and then let the computer suspend/hibernate.


case "${1}" in
    while pgrep -f "/usr/bin/backintime "; do
      sleep 5

exit 0

Remember to make the file executable.

disable screen saver when looking at flash videos(youtube, vimeo, etc)

Run this script at startup of Gnome.


# cleanup any bad state we left behind if the user exited while flash was running
gconftool-2 -s /apps/gnome-screensaver/idle_activation_enabled --type bool true

sleepcomputer0=`gconftool-2 -g /apps/gnome-power-manager/timeout/sleep_computer_ac`
sleepdisplay0=`gconftool-2 -g /apps/gnome-power-manager/timeout/sleep_display_ac`

# run loop forever
while true; do
  # interval between checks
  sleep 30
  # make id variable of window in focus
  current_window_id=`xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" | cut -d" " -f5`
  # make pid array of every command with libflashplayer in full(-f) command
  for pid in `pgrep -f libflashplayer` ; do
    # check if window in focus is our libflashplayer
    if [ $pid == `xprop -id $current_window_id | grep PID | cut -d" " -f3` ]
      then SS_off=1

# check to see if xine is being used
#  if pgrep xine > /dev/null; then
#    SS_off=1
#  fi
# check to see if current application is fullscreen
#  current_window_id=`xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" | cut -d" " -f5`
#  if xprop -id $current_window_id | grep "_NET_WM_STATE_FULLSCREEN" > /dev/null; then
#    SS_off=1
#  fi

  # read current state of screensaver
  ss_on=`gconftool-2 -g /apps/gnome-screensaver/idle_activation_enabled`

  # change state of screensaver as necessary
  if [ "$SS_off" = "1" ] && [ "$ss_on" = "true" ]; then
    gconftool-2 -s /apps/gnome-screensaver/idle_activation_enabled --type bool false
    gconftool-2 -s /apps/gnome-power-manager/timeout/sleep_computer_ac --type int 0
    gconftool-2 -s /apps/gnome-power-manager/timeout/sleep_display_ac --type int 0
  elif [ "$SS_off" = "0" ] && [ "$ss_on" = "false" ] && [ "$turn_it_off" = "1" ]; then
    gconftool-2 -s /apps/gnome-screensaver/idle_activation_enabled --type bool true
    gconftool-2 -s /apps/gnome-power-manager/timeout/sleep_computer_ac --type int $sleepcomputer0
    gconftool-2 -s /apps/gnome-power-manager/timeout/sleep_display_ac --type int $sleepdisplay0


Remove title from Firefox when maximized(Chrome style)

Add this to CompizConfig under “Window Decorations” in the field “Decoration windows”:


Toggle maximize with Alt-F10. If you hide the “Menu Bar”, you can show it with Alt Gr-F10. This allows for semi-full-screen-mode.

This was tested with Firefox 4 on Linux Mint 10. Install with:

sudo add-apt-repository ppa:mozillateam/firefox-stable
sudo apt-get update
sudo apt-get install firefox ubufox


Roundcube and automatic addressbook

With automatic addressbook plugin on roundcube, I could not create the MYSQL table. I’m running Ubuntu 10.04 LTS, with mysql-server 5.1.41. Got error message:

ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--!40008
)' at line 15

Found this solution at

Use this command to create table:

CREATE TABLE `collected_contacts` (
  `contact_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
  `del` tinyint(1) NOT NULL DEFAULT '0',
  `name` varchar(128) NOT NULL,
  `email` varchar(128) NOT NULL,
  `firstname` varchar(128) NOT NULL,
  `surname` varchar(128) NOT NULL,
  `vcard` text,
  `user_id` int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`contact_id`),
  KEY `user_collected_contacts_index` (`user_id`,`email`),
  CONSTRAINT `collected_contacts_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE