Post Your Thunar Custom Actions Here

Tweaking a computer is fun, but some people actually use their Debian system to accomplish various tasks. If you are one of those, post your trials and triumphs here.

Re: Post Your Thunar Custom Actions Here

Postby julian67 » June 10th, 2011, 9:28 pm

Extract Images from PDF and save to 300 DPI jpg

Requires ImageMagick and ghostscript.

This works fine without using xterm, but if you want to see what it's doing you could prefix the action with 'xterm -hold -e ' or 'xfce4-terminal -H -x '

Put the script in your path and make it executable.

If you're running Lenny, or any system with Ghostscript <8.71 then use the second script below. It's somewhat slower, having two conversion stages, but it works fine. The difference is due to a bug handling pdf files which don't comply with Adobe's PDF specification

Image

script
Code: Select all
#!/bin/sh
# pdf2jpg extracts images from pdf and saves them in same directory at 300 dpi as booklet-#.jpg
# i.e. booklet-0.jpg,booklet-1.jpg and so on
# the numbering is automatic.
for FILE in "$@" ; do
convert -define pdf:use-cropbox=true -quality 100% -density 300 "$FILE" booklet.jpg
done


alternative script for systems using older versions of ghostscript (requires xpdf-utils,ImageMagick):
Code: Select all
#!/bin/sh
# pdf2jpg extracts images from pdf and saves them in same directory at 300 dpi as booklet-#.jpg
# i.e. booklet-0.jpg,booklet-1.jpg and so on
# the numbering is automatic.
for FILE in "$@" ; do
OUTFILE=$(dirname "$FILE")/booklet.jpg
pdftoppm -cropbox "$FILE" "$FILE" ;
convert "$FILE"*.ppm -density 300 -quality 100% "$OUTFILE" ;
rm "$FILE"*.ppm
done
User avatar
julian67
 
Posts: 249
Joined: February 9th, 2011, 12:59 pm

Re: Post Your Thunar Custom Actions Here

Postby julian67 » June 10th, 2011, 9:31 pm

Convert Video for Sansa Fuze:

Will convert all selected video files for playback on Fuze.

Requires fuzemux and mencoder script, see http://forums.debian.net/viewtopic.php?p=286477#p286477

Image

Get fuzemux from http://code.google.com/p/fuzemux/

MEncoder script:
Code: Select all
#!/bin/bash
# script name mensansa

for MOVIE in "$@" ; do

# Get movie name and strip extension - allow spaces dots etc
VIDOUT=$(basename "$MOVIE" |sed 's/\(.*\)\..*/\1/')

# Get original directory name of movie
DIRNAME=$(dirname "$MOVIE")

# Set output directory & name for converted movie
DEST="$DIRNAME"/"$VIDOUT"_fuze.avi

mencoder "$MOVIE" \
-srate 44100 -af resample=44100:0:1,format=s16le \
-oac mp3lame -lameopts cbr:br=128 \
-ovc lavc -lavcopts vcodec=mpeg4:vqscale=3:vmax_b_frames=0:keyint=15 \
-ofps 20 -noskiplimit -vf pp=li,expand=:::::224/176,scale=224:176 \
-ffourcc DX50 \
-o "$MOVIE"_premux.avi \
&& fuzemux "$MOVIE"_premux.avi "$DEST" \
&& rm "$MOVIE"_premux.avi
done
User avatar
julian67
 
Posts: 249
Joined: February 9th, 2011, 12:59 pm

Re: Post Your Thunar Custom Actions Here

Postby julian67 » June 10th, 2011, 9:31 pm

A neat way for batch image conversions as a Thunar Custom Action is to use Phatch. Phatch: PHoto bATCH. It's in Debian main from Lenny onwards. Phatch works on the command line as well as via a GUI, and running an action as a command is really easy. For example I have an action to reduce image size to 70%, mostly used to get fullscreen screenshots down to a reasonable size. I made the action using the GUI and saved it to ~/.local/share/phatch/actionlists/screens.phatch (I believe the older versions of Phatch such as Lenny's use a different save location). So now I have a custom action:

Image

Code: Select all
phatch ~/.local/share/phatch/actionlists/screens.phatch %F


Phatch has a large range of available actions built in:

