Post Your Thunar Custom Actions Here

Here you can discuss every aspect of Debian. Note: not for support requests!

Re: Post Your Thunar Custom Actions Here

Postby debil » 2010-05-24 20:19

I think the better subject line for this thread would've been something like

Post Your Thunar Custom Actions Here (and even if you don't use Thunar, you'll find a lot of good scripts (or at least ideas for scripts) to fill your ~/bin with)
Q: Why is the Eunux kernel so bloated?
A: It was made in the image of its founder.
User avatar
debil
 
Posts: 1338
Joined: 2008-05-11 08:55
Location: Mazes of Menace, surrounded by brown puddings

Re: Post Your Thunar Custom Actions Here

Postby ComputerBob » 2010-05-24 20:32

@dbbolton - Thanks for explaining it!
ComputerBob - Making Geek-Speak Chic (TM)
ComputerBob.com - Nearly 6,000 Posts and 22 Million Views
My Ministry
My Massive Stroke
User avatar
ComputerBob
 
Posts: 1195
Joined: 2007-11-30 04:49
Location: The Beautiful Sunshine State

Re: Post Your Thunar Custom Actions Here

Postby dbbolton » 2010-05-24 21:46

Thunar's bulk rename is pretty handy, but it seems awkward when performing several operations on the same group of files. I use this script to get rid of "bad" characters in filenames: http://github.com/dbbolton/scripts/blob ... -rename.pl

