change the number of workspaces in Ubuntu


Every once in a while there is an occasion to reinstall the system, be it a new laptop, drive replacement or just an occasional ‘cleanup operation’.
One of the most useful things are the workspaces and until recently I’ve always installed CompizConfig to help me change the number of them, but I thought there surely must be an easier way to do that. And there is. dconf is a small utility that allows you to change a lot of settings. It is something similar to regedit on windows, albeit you use it via cli.

paths for workspace size are:


I don’t expect you would remember these for a task done once or twice a year. So the simplest thing to do is:

dconf dump /

this will spit out a list of all settings and you just have to search for ‘vsize’ or ‘hsize’

dconf dump / | grep vsize -A 4 -B 4

this should return a part of the db containing your current settings as well as the path, something like this:

active-plugins=['core', 'composite', 'opengl', 'commands', 'copytex', 'mousepoll', 'snap', 'wall', 'vpswitch', 'place', 'grid', 'compiztoolbox', 'move', 'regex', 'resize', 'imgpng', 'session', 'animation', 'unitymtgrabhandles', 'workarounds', 'expo', 'fade', 'ezoom', 'scale', 'unityshell']

to edit it to what you want you have to write to db (remember that the path has to start with ‘/’ but end with a key name):

dconf write /org/compiz/profiles/unity/plugins/core/hsize 5

Hope this helps :)

Ubuntu/Linux and wifi drivers


This is a bit of a rant, but I hope it may help someone at the same time.

I recently purchased a ‘thumb’-sized wifi adapter as I need to share my wifi connection. I’ve read it works with RasPi, so I thought it will work well with my ubuntu based set up as well.

As you might have guessed it was not to be. I have a Dell Inspiron 7437 and the old XPS17 (702L). Both running ubuntu 14.04, with the same kernel.

The adapter in question is the D-Link DWA-121 (I thought that if I go with an older adapter I will have better chances of it working out of the box).
My trusty XPS17 did not disappoint, plugged the adapter and it worked without an issue. Come the Inspiron though and there was nothing.
My first port of call was to upgrade the kernel to 3.16 (newest atm). This did not help. I then started reading on the issue and came across a dkms based solution by Vincent T that worked like a charm.

Important things to note are the differences in the two laptops, which ultimately are the cause of this disparity. The main one being UEFI (inspiron) vs BIOS (XPS)

Take care.

Check if nVidia is running (linux-optimus-bumblebee)


I recently downloaded 0AD to check it out and the first time I started it my experience was dreadful. I immediately knew what has happened (My Dell XPS laptop has an nVidia card with Optimus). I have not started the game via “optirun”. This fact actually spiked my curiosity as to how to check if the optirun is actually using the nVidia card and not the built in Intel one?

When you actually do a search on the subject you may find a lot of stuff about glxgears. This however is not a test at all and in my case it actually shows the same frame speed irrespective of whether optirun is used or not.

Having said that I’ve stumbled upon a great solution, use inxi: (I had to install it on Ubuntu, however according to the post I have found it is already installed on Linux Mint)

So how do you check?

$ inxi -Gx
$ optirun inxi -Gx

Outputs should be different, in the first case you should see Intel and the second one should provide you with info about your nVidia card.

Take care.

Source: FunTechTips

Crontab’s predefined definitions


While working on my “guestnet” bash script I run into one significant issue “nmcli” has to be run either by root or with sudo.

There were two options I was aware of to solve this issue:

  • grant password-less sudo access to this command to my user
  • have root execute the script on every boot

As I did not feel comfortable with option 1, I started looking for possible ways to execute the second one.

This was not hard at all, although it took me a bit of time to find out. Cron has predefined definitions, that one can use, see wikipedia. I suppose, if I read man pages for cron I would know that too :)

Anyway, this is much better than my initial idea of having cron running every 5 minutes to check if network is up and if not to bring it up.

Use @reboot for anything that you want to execute at reboot!
Having said that, if you don’t need sudo, you may as well use .desktop files in ~/.config/autostart/

Take care.

Ubuntu connection sharing as access point (guestnet bash)