* Auto Contrast - Maximize image contrast
* Background - Put colour under transparent image
* Border - Variable border to the inside or outside
* Brightness - Adjust brightness from black to white
* Canvas - Crop the image or enlarge canvas without resizing the image
* Color To Alpha - Make a background with fixed color transparent
* Colorize - Colorize grayscale image
* Common - Copies the most common pixel value
* Contour - Draw a contour around image edges
* Contrast - Adjust from grey to black & white
* Convert Mode - Convert the color mode of an image (grayscale, RGB, RGBA or CMYK)
* Copy - Copy image file
* Crop - Crop the image
* Delete Tags - Delete Exif or Iptc Tags
* Desaturate - Fade all colors to grey
* Effect - Blur, Sharpen, Emboss, Smooth, …
* Equalize - Equalize the image histogram
* Fit - Downsize and crop image with fixed ratio
* Geek - Execute external command
* Geotag - Geotag an image file
* Grayscale - Fade all colours to gray
* Highlight - Add a highlight effect
* Imagemagick - Blur, Polaroid, Shadow, Unsharp…
* Invert - Invert the colors of the image (negative)
* Lossless JPEG - Rotate, flip, grayscale and crop
* Maximum - Copies the maximum pixel value
* Mask - Apply a transparency mask
* Median - Copies the median pixel value
* Minimum - Copies the minimum pixel value
* Mirror - Symmetrical tile texture
* Offset - Offset by distance and wrap around
* Perspective - Shear 2d or 3d
* Posterize - Reduce the number of bits of colour channel
* Rank - Copies the rank'th pixel value
* Reflect - Drops a reflection
* Rename - Rename image file
* Rename Tag - Rename an Exif or Iptc Tag
* Rotate - Rotate with random angle
* Round - Round or crossed corners with variable radius and corners
* Saturation - Adjust saturation from grayscale to high
* Save - Save an image with variable compression in different types
* Save Tags - Save only metadata (lossless)
* Scale - Scale an image with different resample filters.
* Shadow - Drop a blurred shadow under a photo with variable position, blur and color
* Sketch - Transform to a grayscale pencil drawing.
* Solarize - Invert all pixel values above threshold
* Tamogen - Tone altering mosaic generator
* Text - Write text at a given position
* Time Shift - Shift Exif time
* Transpose - Flip or rotate an image by 90 degrees
* Watermark - Apply a watermark image with variable placement (offset, scaling, tiling) and opacity
* Write Tag - Write a new value to a metadata tag (exif & iptc)


And you can make your own too http://photobatch.wikidot.com/writing-actions
User avatar
julian67
 
Posts: 249
Joined: February 9th, 2011, 12:59 pm

Re: Post Your Thunar Custom Actions Here

Postby julian67 » June 10th, 2011, 9:37 pm

(Batch) Convert YouTube videos to .mp4

This is for the YouTube stuff that is in /tmp where the YT video cached (I never worked out the purpose of many of those clever conversion apps when all you have to do is copy the file somewhere else). As far as I can tell all non-DRM/obfuscated YT content is offered h.264+aac in flash, so no need for video or audio conversion, all that's required is to put it in an mp4 container and then it will play even in dumb media players which rely on file extensions to identify content type. You could just as easily use mkv (it saves a little space). No encoding, only muxing, so very quick.

custom action:
Code: Select all
xfce4-terminal -x youtube2mp4.sh %F


You can run it without launching xfce4-terminal so then only
Code: Select all
youtube2mp4.sh %F
but the terminal is useful in case of errors, and personally I get huge thrills watching the ffmpeg output flash by.

Image

Image

Requires this script or similar to be in your path and executable.

Code: Select all
#!/bin/bash
# youtube2mp4.sh
for i in "$@" ; do
ffmpeg -i "$i" -acodec copy -vcodec copy "${i%.flv}".mp4
done


You can easily change the ffmpeg options if you want to transcode to different video and audio codecs.
User avatar
julian67
 
Posts: 249
Joined: February 9th, 2011, 12:59 pm

Re: Post Your Thunar Custom Actions Here

Postby julian67 » June 10th, 2011, 9:38 pm

Sometimes I want to know not the file size of a directory, but the playing time of the audio files within.

Command for thunar:

Code: Select all
xfce4-terminal -H -x oidua -o [N]"  "[l] %F


Appearance Conditions: Directories

Requires: oidua (in Debian main).

Works with: ogg, mp3, flac, mpc

Image

oidua can do other things too so if you also wanted to know the file size, codec or quality it can do that as well. http://oidua.suxbad.com/
User avatar
julian67
 
Posts: 249
Joined: February 9th, 2011, 12:59 pm

Re: Post Your Thunar Custom Actions Here

Postby julian67 » June 10th, 2011, 9:40 pm

I'm bored now so I'll add the rest another time.
User avatar
julian67
 
Posts: 249
Joined: February 9th, 2011, 12:59 pm

Re: Post Your Thunar Custom Actions Here

Postby dbbolton » October 2nd, 2011, 11:58 pm

Once my "scripts" repo got too big to manage, I decided to split it up. I put my thunar scripts here: https://github.com/dbb/thunar-scripts

I am working on some more that I haven't added yet.
<nadir> i am the king of wobbly windows

