Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Friday, October 30, 2009

Batch Conversion of Image Files

To convert eps files to png, one can use imagemagick's convert and the good old find along with the -exec option: find -name '*.eps' -exec convert {} {}.png \; However, there is an easier command: mogrify -format png *.eps will do the job more elegantly. Using the -path png will output the images in a folder named png instead of the current folder. Imagemagick has some other useful commands: - display : Displays the image - montage : Concatenates several images - animate : Animates several images man imagemagick for more.

Wednesday, September 02, 2009

KDE Submenu Action For Getting the Public URL of a File in the Dropbox Public Folder

There is yet no equivalent for the nautilus extension for GNOME for KDE, so one can't right click on files in Dropbox's Public folder to get the Public URL. To overcome this limitation, one can use a KDE submenu action. First, create a .desktop file, named dropboxpublic.desktop with the following contents and save it under /usr/share/kde4/services/ServiceMenus or ~/.kde/share/kde4/services/ServiceMenus . The exact location for the parent directory of ServiceMenus is obtained by "kde4-config --path services" output.
[Desktop Action Dropbox Public URL]                                                                                               
Exec=dropbox puburl %u | xclip -selection clipboard                                                                               
Name=Get Public URL

[Desktop Entry]
Actions=Dropbox Public URL;
MimeType=application/octet-stream;
ServiceTypes=KonqPopupMenu/Plugin;
Type=Service
X-KDE-ServiceTypes=KonqPopupMenu/Plugin,
This action requires the xclip program to copy the output of the action to clipboard, so install that using your package manager. Next, when you right click a file in Dropbox/Public folder, and go to Actions-Get Public URL, the URL should be copied to the clipboard. Tip: If you add X-KDE-Priority=TopLevel it will appear in the top level, not under Actions menu.

Thursday, July 23, 2009

Setting a Lefty and a Righty Mouse in Linux at the Same Time

If you want to use two mouses in Linux, and want one of them lefty and the other righty: use this:

xinput set-button-map 2 3 2 1
will reverse the buttons of the mouse numbered 2. To get a list of the mouses,
xinput list
or
xsetpointer -l

Combining both, to set the Microsoft mouse as lefty for example, use:

xinput set-button-map `xsetpointer -l|grep Microsoft|cut -c 1` 3 2 1

This is not persistent across sessions.

Thursday, July 16, 2009

Opening Files from the Command Line via the Default Application

Files can be opened from the command line as if they were double clicked.

  1. On Windows, simply typing the name of the file should work IIRC.
  2. On OS X, there is the open command.
  3. On KDE and Gnome, there are kde-open and gnome-open respectively.

I have created a function in my .bashrc, so that I can open files by the command o. Just add it to ~/.bashrc and source .bashrc or reboot(!)

function o
{
  kde-open "$@" &>/dev/null &             
}

This sends all stdout and stderr to outer space in order to save you an Enter press, so beware.

Bonus: Actually, all this was done so that I can open the files in dired mode in emacs by their default application, pdf, jpg, mp3 files etc.

(define-key dired-mode-map "o" 'dired-launch-command)
(defun dired-launch-command ()
  (interactive)
  (dired-do-shell-command
   (case system-type
     (gnu/linux "kde-open") ;right for gnome (ubuntu), not for other systems
     (darwin "open"))
   nil
   (dired-get-marked-files t current-prefix-arg)))

Now in dired mode, pressing 'o' will open the file in the default application.

See here if that doesn't work.

Thursday, May 07, 2009

Modifying Frame Buffer Size in TTY's

  1. Use hwinfo --framebuffer to get the code.
  2. Append it to the kernel line as vga=0x0368 for 1680x1050 resolution.

Tuesday, April 21, 2009

Sort Directories by Disk Usage

du -sm * | sort -rg
Calculates the disk usage in MB's and sorts in reverse order.