Wednesday, April 10, 2013

Create a custom launcher icon in gnome-shell

Today, I realised that navigating into a certain folder to start mincraft with a terminal command is much to complicated. A nice minecraft icon within the other installed applications would be great!


All I needed to do was to create a file: ~/.local/share/applications/minecraft.desktop and fill it with such a content:
[Desktop Entry]
Encoding=UTF-8
Name=Minecraft
GenericName=Game
Comment=Block Building Game
Exec=java -Xmx1024M -Xms512M -jar /path/to/minecraft.jar
Icon=/path/to/minecraft/icon.png
Terminal=false
Type=Application
MimeType=text/plain;
Categories=Game;
Name[en_US]=Minecraft
You still need to download a beautiful icon and adopt the two lines in bold (path to your executable and to the icon). Further you need to run
chmod a+x ~/.local/share/applications/minecraft.desktop
to give this file proper rights for execution. This is it! It works for any other application/script too!

Wednesday, February 27, 2013

Tomboy's new sync-server Rainy running on the Raspberry Pi!


As Ubuntu One is shutting down their note-sync service based on the Snowy server, I needed to come up with a solution for this problem. My main thought was: Why should I trust anyone on this again, if it is so easy to build your own "cloud" for syncing notes?
Rainy is still in early development, but already does an awesome job on syncing notes between Tomboy and Tomdoid. Special thanks to Timo Dรถrr for this! Further, the Raspberry Pi (a credit-card sized computer) is the ideal platform for this purpose as it only "eats" 2 Watts per hour and can be easily run 24/7.

How do I build my own note-sync-server?

To create a minimal Debian system on a SD Card for the Raspberry Pi, just follow the steps here: 
http://blog.kmp.or.at/2012/05/build-your-own-raspberry-pi-image/

In summary you need to:
1. Install these dependencies on your computer: 
apt-get install binfmt-support qemu qemu-user-static debootstrap kpartx lvm2 dosfstools
2. Adopt the script (Optional! Just search for the lines and put your things in there!):
x) Change the debian mirror url: deb_mirror="http://http.debian.my/debian"
x) Add the network interface wlan0 for wifi access and use a static IP address of your choice:
echo "auto lo
iface lo inet loopback

#auto eth0
#iface eth0 inet static
# address 192.168.0.4
# netmask 255.255.255.0
# gateway 192.168.0.1

auto wlan0
iface wlan0 inet static
address 192.168.0.4
netmask 255.255.255.0
gateway 192.168.0.1
wpa-ssid MYSSID
wpa-psk MYWIRELESSKEY
" > etc/network/interfaces

    x) Change the password: echo \"root:MYPASSWORD\" | chpasswd
    x) Add packages to pre-install for wifi (you might need other firmware packages!): 
apt-get -y install locales console-common ntp openssh-server less vim wireless-tools firmware-atheros firmware-realtek wpasupplicant
3. Run script: sudo ./build_rpi_sd_card.sh /dev/sdX
4. Put the SD Card into your Raspberry Pi and plug it in. It should automatically connect to your wifi (or lan)!

After you logged in (either directly or over ssh root@192.168.0.4), you will see a typical Linux shell. At first we will have to install the dependencies and necessary packages for our mono based Rainy server:
apt-get -y install libmono-system-runtime2.0-cil libmono-microsoft-csharp4.0-cil libmono-system-componentmodel-dataannotations4.0-cil libmono-system-web2.0-cil libmono-system-web-services4.0-cil libmono-system-data-linq2.0-cil libmono-system-data-linq4.0-cil libmono-system-web-abstractions4.0-cil mono-runtime unzip screen
Then we have to download the pre-compiled Rainy binary, unzip it and change into the directory:
wget http://rainy.notesync.org/release/rainy-0.1.3.zip
unzip rainy-0.1.3.zip
cd rainy-0.1.3
With a text editor of you choice you can edit the settings.conf file to change the user names, passwords, etc. Then start Rainy:
mono Rainy.exe -c settings.conf
If you want to run the server as a background job, I suggest to use screen. A very short explanation on how it works can be found here: http://jjjjango.blogspot.co.at/2013/01/linux-start-long-running-jobs-with-ssh.html

Now open your Tomboy, or Tomdroid and add the new sync server URL:
http://192.168.0.4:8080/<username>/<password>/
If you want to sync from outside your home, you have to redirect the 8080 port of your router to the IP address of the Pi. Further, you have to use the public IP of your router in the sync URL. In case you get a dynamic public IP, you will have to use http://www.noip.com/ or a similar service.

I hope, you know what to do! If not, please don't hesitate and ask your questions in the comments!

Friday, January 25, 2013

Insert a CD image file in gnome-boxes

As I heard about the new Age of Empires II extension "Forgotten Empires" created not by Microsoft, but by an awesome community, I needed to play this game again! I don't like Wine that much as I once got a bunch of viruses having it just installed, therefore I decided to install Windows XP in a virtual machine.
I chose GNOME Boxes as it uses kvm. It was really fast and easy to install, I just needed my Windows-Installer-CD as an *.iso file.