RDU since 2007
User avatar
dbbolton
 
Posts: 180
Joined: February 12th, 2011, 9:32 pm

Re: Post Your Thunar Custom Actions Here

Postby huggybear » November 27th, 2011, 11:18 am

.

Dropbox Integration in Xfce


Image


0. What is Dropbox?

It's a proprietary online storage provider which gives you 2 GB of free space, while additional space can be subscribed to monthly for an additional fee. Dropbox is not overly concerned about your privacy, so putting very sensitive data on there might not be such a good idea...
You can use it via its web interface which requires Adobe Flash (though Gnash in Debian Stable worked fine for me). Their official package supports and requires Nautilus, but we are going to use an alternate package for this method.

https://www.dropbox.com/


1. Download the precompiled Dropbox client (the one that isn't tied to Nautilus):

A. For 32 bit

Code: Select all
cd ~ && wget http://dl-web.dropbox.com/u/17/dropbox-lnx.x86-1.3.2.tar.gz && tar zxvf dropbox-lnx.x86-1.3.2.tar.gz


B. For 64 bit

Code: Select all
cd ~ && wget http://dl-web.dropbox.com/u/17/dropbox-lnx.x86_64-1.3.2.tar.gz && tar zxvf dropbox-lnx.x86_64-1.3.2.tar.gz


The dropbox client will be extracted to .dropbox-dist


2. Make a run script for the client

In a text editor paste this:

Code: Select all
cd  ~/.dropbox-dist
./dropbox


and save it as dropbox into either ~/.bin or /usr/local/bin . Make it executable.


3. Run the Dropbox client at startup

3.1. From the start menu, choose Settings --> Session and Startup

3.2. Under Application Autostart choose the + Add sign to add a new rule. Choose a name and description to your liking, but under Command enter dropbox.


4. Start Dropbox
by running the command dropbox from the run dialogue. You will be asked to either create a new account or provide credentials for your existing one.


5. Dropbox Usage

Everything you copy to the folder ~/Dropbox is automatically synced to your Dropbox account. The subfolder Public contains files that you want to share with others. We will now make a Thunar Custom Action which will enable us to right click on any given file in the Public folder and use a command which will copy the public web page link to our clipboard -- this way we can paste it to others...

5.1. The Script

This Python script was taken from the official Nautilus Dropbox package, but it works here, too. Download it:

Code: Select all
wget http://dl.dropbox.com/u/11675431/dropbox.py


and copy it to ~/.bin or /usr/local/bin . Make it executable.

5.2. Install xclip

Code: Select all
apt-get install xclip


5.3. Make the following Thunar Custom Action:

Name: Copy Dropbox Public Link
Description: Copies a public link for the shared file in Dropbox...
Command: bash -c "dropbox.py puburl %n | xclip -i -selection clipboard"

Check all file types under Appearance Conditions and under FIle Pattern use * !

.
<< I guess that makes them "DEBITARDS" ..... >>
User avatar
huggybear
 
Posts: 1408
Joined: February 9th, 2011, 6:54 pm
Location: Gargantua's cookie jar

Re: Post Your Thunar Custom Actions Here

Postby huggybear » February 29th, 2012, 5:06 am

.

Convert images to separate PDFs

I often make handouts from cropped exercises I scan from books. They are assembled in Inkscape and exported as a PNG which I then turn into PDFs with this script.
It requires ImageMagick and Zenity, but you can delete Zenity if you don't want the little pop up that says "Done!"

Code: Select all
apt-get install imagemagick zenity


The script:

Code: Select all
#!/bin/bash
for f in $@
 do
   convert $f $f.pdf
 done && zenity --info --text "Done!"


Save it (I chose the name "img2pdf.sh") and put it into ~/.bin or /usr/local/bin .

This will turn any image you mark into separate PDFs (I will devise another script that turns the images into just one PDF). The quality and resulting filesize aren't that great by default, but it's just for b/w handouts, so I don't care. I do sharpen the text scans in Gimp a bit. I also make sure to choose a high DPI value when exporting from Inkscape, but I don't think that's of much use if the DPI of the scanned pictures isn't great. To see possible options, look at

Code: Select all
man imagemagick


and modify the command convert in the previous script according to your wishes.

Add this to your Custom Actions:

Basic --> Command: img2pdf.sh %F

Appearance Conditions --> Tick Image Files and just leave *.* as the file pattern.

.
<< I guess that makes them "DEBITARDS" ..... >>
User avatar
huggybear
 
Posts: 1408
Joined: February 9th, 2011, 6:54 pm
Location: Gargantua's cookie jar

Previous

Return to Doing stuff with Debian

Who is online

Users browsing this forum: No registered users and 0 guests

x