Recently, I was working on my guest network (my router broadcasts at 5GHz, my media server rebroadcasts at 2.4GHz), which I need so that some of my legacy devices can have access to the internet and for any visitors I might have, so that they can use wifi, but not receive access to my proper network and its shares. It also is important that the new network is in access point (ap) mode as that is a requirement for most mobile devices.

Most, if not all tutorials for Ubuntu (mine is 14.04) you find will tell you to install KDE GUI network manager. That’s the last thing I wanted to do.

Once you create a hotspot (if you don’t know how to, please do a search) it will most likely be ad-hoc. To change it open your hotspot file in the text editor:

vim /etc/NetworkManager/system-connections/Hotspot

You will find a list of config items, but one of major importance is “mode”. Make sure it says:


on top of that, if you would rather have WPA2 encryption add the following (remember to change password):


Feel free to change “ssid” and “id” and rename the connection file to whatever you want and reboot your pc.
After reboot go to your network list and select “create new wifi network”
You should see “connection” dropdown where your “hotspot” should be listed, select that, and click create.

Voila! You now (should) have a hotspot in access point mode providing internet connection to all your android and other mobile devices.

Take care.

P.S. It will need adjustment, as every network has a different uuid, however I have written a bash script that is executed via cron on every reboot to automatically create the guest network. You can find it at github

Mystery of disappearing crontab


I have upgraded my media server to ubuntu 14.04 (from 12.04) and as such I had to edit my backup script.
Shortly after that I have noticed that my cron is emptied every now and then. I traced this back to the reboot. My cron disappears on reboot – shock!

I have an SSD drive and I followed one of many ‘limit wear and tear’ posts, where the author recommends to put /var/spool on tmpfs. Problem with that is that crontab is stored in var/spool/cron/crontabs an tmpfs is memory.

Easy fix!

Take care.

Ubuntu 14.04 unresponsive password prompt


I seem to have a fairly obscure issue with my Ubuntu (running on Dell XPS17 L702x with nVidia GT555M). The problem is that every once in a while, when the screen turns off and it locks the system. I’m unable to enter the password. There is no caret in password field. The first time it happened I turned the pc off, but this time I decided to fight ;)

In my case tty was still available so I logged on an tried startx. This gave me a desktop and a working mouse, but not the full unity, nor were there any open windows from the programs running in my session. Back to terminal I tried unity. This at first was disappointing as nothing happened. Programme was running in the terminal, but that’s about it (contrary to startx which immediately gave me gui). I tried to run it again, but this time, after I started it, I moved back to gui (Ctrl+Alt+F7).

Another potential loss of work/data has been averted. I had to enter the keyring password and was back in, with all my open programmes still running and unsaved data intact.

Take care.

Ubuntu 12.04 to 14.04 upgrade (‘Failed to start session’ error)


I have recently upgraded on of my computers from Ubuntu 12.04 to 14.04 and was confronted by the ‘Failed to start session’ error.

I could log in from the terminal, but going back to gui I was still presented with the log in screen
(Ctrl+Alt+F1 => terminal, Ctrl+Alt+F7 => gui)

In my case there have been a bunch of unmet, read not installed, dependancies for ubuntu-desktop, and solution was provided after the list of them.

To verify that’s the case try sudo apt-get install ubuntu-desktop
and then go with sudo apt-get -f install

Take care.

use rsync to back up local files


As I was keeping various parts of my backups on different hard drives and different computers/network drives I thought it’s time to unify this and I bought a pair of 2TB hard drives. I copied all the files, duplicated on the other drive and sat down to readup on the available back up solutions. In the end I chose the simplest one: RSYNC run via cron on a daily basis.

Below are the contents of my shell script, which is run by cron at 3 am every day.

all flags used here are explained in the rsync --help and manpages, backup directory is a current day of the month, so it get’s removed if it exists, giving me a one month’s backup facility. All output of this script is sent to a log file in a crotab, but it could be done in this script as well.

Take care.

UPDATE: One thing that is important to note are the final slashes in the $SYNCFROM and $SYNCTO. What will be transferred depends on them. If $SYNCFROM was to be “/media/Ext1″ (note missing final slash) then Ext1 would be considered a directory to be transferred and after transfer you would end up with /media/Ext2/Ext1, wherease in the code example above contents of /media/Ext1 directory are matched against contents of /media/Ext2 directory.

Loop through and lint php files via cli