However, I could not find any option to insert another *.iso image file to be mounted in the guest system. The user interface just does not provide to change the CD disc image - so we have to change the kvm options in another way. Open your terminal and type:

$ virsh edit Windows\ XP\ Pro.iso

(If you installed something else than Windows XP you might have to look in the folder .local/share/gnome-boxes/images/ how your machine is called.)
In this file search for the lines saying something like the following and exchange your iso-filename (+path):

<disk type='file' device='cdrom'>
   <driver name='qemu' type='raw'/>
   <source file='/home/tux/AoE.iso' startupPolicy='optional'/>

(If you need help using vim, check this out.)
Save it, reboot your Windows and enjoy having your disc image in the CD drive of the guest!

Friday, January 18, 2013

Linux: Start long running jobs with SSH

Recently I needed to start several long running jobs at my working machine from home using SSH. Unfortunately closing the SSH connection stops all the tasks started in this session.

Therefore we need a tool to start some tasks which will be kept running upon logout: SCREEN
There are tons of tutorials and howtos out there and a man page exists too.
However, here the most important commands and shortcuts:
Start it with typing

$ screen

then start your job, then press Ctr + A, Ctr + D  to detach the job and close the program without killing the running task. Running

$ screen -r

will resume your previous session.

Ctr + D closes the session and kills all tasks.
Ctr + A, Ctr + C opens a new screen "window",
Ctr + A, Ctr + N moves to the next window,
Ctr + A, Ctr + P moves to the previous window,
Ctr + A, Ctr + D detaches the task and closes the window,
Ctr + A, ESC enters scroll mode: use Up/Down/PgUp/PgDn to scroll, ESC again to exit this mode

Friday, November 23, 2012

Windows as Guest in Linux with minimal Software

You have Linux (any distribution, commands below for Debian/Ubuntu) and need to do just one tiny thing with Windows? Therefore you don't want to install thousands of packages and third party packages?
Then follow this quick guide made out of 4 steps and one package you need to install!

Fist install the kvm engine typing this into a terminal:

$ apt-get install kvm

Afterwards change into the directory where you want your virtual harddrive image to be created. The next command will create a *.img file with a size of 8GB.

$ dd if=/dev/zero of=vm_disc.img bs=1024k count=8000

Once this is done, you can boot up your virtual "machine" for the first time - of course with the Windows Install CD "inserted" into your device:

$ kvm -m 2048 -cdrom Windows_XP.iso -boot d vm_disc.img

Remember that you might have to exchange the name of your install-cd image.
Reading the manual of kvm (terminal command: man kvm) I found some nice features like graphical output to a vnc stream, using a specific sound-card, forwarding usb devices,... I am always using following command to start my virtual machine:

$ kvm -m 2048 -hda vm_disc.img -vga std -soundhw ac97 -usb -usbdevice tablet -smp 2 -vnc :0

Afterwards I connect to the vnc stream (localhost) using the "Remote Desktop Viewer" application.
Source: http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/

Have Fun!

VLC as DLNA Client on Linux

Since version 2.0 VLC is able to play content from a DLNA Server.
On Ubuntu it seems not to be working out of the box. The first challenge is to realize, that a probably installed firewall (eg. ufw) is blocking all incomming traffic, meaning the broadcast of the DLNA server is not seen.

Add a rule to the firewall, to enable incoming traffic on port 1900 UDP for your media-server IP.
Therefore you might want to use a graphical user interface like gufw installable either in the Software Center, or with the terminal: 

$ sudo apt-get install gufw

Afterwards VLC should be able to see your DLNA server, but when double clicking, it seems that nothing happens. But this is not true - if you look more closely, you will realize that you suddenly have a lot of wlan/lan traffic. VLC is syncing the database without any graphical feedback. This is not really user-friendly.
After some time (depended on the size of your database, so be patient...) a folder icon appears, double clicking on it takes a looong time again. This process without graphical feedback (again!) is finished when you see a triangle in front of the folder... YAY! 

Now you can browse your database and start a movie, songs and even look at images!

Have fun!


Tuesday, November 6, 2012

Save the environment AND your eyesight!

I have to read a lot lately and therefore I print out everything. I don't like to read publications, papers and other scientific stuff on the screen, as there is no easy possibility to take down notes, mark some lines and interact with this thing. I just like to work with paper and pencil!

To save the environment a little bit, I always print two pdf pages onto one sheet - double-sided of course - leading to 4 virtual pdf pages being printed onto one single sheet of paper.
This is awesome, but my eyes start to hurt after some time, because the text is so unbelievably small. However, I realised that there is a lot of white space on these sheets and somehow it should be possible to remove the white space and "zoom" the pages a little bit for a better readability.

Exactly this is done by pdfcrop (http://pdfcrop.sourceforge.net/)!
You just type something like

$ pdfcrop --margins 5 input.pdf output.pdf

into your terminal and then print the output.pdf as usual. You will realise that the font size has almost doubled (or sometimes even more), only with removing the white borders. Happy reading!