30 Jul 2009

Selectable area for screenshots on gnome

Install required software:

$ sudo apt-get install zenity scrot xclip


Script for capturing screen areas (change targets at the beginning of the file):
#!/bin/bash

targetdir=/home/public-www/tmp/
targeturi=http://wunderlin.net/tmp/
icon=/usr/share/icons/gnome/22x22/apps/applets-screenshooter.png

# ask for filename
file=$(zenity --title="Screenshot" --width=800 --window-icon=$icon \
--text="Filename:" --filename="$targetdir" --file-selection)

if [[ "$file" == ".png" || -z "$file" ]]; then exit 1; fi

scrot --select "$file"

uri=$(echo "$file" | sed -e 's|'$targetdir'||')

echo "$targeturi$uri" | xclip -i -selection clip-board
# zenity --info --text="$targeturi$uri" --title="Screenshot URL" --window-icon=$icon
echo $file;

exit 0;


Steps for creating a custom hotkey to launch any application in GNOME:
  1. Open "gconf-editor" as the user as you're logged in in GNOME
  2. Go to "apps" -> "metacity" -> "keybinding_commands"
  3. Double click on e.g. "command_1"
  4. Type in the name of the application you want to launch, e.g. "gcalctool", the GNOME calculator
  5. Go to "apps" -> "metacity" -> "global_keybindings"
  6. Double click on e.g. "run_command_1"
  7. Type in e.g. <Control><Alt>c
  8. Note the < and > for the special function keys
  9. DONE! Close the gconf-editor and press CTRL-ALT-c and the calculator should come up