According to lines 46 and 47,
Code: Select all
 !"#$%'*+,:;?@\
will be replaced with a '_'
Code: Select all
()<=>[]^`{|}~
will be replaced with a '-', and the ampersand will be replaced with 'and'. If a file already exists, an integer will be stuck on the end until the name is unique. If a file extension is detected (id est a '.' followed by 1 or more word characters), the number is added before the '.'. This might seem a bit awkward too, because you will end up with 'file012' if 'file0' and 'file01' both happen to exist already. But if you have that many similarly named files in one place, you might have bigger fish to fry. I'm thinking about adding another block that will check for an integer at the end of the name and save it to a variable to be incremented rather than just catenating a new one to the end. But for now this thing does what I need it to do. Eventually Imperator Margaritae* aka Telemachus will show up and show me what I did wrong.

It operates on the first argument or, if none is given, the current directory

* - "Margarita" dixi quia verbum quod "Perl" significat in hac lingua non exsistit.
GitHub | zsh docs in Letter PDF

Telemachus wrote:Put down the CGI.
User avatar
dbbolton
 
Posts: 2133
Joined: 2007-06-20 08:17
Location: Iapetus

Re: Post Your Thunar Custom Actions Here

Postby dbbolton » 2010-06-14 08:44

dbbolton wrote:To open a file in a new tab in Kate:
Code: Select all
kate -u %f


I've been using GVim as my editor in X lately (Kate's vi mode is pretty rudimentary)

Code: Select all
gvim --remote-tab %F
GitHub | zsh docs in Letter PDF

Telemachus wrote:Put down the CGI.
User avatar
dbbolton
 
Posts: 2133
Joined: 2007-06-20 08:17
Location: Iapetus

Re: Post Your Thunar Custom Actions Here

Postby julian67 » 2010-07-09 03:16

(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 MOVIE in "$@" ; do
VIDOUT=$(basename "$MOVIE" |sed 's/\(.*\)\..*/\1/')
ffmpeg -i "$MOVIE" -acodec copy -vcodec copy "$VIDOUT".mp4
done


You can easily change the ffmpeg options if you want to transcode to different video and audio codecs, for example to make an avi with mp2 audio and divx compatible video which should play on pretty much anything change the ffmpeg line to
Code: Select all
ffmpeg -i "$MOVIE" "$VIDOUT".avi
and change the custom action name to youtube2avi to avoid confusion.
Wisdom from my inbox: "do not mock at your pottenocy"
User avatar
julian67
 
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

'Edit' script

Postby dbbolton » 2010-07-09 08:27

I had several 'Edit' actions for different types of files, e.g. audacity for audio files, GIMP for image files, and so on. I decided to simplify my setup by using a Perl script that will work with 99% of the files that I open from Thunar: http://github.com/dbbolton/scripts/blob ... ar-edit.pl

I wrote it to work with only one file at a time (so %f), but a person could easily embed the existing code in a for loop over @ARGV if he so desired (%F).

Before someone yells at me for not using MIME::Types, I actually first wrote the script to use that, but ultimately I found it to be way less typing simply to list the file extensions myself. I am happy to let go of that 1% certainty.
GitHub | zsh docs in Letter PDF

Telemachus wrote:Put down the CGI.
User avatar
dbbolton
 
Posts: 2133
Joined: 2007-06-20 08:17
Location: Iapetus

Re: Post Your Thunar Custom Actions Here

Postby julian67 » 2010-10-25 01:22

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/
Wisdom from my inbox: "do not mock at your pottenocy"
User avatar
julian67
 
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Post Your Thunar Custom Actions Here

Postby canci » 2010-10-25 08:39

julian67 wrote: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/

Nifty! TNX. Will use that with zenity...

EDIT: Here is the command with zenity output:

Code: Select all
oidua -o [N]"  "[l] %F | zenity --text-info
I ken hez kinvulf beck? I ken hez riesnible modereyshn? Kthnxbai!

No need to discuss this topic? Offended by this signature? Remove it:

Mez wrote:You can easily just disable viewing signatures

Click here - and set "Display Signatures" to No
User avatar
canci
 
Posts: 1705
Joined: 2006-09-24 11:28
Location: Bosnia & Herzegovina

Re: Post Your Thunar Custom Actions Here

Postby canci » 2010-10-25 15:07

I use catfish, a GUI for find, locate, strigi and many more which finds your files.

http://packages.debian.org/search?keywords=catfish
http://www.twotoasts.de/index.php?/page ... mmary.html

I start it using a key shortcut which issues the following command:

Code: Select all
catfish --thumbnails --path=/home/canci --wrapper=xdg-open --fileman=thunar

--thumbnails, if you want to preview pictures, PDF and such
--wrapper tells it to use xdg-open when you double click a file, which is a desktop
agnostic database knowing what programmes open what file type.
--path is the path it's searching in.
--fileman tells it to open folders in requested file manager.

Sometimes, I want to see whether the same filename exists in other locations, so I
came up with this custom action:

Code: Select all
catfish --thumbnails --path=/ --wrapper=xdg-open --fileman=thunar %N


Take care to choose %N here, otherwise with %f catfish is searching for something like /home/foo/bar.png and will list all things
named home or foo!

Check everything for appearance conditions.

This basically searches the same filename (and also other similar written ones --
don't know if this can be restricted via command line) on the whole system recursively.
It might be a good idea to make one for the home directory, and another one
for the entire system if you have many mount points.

EDIT: Changed %f to %N !
Last edited by canci on 2010-10-31 15:29, edited 1 time in total.
I ken hez kinvulf beck? I ken hez riesnible modereyshn? Kthnxbai!

No need to discuss this topic? Offended by this signature? Remove it:

Mez wrote:You can easily just disable viewing signatures

Click here - and set "Display Signatures" to No
User avatar
canci
 
Posts: 1705
Joined: 2006-09-24 11:28
Location: Bosnia & Herzegovina

Re: Post Your Thunar Custom Actions Here

Postby canci » 2010-10-26 17:41

LaTeX Preview

Image

A script which compiles your latex in a temporary folder with nice output in a terminal,
displays it in a PDF viewer and after closing deletes the temporarily created file and
folder.

Code: Select all
#!/bin/bash
cd $HOME &&
mkdir .TMP_LAT &&
cd .TMP_LAT &&
pdflatex $1 &&
evince *.pdf &&
cd $HOME &&
rm -r .TMP_LAT


Change "evince" in the script above to any PDF viewer you like.
Make the script executable and copy it into /usr/local/bin.
I named it "pdflatpreview"

This code is the custom action:

Code: Select all
lxterminal -e "pdflatpreview %f"


Change lxterminal to your preferred terminal.
I ken hez kinvulf beck? I ken hez riesnible modereyshn? Kthnxbai!

No need to discuss this topic? Offended by this signature? Remove it:

Mez wrote:You can easily just disable viewing signatures

Click here - and set "Display Signatures" to No
User avatar
canci
 
Posts: 1705
Joined: 2006-09-24 11:28
Location: Bosnia & Herzegovina

Lossless 2-click image rotation

Postby mzilikazi » 2010-12-05 05:14

Rotate your images from the right click menu.
Rotate Right
jpegtran -rotate 90 -copy all -outfile %f %f

Appearance Conditions:
*.jpg;*.JPG
Image Files

Rotate Left
jpegtran -rotate 270 -copy all -outfile %f %f

Appearance Conditions:
*.jpg;*.JPG
Image Files
Debian Sid Laptops:
AMD Athlon(tm) 64 X2 Dual-Core Processor TK-55 / 1.5G
Intel(R) Pentium(R) Dual CPU T2390 @ 1.86GHz / 3G
User avatar
mzilikazi
Forum Ninja
 
Posts: 3321
Joined: 2004-09-16 02:14
Location: Colorado Springs, CO

Re: Lossless 2-click image rotation

Postby dbbolton » 2010-12-05 05:47

mzilikazi wrote:Rotate your images from the right click menu.
Rotate Right
jpegtran -rotate 90 -copy all -outfile %f %f

Appearance Conditions:
*.jpg;*.JPG
Image Files

Rotate Left
jpegtran -rotate 270 -copy all -outfile %f %f

Appearance Conditions:
*.jpg;*.JPG
Image Files


You could also use convert (from the imagemagick package) for a more general solution: http://www.imagemagick.org/script/comma ... 8q3#rotate
GitHub | zsh docs in Letter PDF

Telemachus wrote:Put down the CGI.
User avatar
dbbolton
 
Posts: 2133
Joined: 2007-06-20 08:17
Location: Iapetus

Re: Post Your Thunar Custom Actions Here

Postby canci » 2010-12-05 10:28

GPicView is in the repositories and has few dependencies. It is an image viewer which lets you rotates images
and then also save them into various formats. Of course, rotation is only limited to 90° CW or CCW, so not nearly as potent as a script.
I find it to be much lighter than Ristretto. It's part of the LXDE project.

Image
I ken hez kinvulf beck? I ken hez riesnible modereyshn? Kthnxbai!

No need to discuss this topic? Offended by this signature? Remove it:

Mez wrote:You can easily just disable viewing signatures

Click here - and set "Display Signatures" to No
User avatar
canci
 
Posts: 1705
Joined: 2006-09-24 11:28
Location: Bosnia & Herzegovina

Re: Post Your Thunar Custom Actions Here

Postby friTTe » 2010-12-05 12:28

Hmm this thread needs a subscriber =)
lots and lots of useful commands in here
User avatar
friTTe
 
Posts: 51
Joined: 2010-11-18 22:08
Location: Sweden

Rename your .jpg images to EXIF date

Postby mzilikazi » 2010-12-07 05:57

This is a quick way to rename alot of images to something more useful than DSCF3727.JPG
Code: Select all
apt-get install jhead


New Action>
Name: Rename To EXIF Date
Description: Rename image file to EXIF date/time
Command: /path/to/RenameToExifDate %F

Code: Select all
#!/bin/bash
while [[ -n "$1" ]]; do
   #if a file and not a dir
   if [[ -f "$1" ]]; then
      jhead -nf%m.%d.%Y_%H:%M "$1"
      fi
   shift
done

for i in *.JPG;
do mv $i `basename $i JPG`jpg;
done
Debian Sid Laptops:
AMD Athlon(tm) 64 X2 Dual-Core Processor TK-55 / 1.5G
Intel(R) Pentium(R) Dual CPU T2390 @ 1.86GHz / 3G
User avatar
mzilikazi
Forum Ninja
 
Posts: 3321
Joined: 2004-09-16 02:14
Location: Colorado Springs, CO

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 8 guests

fashionable