Archive

Posts Tagged ‘script’

Autofocus on the first input field of a page

April 1, 2011 Leave a comment

Problem

You visit some sites frequently where you conduct some search but first you always have to click on the search field. The best example is IMDB. When I go there, I want to find a movie, so I want to type immediately the title of a movie. Why can’t they set the focus on the search field? I find it very annoying.

Solution

Fortunately someone else had also met this problem :) Visit the post Greasemonkey: focus first input field and install the Greasemonkey script. It sets the focus on the first input field and by default it’s activated for all URL addresses. If you want to limit it to IMDB only, edit the head of the script:

...
// @version        1.0
// @include        http://www.imdb.com*
// ==/UserScript==
...

Location of the script: $HOME/.mozilla/firefox/xxxxxxxx.default/gm_scripts/.

Open Konsole from Nautilus

March 3, 2011 Leave a comment

The following entry is based on the post “Nautilus Script to Launch a Terminal” by Linerd.

Problem

For navigating in the file system, I usually use Midnight Commander. However, sometimes it’s useful to switch to a graphical file manager, which is Nautilus under Gnome. For instance, browsing images with Nautilus is easier since it shows thumbnails. After using Nautilus for a while, I want to continue my work in a terminal (my favorite is konsole) in the current directory. How to do that?

Related work

There is a plugin in the repositories called “nautilus-open-terminal”. By default, the plugin calls gnome-terminal and it seems konsole is not supported :(

Solution

In this post, I found a simple and working solution. Here is the script:

#!/bin/bash
#
#  Nautilus script - terminal-here
#  This script will open a GNOME Terminal in the current directory.
#  Written by Linerd in August, 2009 - http://tuxtweaks.com/
#
#  Modification:
#  * konsole-here
#  * Open the Konsole terminal emulator in the current directory.
#
#  Save this script under $HOME/.gnome2/nautilus-scripts/terminal-here. Make sure that
#  you give this file executable permission. { chmod +x terminal-here }
#
#  This program is free software.  It is distributed in the hope
#  that it will be useful, but WITHOUT ANY WARRANTY; without even
#  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
#  PURPOSE.  See the GNU General Public License for more details.
######################################################################

if [ "$NAUTILUS_SCRIPT_CURRENT_URI" == "x-nautilus-desktop:///" ]; then
        DIR=$HOME"/Desktop"
else
        DIR=`echo $NAUTILUS_SCRIPT_CURRENT_URI | sed 's/^file:\/\///' | sed 's/%20/ /g'`
fi

# gnome-terminal --working-directory="$DIR"
konsole --workdir "$DIR"

exit 0

The konsole modification was suggested by James in a comment in the previously referred post.

Installation: Save it in the directory $HOME/.gnome2/nautilus-scripts under the name konsole-here.

Usage: Right click in Nautilus, then choose Scripts -> konsole-here.

Launch Nautilus from terminal

When I want to launch Nautilus from the terminal, I use the alias “nh”, which stands for “nautilus here”, i.e. open Nautilus in the current directory:

alias nh='nautilus . 2>/dev/null'

Simply put this line in your ~/.bashrc file.

With this alias and with the script above, you can easily switch back and forth between Konsole and Nautilus.

Credits

  • Linerd, original script with gnome-terminal support
  • James, konsole patch

Trouble

There is one thing that troubles me. If I open a konsole from Nautilus, the newly opened konsole gets no focus :( That is, you cannot type immediately, first you need to click on its window. However, if you call the script from the Desktop, konsole gets the focus… If someone has a solution for this, please let me know.

Update (20110304): I think I have a solution for the problem. After switching off the visual effects, konsole gets the focus. Damn… Here is how to get rid of the eyecandy: right click on Desktop -> Change Desktop Background -> Visual Effects tab, select None.

PNG to EPS

December 22, 2010 5 comments

Problem

You use “latex” and you want to convert a PNG file to EPS format. Using Gimp, for instance, produces an ugly output.

Solution

Try the png2eps script of Henlich. Works fine :)

Under Ubuntu 10.10, I had to install the following package:

sudo apt-get install pngcheck

Plus, I had to remove the -indexbits=… option from the script.

Credits

Thanks Mehdi for the tip.

Categories: bash Tags: , , ,

Update script

September 30, 2010 1 comment

For updating my Ubuntu, I use the following script:

#!/usr/bin/bash

# good_shape.sh

sudo dpkg --configure -a\
&& sudo apt-get -f install\
&& sudo apt-get --fix-missing install\
&& sudo apt-get clean\
&& sudo apt-get update\
&& sudo apt-get upgrade\
&& sudo apt-get dist-upgrade\
&& sudo apt-get clean\
&& sudo apt-get autoremove

As it calls apt-get clean, it’ll remove the previously downloaded .deb packages which is usually no problem. If you don’t want that, here is a modified version of the same same script without apt-get clean:

#!/usr/bin/bash

# good_shape_safe.sh

sudo dpkg --configure -a\
&& sudo apt-get -f install\
&& sudo apt-get --fix-missing install\
&& sudo apt-get update\
&& sudo apt-get upgrade\
&& sudo apt-get dist-upgrade\
&& sudo apt-get autoremove

I execute this script every day if I don’t forget that.

Categories: bash, ubuntu Tags: ,
Follow

Get every new post delivered to your Inbox.

Join 72 other followers