Nautilus Script – print all documents in folder

I had to print a lot of files lately and it became clear that opening each of them, then hitting ctrl + p takes too long, so i decided instead to look for a nautilus script that allows me to right click inside the folder and hit Print All. Since i didn’t find anything (probably didn’t look enough…) i built one myself.

Save the script bellow as “Print All Documents” then place it in ~/.gnome2/nautilus-scripts


## By Romeo - Adrian Cioaba
## [email protected]
## If you modify it, Please let me know.
## released under GPLv3


for eachFile in $filenames
    case $eachFile in
        *.pdf) lpr "$eachFile"
        *.doc) libreoffice -p "$eachFile"
        *.docx) libreoffice -p  "$eachFile"
        *.txt) lpr "$eachFile"
        *.jpg) lpr "$eachFile"

exit 0

Make it executable

chmod +x ~/.gnome2/nautilus-scripts/Print\ All\ Documents

and you are good to go. When you go inside a folder, right click and under the Scripts entry you will have the option “Print All Documents”

This script can be of course tweaked to print more file types.


Fullscreen any window in Gnome

If you are running any distro that has a recent Gnome, chances are that your window manager is either Metacity or Compiz. I’ve found that while working, having my IDE fullscreen helps as that way i can keep away the “noise” and really concentrate on the work i’m doing.

Here’s how to fullscreen any window in Gnome:

1. Metacity
– Run gconf-editor.
– Go to /apps/metacity/window_keybindings.
– Change toggle_fullscreen from disabled to F11.

2. Compiz
– apt-get install compizconfig-settings-manager compiz-fusion-plugins-extra
Then open System -> Preferences -> CompizConfig Settings Mangager. The “Extra WM Actions” plugin should now be available under “Window Management”. Check it and click “Close”.

Restart your X-server by logging out and back in again. The “Toggle fullscreen” keyboard shortcut should now work with whatever you set in the main Gnome keyboard shortcuts settings.


How to: Replace with LibreOffice on Ubuntu

Here are a few easy steps to replace with libreoffice on ubuntu:

CLI instructions (these will take care of removing and installing LibreOffice):

Add the PPA and install LibreOffice:

sudo add-apt-repository ppa:libreoffice/ppa
sudo apt-get update
sudo apt-get install libreoffice 

For GNOME integration (for people running default Ubuntu):

sudo apt-get install libreoffice-gnome

or for KDE Integration (for people running Kubuntu):

sudo apt-get install libreoffice-kde

As of Ubuntu 11.04, LibreOffice will replace by default OpenOffice.

linux ubuntu

Fix gitk ugly fonts in Ubuntu

I’ve recently started playing around with git and found out the power of gitk. Gitk is a small tool built using tcl/tk that helps the user visualize the changes he’s done in a graphical, easy to follow manner. By default Ubuntu 10.10 ships with tk8.4 installed by default and that makes gitk look really ugly, as tk8.4 doesn’t support antialiased fonts. To fix this problem simply install tk8.5 and make it default on your machine:

sudo apt-get install tk8.5
sudo update-alternatives --config wish
# a list will show up and you need to type in the number that corresponds to tk8.5 (in my case was 3) then hit enter.

That’s it. You can now reopen gitk and see the difference.

linux ubuntu

Find string in files and show line number with grep

Handy snippet to find some string inside the files in a directory:

grep -r --line-number "string_you_search" path/where/to/look

Note the -r tells grep also to look into all subfolders recursively.

linux ubuntu

CD Emulation in Linux

In Linux, most of the time you don’t need any special tool to mount an image. You can just mount an .iso file using the mount tool:

sudo mount -oloop Image.iso /mnt

Unfortunately if you want to play a game that needs the CD inside the drive, mounting using the mount tool won’t make the CD available for the game (unless it didn’t worked for me). So i looked around and found that CDEmu can do the job. To install on Ubuntu add the repos from ppa:cdemu/ppa them install:

sudo add-apt-repository ppa:cdemu/ppa
sudo apt-get update
sudo apt-get install gcdemu

This will install and applet which you can use with your Gnome panel, and all the other libs that it needs. In order for the applet to work you need to start the cdemud daemon, which depends on the vhba kernel module. To start those run:

sudo modprobe vhba; cdemud &

Now you can mount images using your CDEmu applet 🙂

linux ubuntu

Install Adobe® Flash® Player “Square” on Linux

Adobe® Flash® Player “Square” is a preview release that enables native 64-bit support on Linux, Mac OS, and Windows operating systems, as well as enhanced support for Microsoft Internet Explorer 9 beta.

