Some things to do after installing Elementary OS Freya

The latest release of Elementary OS, code-named ‘Freya’ after a Norse goddess[1][2], is sure to attract new users each of whom will have varied experience with Elementary OS. The primary purpose of this post is to assist those who are relatively new to the distribution or Linux in general. I will assume that you know enough about Linux to get your system set up properly (i.e. installing updates and drivers) before following this tutorial.

Install the Elementary Tweak tool

The Elementary Tweak tool will prove to be your ‘go-to’ program when attempting to modify various aspects of your Elementary OS experience. To install the tweak tool in Freya, run the following commands in a Terminal.

sudo add-apt-repository ppa:mpstark/elementary-tweaks-daily
sudo apt-get update
sudo apt-get install elementary-tweaks

After the above commands have finished executing, you will find the Elementary Tweak tool under your System Settings.

Change your window controls placement

You may find that the standard Elementary OS window controls are not to your liking. To change the placement of your window controls, open your tweak tool by navigating to System Settings > Tweaks. Once there, navigate to the ‘Window Controls’ menu and select an operating system that is familiar to you. Personally, I prefer the window controls found in Ubuntu (close, minimize, and maximize on the left) so I selected OS X.

Elementary OS window control placement

Remove the single-click file function

If you have opened your files folder in Freya, you may have noticed that you only have to click the file once to open it. While this may prove useful after further acquainting oneself with it, I decided to revert to the standard of requiring a double-click to open files. This can be achieved by navigating to your tweak tool (System Settings > Tweaks) and deselecting the single click function under the ‘Files’ navigation item.

Elementary OS single-click function

Install Oracle Java via Webupd8

To run some of your applications, you may find that you need to install Java on your fresh Elementary OS install. This can be done multiple ways, however I personally prefer using the Webupd8 method[3]. Run the following commands in a Terminal to install Java 8 via Webupd8.

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

Install LibreOffice

LibreOffice comes pre-installed on many other Linux distributions but you will have to install it manually on Elementary OS Freya. Unlike the previous programs, LibreOffice can be found in the Software Center, however I personally prefer to install it via Terminal. To install LibreOffice, open a Terminal and run the following command.

sudo apt-get install libreoffice

Install the Chrome browser

Freya ships with the lightweight Midori browser pre-installed. Although Midori is generally considered to be a good browser, I personally prefer Google Chrome. To install Google Chrome, you should head over to and download the appropriate .deb package.

Please note that sometimes Midori will save the 32bit .deb file even though you requested the 64bit version, double check that your file mentions 64bit and not i386. To see the progress of your download, navigate to the Settings gear icon in the top right of Midori and select the ‘Tansfers’ option. You will get errors if you try to open a .deb file that is not fully downloaded.

Once the .deb file is downloaded, click it (or double click if you have disabled the single-click function) and you will be brought to the Software Center. Select install and viola! You will have Chrome installed.

Prevent double icons in Chrome

When you lock Chrome to your bottom dock (formally called Plank) you may notice duplicate icons when you instantiate a new window of Chrome. The duplicate icon is functional, however it is heavily pixelated and seemingly has nothing to do with the icon you locked to your Plank in the first place. Luckily, the solution for this is relatively simple[4]. Open a Terminal and run the following command.

cp /usr/share/applications/google-chrome.desktop ~/.local/share/applications

After the above command has executed, edit the desktop file using the following command.

nano ~/.local/share/applications/google-chrome.desktop

Use your arrow keys to navigate the cursor below ‘Name=Google Chrome’ and insert the following line.


The finished product should look like the screenshot below. Don’t forget to save the file! Use the following sequence of commands [Ctrl+o] [Enter] [Ctrl+x].

ElementaryOS Chrome duplicate icon

After editing the .desktop file remove the Chrome icon that you locked to your Plank originally and shut down every instance of Chrome. With no instances of Chrome open, open a new instance of Chrome and lock it to Plank. You should not see double Chrome icons ever again!

Install MenuLibre

If you’ve been sequentially installing every program listed in this post, you may notice that your applications menu is becoming a bit crowded (thanks LibreOffice). Fortunately, this is relatively easy to fix by using the MenuLibre tool. You can install MenuLibre by opening a Terminal and running the following commands.

sudo apt-add-repository ppa:versable/elementary-update
sudo apt-get update
sudo apt-get install menulibre

Once the above commands have finished executing, you may open your MenuLibre tool by searching for “menu” in your applications search bar.

To hide a particular application from your applications menu, search for the name of the application within the MenuLibre search box. Once you have found the application you would like to hide, select it and check the option that says ‘Hide from menus’. Please note that you will still be able to find the application by searching for it in the applications search bar.

ElementaryOS hide applications with MenuLibre


Elementary OS has a beautiful uniqueness about it, however switching operating systems is hardly ever easy. I hope this post has helped you find some familiarity with your new Elementary OS Freya installation and that you now feel somewhat comfortable with your new OS!

Further reading

Install Spotify and listen to some tunes with this tutorial.


[1] <Accessed on April 21, 2015>

[2] <Accessed on April 21, 2015>