This is a quick way to use php native linter to check files in your project.

for i in find path/to/your/project -name "*.php"; do php -l $i >> ./lint; done

What it does is it loops through every php file it finds in the given path and runs it through php linter, outputting path and status to the file “lint”.
Unfortunatelly, it will break on any file with errors, so you will have to fix the errors and run it again.

If you have any suggestions as to how to prevent this let me know via Twitter

Take care.

Using Vagrant


I’m not going to give you a tutorial on how to use vagrant, there have been plenty of people before me who have done a great job. I will share my bash scripts on github soon though.
The most important thing I was going to say is that you don’t need to learn Ansible, Chef or Puppet to make the most out of Vagrant. Yes, it is nice to learn basics of at least one of them and I have that on my schedule, but basic bash knowledge will take you far enough in no time.

Take care.

Jolla – after 2 months


I’ve had the privilege to own Jolla since 16th of December, here is my review of the phone after using it for two months.

Good things:

Swipe based UI – you probably have read reviews from various sources (techcrunch and the likes) saying how hard the navigation is, the matter of fact is that one has to be well, retarded to consider the UI hard to use. After a day or two you will be trying to use the gestures on other touch enabled devices and it will actually be quite annoying that they don’t support them.

Battery life – ever since the firmware upgrade the battery life is so freaking awesome that I doubt you will find a better one on the market. I tend to charge it every 3 days (maximum was 99hrs) and there are people reporting 4+ days of usage.

Mallit based keyboard – Jolla’s virtual keyboard is gorgeous and really nice to use. I admit I got used to swype on Samsung, but this is the second best thing.

Developer mode – No other device gives you access to the built in console. You can ssh to the device too.

True multitasking – every application you open and do not close (yes, you can close an application on Jolla) is running in the background. What’s more, you get up to 9 active tiles, which display changes to the apps, but also allow you to perform most common functions without going back into the app itself (example would be pause or play next song, update mailboxes, or refresh weather tile)

CLI based tools – I did not have time to play with the mer distro too much, but I did notice that Jolla comes with git and sqlite installed. You can get ruby, postgresql, midnight commander, emacs and many more from Possibilities are endless.

Software – There is enough applications in the Harbour (Jolla Store) at the moment, yes, you won’t count millions, not even thousands, but the matter of fact is that pretty much every person uses the same 50 apps, so why would you need the other million of the rubbish ones?
If you do need rubbish there is always Android VM, which allows you to run most of the Android apps. Yandex store is installed and if you are adventurous and feel the need for google store there are tutorials with instructions of how to install Play store.

TOHs (The Other Halfs) – This is a brilliant concept of replaceable, nfc enabled back-covers which are capable of additional functionality. People have already built a wireless charging one and there is a “home made” qwerty keyboard one as well. Other concepts where better camera, external battery, etc.

Negative side of SailfishOS:

Sailfish has only one issue – It’s young, it’s still in beta and there are things that will annoy.
1. Occasionally, emails accessed from notification screen will display white screen (you have to swipe back to email list an enter again)
2. Calendar does not have every x weekday of the month repeat setting
3. WiFi to mobile network change is not as smooth as one would expect (or is used to from other devices)
4. No distinction between contacts home/work/other phone number in the recent connections list (which may be costly if your friends home number is in another country)

There is probably more, but these are the things I’ve found annoying.

The beauty of Jolla comes to light with those issues though. The company has set up a service where users can voice their concerns, propose new features, ask for changes and help one another. And what’s even more important, Jolla listens. Try that with Google, Apple or Microsoft.

In conclusion:

It’s a mobile device like no other. Any linux fan should get one, any open source fan should get one, any developer should get one.
Should a casual user get one too? Well, if one only cares about shitty bird games and giving away all your personal information to the likes of google, facebook and apple then you might be served better by other companies (I personally would say no to such a person, however most of the apps required to satisfy such person are available via Android VM on Jolla and more devices sold means more devices in the future). Having said that, a person I just described might feel annoyed by SailfishOS in it’s current state.

In the end I feel that it’s better to support a company built on a trust between customer and vendor rather than give away all your private information to the spying machine of the government and/or the hypocrites from Mountain View, Cupertino or Redmond.

and because of that I bought another Jolla for my wife :)

Remove x number of files with name y


