Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Post Your Thunar Custom Actions Here

Here you can discuss every aspect of Debian. Note: not for support requests!
Message
Author
User avatar
debil
Posts: 1336
Joined: 2008-05-11 08:55
Location: Mazes of Menace, surrounded by brown puddings

Re: Post Your Thunar Custom Actions Here

#46 Post by debil »

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
ComputerBob
Posts: 1181
Joined: 2007-11-30 04:49
Location: The Mountains of the Sunshine State
Been thanked: 1 time

Re: Post Your Thunar Custom Actions Here

#47 Post by ComputerBob »

@dbbolton - Thanks for explaining it!
ComputerBob - Making Geek-Speak Chic (TM)
ComputerBob.com - Nearly 6,000 Posts and 23 Million Views
My Massive Stroke
Help! (off-topic)
_________________
Your Life Matters

User avatar
dbbolton
Posts: 2129
Joined: 2007-06-20 08:17
Location: Iapetus

Re: Post Your Thunar Custom Actions Here

#48 Post by dbbolton »

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: 2129
Joined: 2007-06-20 08:17
Location: Iapetus

Re: Post Your Thunar Custom Actions Here

#49 Post by dbbolton »

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
julian67
Posts: 4633
Joined: 2007-04-06 14:39
Location: Just hanging around
Been thanked: 7 times

Re: Post Your Thunar Custom Actions Here

#50 Post by julian67 »

(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
dbbolton
Posts: 2129
Joined: 2007-06-20 08:17
Location: Iapetus

'Edit' script

#51 Post by dbbolton »

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
julian67
Posts: 4633
Joined: 2007-04-06 14:39
Location: Just hanging around
Been thanked: 7 times

Re: Post Your Thunar Custom Actions Here

#52 Post by julian67 »

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
canci
Global Moderator
Global Moderator
Posts: 2502
Joined: 2006-09-24 11:28
Has thanked: 136 times
Been thanked: 136 times

Re: Post Your Thunar Custom Actions Here

#53 Post by canci »

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
Image Stable / Asus VivoBook X421DA / AMD Ryzen 7 3700U / Radeon Vega Mobile Gfx (Picasso) / 8 GB RAM / 512GB NVMe

READ THIS:

* How to Post a Thread Here
* Other Tips and Great Resources

User avatar
canci
Global Moderator
Global Moderator
Posts: 2502
Joined: 2006-09-24 11:28
Has thanked: 136 times
Been thanked: 136 times

Re: Post Your Thunar Custom Actions Here

#54 Post by canci »

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.
Image Stable / Asus VivoBook X421DA / AMD Ryzen 7 3700U / Radeon Vega Mobile Gfx (Picasso) / 8 GB RAM / 512GB NVMe

READ THIS:

* How to Post a Thread Here
* Other Tips and Great Resources

User avatar
canci
Global Moderator
Global Moderator
Posts: 2502
Joined: 2006-09-24 11:28
Has thanked: 136 times
Been thanked: 136 times

Re: Post Your Thunar Custom Actions Here

#55 Post by canci »

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.
Image Stable / Asus VivoBook X421DA / AMD Ryzen 7 3700U / Radeon Vega Mobile Gfx (Picasso) / 8 GB RAM / 512GB NVMe

READ THIS:

* How to Post a Thread Here
* Other Tips and Great Resources

User avatar
mzilikazi
Forum Account
Forum Account
Posts: 3282
Joined: 2004-09-16 02:14
Location: Colorado Springs, CO

Lossless 2-click image rotation

#56 Post by mzilikazi »

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
dbbolton
Posts: 2129
Joined: 2007-06-20 08:17
Location: Iapetus

Re: Lossless 2-click image rotation

#57 Post by dbbolton »

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
canci
Global Moderator
Global Moderator
Posts: 2502
Joined: 2006-09-24 11:28
Has thanked: 136 times
Been thanked: 136 times

Re: Post Your Thunar Custom Actions Here

#58 Post by canci »

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
Image Stable / Asus VivoBook X421DA / AMD Ryzen 7 3700U / Radeon Vega Mobile Gfx (Picasso) / 8 GB RAM / 512GB NVMe

READ THIS:

* How to Post a Thread Here
* Other Tips and Great Resources

User avatar
friTTe
Posts: 51
Joined: 2010-11-18 22:08
Location: Sweden

Re: Post Your Thunar Custom Actions Here

#59 Post by friTTe »

Hmm this thread needs a subscriber =)
lots and lots of useful commands in here