I’m glad to see Adobe has is finally embracing the way it should the 64 bit Platform. This release is a milestone as far as i know, as is the first one that’s released in the same time for win, mac and linux. I’ve put together a small tutorial on
how to install adobe flash player square on linux:

# Script  created by
# Romeo-Adrian Cioaba [email protected]

echo "Stopping any Firefox that might be running"
sudo killall -9 firefox

echo "Removing any other flash plugin previously installed:"
sudo apt-get remove -y --purge flashplugin-nonfree gnash gnash-common mozilla-plugin-gnash swfdec-mozilla libflashsupport nspluginwrapper
sudo rm -f /usr/lib/mozilla/plugins/*flash*
sudo rm -f ~/.mozilla/plugins/*flash*
sudo rm -f /usr/lib/firefox/plugins/*flash*
sudo rm -f /usr/lib/firefox-addons/plugins/*flash*
sudo rm -rfd /usr/lib/nspluginwrapper

echo "Installing Flash Player Square"
cd ~
# 64 bit
tar zxvf flashplayer_square_p1_64bit_linux_091510.tar.gz
# 32 bit
# wget
# tar zxvf flashplayer_square_p1_32bit_linux_091510.tar.gz
sudo cp /usr/lib/mozilla/plugins/

echo "Linking the libraries so Firefox and apps depending on XULRunner (vuze, liferea, rsswol) can find it."
sudo ln -sf /usr/lib/mozilla/plugins/ /usr/lib/firefox-addons/plugins/
sudo ln -sf /usr/lib/mozilla/plugins/  /usr/lib/xulrunner-addons/plugins/

# now doing some cleaning up:
sudo rm -rf
sudo rm -rf flashplayer_square_p1_64bit_linux_091510.tar.gz

To check if the install did it’s job, you need to check about:plugins in your address bar. It should show you this for flash player:

Shockwave Flash

Shockwave Flash 10.2 d161
MIME Type Description Suffixes Enabled
application/x-shockwave-flash Shockwave Flash swf Yes
application/futuresplash FutureSplash Player spl Yes

As usual, I’ve wrapped everything mentioned before into a script to easily install flash player square on Linux

If this version doesn’t work out that well for you, you can still check my other tutorial on how to install native 64bit flash player on Linux
Happy browsing!

linux ubuntu

CLI Disk Usage

Modern Linux systems have plenty of tools for both Gnome and Kde to analyze the disk space. But if you log into a server via SSH or similar, you’re out of luck. You need a tool for Cli Disk Usage analytics. That tool is ncdu.

You can install it easy:

sudo apt-get install ncdu

Issuing ncdu inside the folder you want to check will open a cool ncurses interface, really easy to use 🙂

linux ubuntu

Converting disc images to another format on Linux

While this information is available all over the net, i find myself losing enough time now and again trying to figure out how to convert a disk image to iso or something useful for that matter. So i decided to put together a small tutorial on converting disk images to another format on Linux, so i can easily access it whenever i need it.

The most popular disk image formats i’ve had to deal with are: iso (which Ubuntu handles by default perfectly), CloneCD/IMG (used by CloneCD), CUE/BIN, MDF (created by Alcohol 120%), NRG (Nero images) and last but not least DMG (format used mainly by Apple).

Since Linux handles very well .iso files, the idea is to convert any of the image types listed into iso and then the job is easy. For all of the formats there are tools to do just that. You can install them as follows:

sudo apt-get install ccd2iso bchunk mdf2iso nrg2iso dmg2img

Example usage:

# ccd
ccd2iso /path/to/example.img /path/to/example.iso
# bin/cue
bchunk /path/to/example.bin /path/to/example.cue /path/to/example.iso 
# mdf
mdf2iso /path/to/example.mdf /path/to/example.iso 
# nrg
nrg2iso /path/to/example.nrg /path/to/example.iso 
# dmg
dmg2img filename.dmg

Some of those formats can be also mounted using the CLI:

# ccd/img
sudo mount -o loop example.img /media/example 
# nrg 
sudo mount -o loop,offset=307200 /path/to/example.nrg /media/example 
# dmg
dmg2img /path/to/example.dmg /path/to/example.img 
sudo modprobe hfsplus
sudo mount -t hfsplus -o loop example.img /media/example
linux ubuntu

Convert wma to mp3 on Linux

Today i wanted to listed to some old tracks, which for some reason i had saved in .wma format. Added them to Rhythmbox and it complained about needing a plugin which it didn’t find. I fired up Google and learned that i need to install some gstreamer codecs, but with my files it still didn’t worked. That so, i decided to convert the wma files to mp3 using the Perl Audio Converter. Install was painless on Ubuntu 10.04:

sudo apt-get install pacpl

After install, go to the folder that contains your .wma files and run:

pacpl -t mp3 *.wma