I’m playing with my vagrant setup script and learning new command line ‘tricks’. Here is one of many ways in which you could remove x number of files with a certain name:

ls -f | grep | head - | xargs rm

So if we want to remove 1 file named test, we would do:

ls -f | grep test | head -1 | xargs rm

Take care.

Date of the first ‘such’ day of the month


I’ve been doing a little tidy on my drive and I came across a little method I wrote some 2 years ago. It returns the first ‘such’ day of the month (meaning, date of the first Monday, Tuesday, Wednsday, etc). I thought it might come in handy to someone. If memory serves me right this code has been ‘battle tested’, but I don’t guarantee it being bugless. Give me a shout on twitter if you find something.

Take care.

Change colour of twitter header


Some of you probably have noticed that twitter refreshed their design. For those who, dislike it I have a simple greasemonkey script to edit top header to whatever colour you like.


Multiboot is a… challange


I always thought multibooting was easy. One partition for windows, one for linux. Over the weekend I thougth I will install a third OS and I had to shuffle things about. I ended up messing up both of them. No problem I thought, I will clear up some space, install, reinstall all will be good. It ain’t so. First I thought I will get rid of windows – in the end I no longer have time to play games, what’s more, with the advent of steam on Linux, my only reason to keep that OS is silly. So it’s gone :)
That, however did not end my troubles, cfdisk keeps complaining about overlapping partitions, it does so even though I have removed those partitions (unless it complained about swap starting on the begining of the extended partition [something to check tomorrow]). Having said all that I don’t think I will be wasting my time though.

My advice is -

If you have more than one OS and your partitions are not in the best configuration to add a third one, do yourself a favour and do one of the following:
a) install the third OS on a new hard drive
b) backup important data, wipe the drive and reinstall all of the OSes

In the end you will either save yourself a lot of time to start with or you will save yourself a lot of headaches in the long run.

Take care.

Create a bootable pendrive with dd


I’ve decided to jump into the deep water and switch from Ubuntu to ArchLinux
I will tell you more about it once I actually have it on my pc (see my Recipe for a (not so) kick ass weekend in 10 steps). Anyway, in case you ever wonder how to create a bootable pendrive here is how:

1. first, plug in the pendrive and check device number

(sudo) fdisk -l

2. second, make sure the drive is empty (let’s assume your pendrive is /dev/sdc)

(sudo) dd if=/dev/zero of=/dev/sdc

3. copy the .iso file to the pendrive (let’s assume you have it in ~/Downloads)

(sudo) dd if=~/Downloads/file.iso of=/dev/sdc

P.S. Please note that there is no digit after the sdc. (Most common reason for “missing or corrupt isolinux.bin” error.
Also, I’ve read that To do so for Ubuntu you first need to convert the .iso to .img

Take care.

Recipe for a (not so) kick ass weekend in 10 steps


The following recipe might shorten your life by more than the time you spend executing it if you have any data you do not want to loose, so think twice ;)

1. Make sure you installed Ubuntu with encrypted home folder.
2. Realise your OS is taking waaaaay too much space, just when you need it to install new distro.
3. Decide to keep /home as a separate partion shared by all linux distros you use.
4. Realise that it is the encryption, which doubles up the space needed by Ubuntu and decrypt it.
5. While moving files about, accidently mess up ownership and permissions on random selection of files.
6. Consider this a minor ‘issue’, install clean version of the distro, move (don’t COPY) important stuff there (rather than to any other drive), as if that new distro on that new partition was invincible to any further cockups.
7. Move along to installing your awesome distro over the broken one, but before you do make sure you have been setting up that new shiny partition with a nice GUI tool and ensure you set it so that it overlaps with another, don’t worry, you will not be told about this until it’s too late.
8. Look at the partition table (which by now is all out of order). Fix it reordering eveything. Reboot.
9. Be greeted by GRUB Rescue… Panic… Do not think… waste an hour trying various bullshit how-to’s
10. Go to bed. Wake up the next day, calmly approach the pc and fix it.

P.S. Remeber to always move your important data off the disk you will be messing up with. Loosing data ain’t funny.

Take care.

Magento: Get value of order item attribute


You can use the following code to access Magento order item attribute in the order grid view or in any other order view.

Take Care,