[3] <Accessed on April 21, 2015>

[4] <Accessed on April 21, 2015>

Subclassing an abstract class

From the Oracle Java documentation:

An abstract class is a class that is declared abstract—it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed.

Abstract classes can be useful where multiple classes share similar methods or fields[1]. In some programming scenarios, multiple classes should always implement a common method from a superclass. In such cases, declaring the superclass and common method as abstract will ensure consistent behavior.

Creating and using an abstract class

For this demonstration, I will be using code copied from my Benson project*. In short, Benson is a small project that enables people to control various electronics via voice. When someone speaks to Benson, he attempts to match the spoken words to keywords within a predefined list of queries. Each query should require different keywords and respond differently from one another however, each query must have keywords and responses. This is the quintessential usage case for an abstract class, see the code below*.

public abstract class Query {

    public abstract List<String> getInputs();

    public abstract Response getResponse();

In the above abstract class, we have two abstract methods. It should be noted that abstract methods cannot have a body. Each potential query that Benson will iterate through will subclass the above Query class. The following code will demonstrate this.

public class Hello extends Query {

    public List<String> getInputs() {

        return Arrays.asList("hello", "hey", "hi", "howdy");


    public Response getResponse() {

        return new Response("Hello there!");



The above code represents a simple extension of the abstract Query class. Notice that both abstract methods defined in the Query class are overridden here and return actual values. Benson will iterate through a list of various subclasses that extend our abstract Query class and use both of the abstract methods to respond to speech. To demonstrate how this is done, review the following code.

List<? extends Query> lexicon = Arrays.asList(new Hello(), 
        new Goodbye());

for (Query query : lexicon) {

    for (String input : query.getInputs()) {

        if (speech.contains(input)) {





The above code demonstrates how Benson responds to speech. First, we create a list of every subclass we want to include in his lexicon. You will notice the Hello class we discussed earlier is defined here as well as a Goodbye class that was not discussed. When Benson receives spoken text, he iterates through this list of Query subclasses in attempt to find the spoken text defined as an input. If the speech matched an input of a Query subclass, the response is retrieved from the Query and then spoken.


Abstract classes can prove to be very useful for writing reusable code. Subclassing an abstract class in place of using different classes with similar methods may significantly reduce lines of unnecessary code. In my opinion, less code translates into less opportunity for bugs so be sure to ask yourself if you can extend an abstract class whenever you find yourself in need of multiple classes that share methods.

Further reading

A JavaCodeGeek example.

A JavaCoffeeBreak example.

A StackExchange discussion.


[1] <Accessed on March 6, 2015>

* All code used in this post is modified from Benson’s source code for simplicity

Instantiate your Fragment by using a static factory method

From the Android developer documentation:

A Fragment represents a behavior or a portion of user interface in an Activity…[y]ou can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own input events, and which you can add or remove while the activity is running.

Fragments were added in API 11 (Honeycomb)[1] in February of 2011[2] and have become a staple in most applications developed since. Typical usage cases of fragments necessitate dynamic variables to be present when the Fragment is instantiated. The most common method to achieve this is using a static factory method within the Fragment itself.

Using the static factory method

For the sake of simplicity, let’s say you have an Activity (ActivityMain) which adds a Fragment (TextFragment) to a container within the activity’s layout to display a particular String. Since the only job of the TextFragment is to display text, we will most likely call the fragment’s setArguments() method every time we want to use it.

TextFragment textFragment = new TextFragment();
Bundle bundle = new Bundle();
bundle.putString("arg_text", "Hello there!");

There is nothing inherently wrong with using the above method to instantiate the TextFragment; however, let’s add the static factory method to the TextFragment and examine the resulting code that utilizes it.

public class TextFragment extends Fragment {
    private static final String ARG_TEXT = "arg_text";

    public static TextFragment newInstance(String text) {

        TextFragment textFragment = new TextFragment();
        Bundle bundle = new Bundle();
        bundle.putString(ARG_TEXT, text);
        return textFragment;


With the static factory method in place, we can now initialize the TextFragment with the following code:

TextFragment textFragment = TextFragment.newInstance("Hello there!");

The resulting use of the static factory method provides three critical improvements over the first method of instantiating the TextFragment. First, the static factory method reduces code by subsequently increasing code readability. The benefits of this should be self-evident. Second, the static factory method ensures the same key is used to add the text to the Bundle. Although this can be alleviated by using a public static final String as a key, having multiple parameters only increases the potential to accidentally mix up keys and their accompanying parameters. Finally, the static factory method helps prevent mundane code errors such as forgetting to call setArguments(). In this respect, reusing the same code to instantiate a Fragment may significantly reduce the time it takes to debug such issues.


The benefits of using the static factory method to initialize your fragments may not be substantial enough to change your existing code; however, it is my humble opinion that it is in every developers’ best interest to adopt specific coding practices that have the potential to ease his/her workload. Practically speaking, the static factory method just makes more sense.

Further reading

A succinct blog post by Alex Lockwood.

A discussion on StackOverflow.

The Android developer documentation.


[1] <Accessed on February 16, 2015>

[2] <Accessed on February 16, 2015>