Wednesday, January 28, 2015

How to bring back the "New Document -> Empty Document" menu in Gnome 3

Long time ago, the Gnome developers removed the right-click menu entry "New Document -> Empty Document" in Nautilus (the file browser). The solution to fix this is easy therefore it seemed not necessary to post it.
However, last week a friend told me that he hates Gnome 3 so much and as I asked why, one of the reasons was that this menu entry is gone.
So here is the solution (so that you start to love Gnome 3!):

  1. Create a folder called "Templates" directly into your $HOME directory if it does not exist
  2. Put a empty text file in there and name it "Textfile" (or anything else)
  3. Do a right click anywhere and be delighted with seeing "New Document -> Textfile"

The cool thing on this approach is that you can put any file with any content into the Templates directory.
Eg. you can put a template python script in there with the headers and scaffolding already in place, or a presentation with the company branding already applied... anything! Its universal!

Tuesday, January 20, 2015

Create a custom sandboxed webapp in Firefox

Google, Facebook, Twitter and others depend on getting as much information about you as possible and therefore use your account information to track and profile you not only on their services but also on 3rd party websites to fit the advertisement to your interests.
On this website you can check out how unique your browser is and how easy it is to identify and track you.
To make this a bit harder for them and save yourself the trouble of constantly logging in and out I will show how you can create a webapp with an independent profile for your Linux desktop.


It is very easy to create a custom launcher for each webapp and Firefox allows to create multiple profiles since a very long time. So in principle it is very simple and easy!

Let's do a webapp for Facebook! First, create a new Firefox profile, which will be used for the "Facebook-only-Firefox". Therefore, start the Firefox profile manager by typing:

$ firefox -ProfileManager

Now add a new profil 'facebook' and close the manager again. Next, create the launcher by copying the original Firefox launcher to the $HOME directory and rename it:

$ cp /usr/local/share/applications/firefox.desktop ~/.local/share/applications/facebook.desktop

Then we edit the facebook.desktop file and set the launcher name, the icon and the process how the application will be started. I suggest to get a nice icon for your application from the web and save it to ~/.icons/facebook.png. If the folder does not exist yet, create it!

$ vim ~/.local/share/applications/facebook.desktop

[...]
Name=Facebook
Exec=firefox -P facebook -new-instance www.facebook.com
Icon=facebook.png
-P profile-name opens firefox with profile "profile-name"
-new-instance opens Firefox in a new instance, as a separate process
Icon= If the icon is stored under ~/.icons/ there is no need to enter a path!

To immediately see you application in gnome-shell you can press Alt + F2 and type "r" and ENTER. This reloads the gnome-shell. Now you can use Facebook in its own browser, but don't forget to log out in your everyday browser ;)
To hide the tabs and therefore save screen space I recommend the Hide Tab Bar With One Tab addon.

NOTE:
There is one tiny problem you have to consider and which I didn't find a work around yet:
If you start the Facebook webapp and want to open your Standard-Firefox afterwards, it doesn't select the right profile. You could either change the firefox.desktop by copying to it to your $HOME as above and adding the default profile to the Exec line:

$ cp /usr/local/share/applications/firefox.desktop ~/.local/share/applications/firefox.desktop
$ vim ~/.local/share/applications/facebook.desktop

[...]
Exec=firefox -P default -new-instance
or you have to start the default firefox first and then open the webapp. Do you know a solution to this?
Happy socializing 2.0!

UPDATE:
Mozilla develops a webapp framework for their Marketplace that works in a similar fashion like we show here: Separate profile directory, minimal UI, own launcher,... The only difference is that they also create a separate binary and therefore do not have the multi-instance problem. A third-party developer (dietrich ayala) created an extension, "Standalone" which uses this framework to create webapps from any page on the web. Awesome!

Thursday, January 8, 2015

Customize SSH login

After you have set up a secure  SSH server maybe you would like to customize your login, to look a bit more personal. e.g. like the penrose triangle

     ____  ____  ____  ____                      ______________________
    /\   \/\   \/\   \/\   \                    /\                     \
   /  \___\ \___\ \___\ \___\                  /  \    _________________\
   \  / __/_/   / /   / /   /                  \   \   \                /
    \/_/\   \__/\/___/\/___/                    \   \   \__________    /
      /  \___\    /  \___\                       \   \   \    /   /   /
      \  / __/_  _\  /   /                        \   \   \  /   /   /
       \/_/\   \/\ \/___/                          \   \   \/   /   /
         /  \__/  \___\                             \   \  /   /   /
         \  / _\  /   /                              \   \/   /   /
          \/_/\ \/___/                                \      /   /
            /  \___\                                   \    /   /
            \  /   /                                    \  /   /
             \/___/                                      \/___/

 (source: wikipedia)


You can also create an ASCII Art from any picture. There are some sites where you can upload your picture and create an ASCII pic out of it, look here. Once you connect via SSH e.g.  > ssh user@myraspberry.pi you see the welcome text or logo, which is defined in your sshd config. First you have to create the file containing the hello message, e.g.  

 $ sudo vim /etc/ssh/welcome.msg  
     ____  ____  ____  ____                   |
    /\   \/\   \/\   \/\   \                  |
   /  \___\ \___\ \___\ \___\                 |
   \  / __/_/   / /   / /   /                 |
    \/_/\   \__/\/___/\/___/                  |
      /  \___\    /  \___\                    |
      \  / __/_  _\  /   /                    |
       \/_/\   \/\ \/___/                     |
         /  \__/  \___\                       |
         \  / _\  /   /                       |
          \/_/\ \/___/                        |
            /  \___\                          |
            \  /   /                          |
             \/___/                           |
WELCOME TO MY RASPBERRY PI!
PLEASE AUTHENTICATE!


In the next step, we have to tell our ssh daemon where to find this welcome message, therefore we have to change the 'Banner' entry in the sshd config to the location of our welcome message:

$ sudo vim /etc/ssh/sshd_config 
[...]
Banner /etc/ssh/welcome.msg


After that, we have to restart sshd:

$ sudo service sshd restart

We can also add another welcome message for the users, which are already authenticated by editing the MOTD file:  

$ sudo vim /etc/motd 

Once finished, we again have to restart the ssh daemon on the raspberry and then we can try this thing out. On connecting to our pi we should now see the pi ASCII logo and after entering the password, we should be informed about the news in our motd file.