User avatar
mzilikazi
Forum Account
Forum Account
Posts: 3282
Joined: 2004-09-16 02:14
Location: Colorado Springs, CO

Rename your .jpg images to EXIF date

#60 Post by mzilikazi »

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
dbbolton
Posts: 2129
Joined: 2007-06-20 08:17
Location: Iapetus

Re: Rename your .jpg images to EXIF date

#61 Post by dbbolton »

mzilikazi wrote: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
It looks to me like the top part acts on a single file (since %f is the first selected file), while the bottom is acting on every file in the current directory. It seems like these tasks would better be separated-- for example, just make the action fix the file extension of the selected file, or perhaps have a separate action for fixing all file extensions in the directory, so that the operation isn't needlessly carried out repeatedly.

You could use a rename expression such as

Code: Select all

rename 'if ($_=~/^(.*\.)([A-Z]+)$/) { $_=$2; tr/[A-Z]/[a-z]/; $_=$1.$_}' *
to do the latter.
GitHub | zsh docs in Letter PDF
Telemachus wrote:Put down the CGI.

User avatar
mzilikazi
Forum Account
Forum Account
Posts: 3282
Joined: 2004-09-16 02:14
Location: Colorado Springs, CO

Re: Rename your .jpg images to EXIF date

#62 Post by mzilikazi »

dbbolton wrote: It looks to me like the top part acts on a single file (since %f is the first selected file),
Opps you're right - changed it to %F
It seems like these tasks would better be separated-.
My camera always names everything with the .JPG extension so these tasks are actually quite perfect together.
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
dbbolton
Posts: 2129
Joined: 2007-06-20 08:17
Location: Iapetus

Re: Rename your .jpg images to EXIF date

#63 Post by dbbolton »

mzilikazi wrote:My camera always names everything with the .JPG extension so these tasks are actually quite perfect together.
It makes more sense using %F, but I think you could even put your file test and subsequent actions inside the for loop. It would probably save you a millisecond if you were dealing with hundreds of files. Maybe another approach would be to use %d, and change the glob to $1/*, so you wouldn't have to select a bunch of files at once.

This is one feature that I have found to be problematic in Thunar: the padding (i.e., the space in which you can click to bring up the selection rectangle) between icons is quite small, especially vertically. I often end up seeing a floating icon under the pointer instead of the selection rectangle.
GitHub | zsh docs in Letter PDF
Telemachus wrote:Put down the CGI.

User avatar
julian67
Posts: 4633
Joined: 2007-04-06 14:39
Location: Just hanging around
Been thanked: 7 times

Re: Post Your Thunar Custom Actions Here

#64 Post by julian67 »

How about:

Code: Select all

#!/bin/bash
#rename2exif.sh
for PIC in "$@" ; do
extn=${PIC##*.}
exval=$(exiftime "$PIC" |grep Created|awk '{print $3"_"$4}')
mv "$PIC" "${exval:?NO EXIF DATA FOUND IN "$PIC"}".$extn
done
No need to test the file because if no exif data is found the process quits with the NO EXIF DATA... message.

Appearance conditions:

*.JPG;*.jpg;*.JPEG;*.jpeg

Thunar Command

Code: Select all

xfce4-terminal -H -x rename2exif.sh %F
Gives a file name like 2010:10:16_03:24:48.JPG

Original extension is always retained so JPG is JPG, jpeg is jpeg etc.

Requires: exiftags (in Debian main).
Wisdom from my inbox: "do not mock at your pottenocy"

User avatar
mzilikazi
Forum Account
Forum Account
Posts: 3282
Joined: 2004-09-16 02:14
Location: Colorado Springs, CO

Copy /path/to/file & Copy file contents

#65 Post by mzilikazi »

Found this somewhere in the Xfce docs:
Copy /path/to/file to clipboard:

Code: Select all

echo -n %f|/usr/bin/xclip -selection c
Appearance conditions:
*
ALL


Copy file contents to clipboard

Code: Select all

xclip -in -selection c < %f
Appearance conditions
*.txt;*.TXT
Text 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

Post Reply