You are not logged in.

#1 2012-03-08 07:01:33

TuxLyn
Member
From: United States
Registered: 2011-10-26
Posts: 283

Thunar Action - Extract tar.xz Files

Here is a custom command on extracting tar.xz files. Might help some one else.

Action by TuxLyn {2012-03-08}
------------------------------------------------------------------
Name: Extract (tar.xz)
Command: xz -d %n; txz=%n; tar xvf ${txz:0:-3}
File Pattern: *.xz
Contains: Other Files
------------------------------------------------------------------

I will be adding more actions in time to my wiki @ http://wiki.gotux.net/config:thunar
for any one interested you can also see custom bash functions @ http://wiki.gotux.net/config:bash

Last edited by TuxLyn (2012-03-08 08:00:32)


::: Using Arch Linux Since October 25, 2011 :::
::: Tutorials: http://distrogeeks.com/ :::

Offline

#2 2012-03-08 16:56:33

avx
Member
Registered: 2011-07-05
Posts: 71

Re: Thunar Action - Extract tar.xz Files

Any particular reason you're doing that in two steps? I doubt my tar is specially patched and just using 'tar xf $file' works.

Offline

#3 2012-03-08 17:06:47

TuxLyn
Member
From: United States
Registered: 2011-10-26
Posts: 283

Re: Thunar Action - Extract tar.xz Files

Not really, just the way I've figured it out my self. Thanks for the tip do, will try it later.


::: Using Arch Linux Since October 25, 2011 :::
::: Tutorials: http://distrogeeks.com/ :::

Offline

#4 2012-03-08 17:17:44

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Thunar Action - Extract tar.xz Files

I have these in my .bashrc, perhaps they can help you with adding custom actions:

# ARCHIVES
# usage: ex <file>
ex ()
{
  if [ -f $1 ] ; then
    case $1 in
      *.tar.bz2)   tar xjf $1    ;;
      *.tar.gz)    tar xzf $1    ;;
      *.bz2)       bunzip2 $1    ;;
      *.rar)       unrar x $1    ;;
      *.gz)        gunzip $1     ;;
      *.tar)       tar xf $1     ;;
      *.tbz2)      tar xjf $1    ;;
      *.tgz)       tar xzf $1    ;;
      *.zip)       unzip $1      ;;
      *.Z)         uncompress $1 ;;
      *.7z)        7z x $1       ;;
      *.xz)        tar xvJf $1   ;;
      *)           echo "'$1' cannot be extracted via ex()" ;;
    esac
  else
    echo "'$1' is not a valid file"
  fi
}

If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#5 2012-03-08 17:19:03

TuxLyn
Member
From: United States
Registered: 2011-10-26
Posts: 283

Re: Thunar Action - Extract tar.xz Files

@Unia, heh I was actually about to code something similar. Thank you.
Here is mine for ZIP/RAR, http://wiki.gotux.net/config:bash#custo … -extractor
I will be coding custom extract function that includes all of this archives listed here http://wiki.gotux.net/help:arc

Last edited by TuxLyn (2012-03-08 17:24:35)


::: Using Arch Linux Since October 25, 2011 :::
::: Tutorials: http://distrogeeks.com/ :::

Offline

#6 2016-02-07 16:57:00

bejo
Member
Registered: 2016-01-04
Posts: 10

Re: Thunar Action - Extract tar.xz Files

Thanks for the hints.
Can anybody please help me to create a thunar custom command to use the ex() function of Unia which is described above? Apparently, my custom commands in Thunar do not access definitions in my .bashrc file. In a bash shell, the ex() function works. Is there a way to make Thunar access ex() via custom commands?
Thanks in advance.

Offline

#7 2016-02-07 17:20:49

Rasi
Member
From: Germany
Registered: 2007-08-14
Posts: 1,914
Website

Re: Thunar Action - Extract tar.xz Files

First of all: this thread is more than 3 years old. you should start a new thread next time.

and to answer your question, simply save Unia's script as some file and add

#!/usr/bin/env bash

at the top of the file and

for i in "$@"; do ex "$i"; done

at the end.

Make it executable.
Then define the custom action in thunar with command

/path/to/script %N

and define the file suffixes in the conditions tab.

This works with single files and also multiple selections in thunar

Last edited by Rasi (2016-02-07 17:27:24)


He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.

Douglas Adams

Offline

#8 2016-02-10 09:00:52

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: Thunar Action - Extract tar.xz Files

@bejo

Please don't necrobump. Open a new thread and link to this one.

https://wiki.archlinux.org/index.php/Fo … bumping.22

Closing.

Errr.. since this seems to be a Community Contributions thread, I'll go ahead an re-open the thread.

Last edited by x33a (2016-02-10 09:03:59)

Offline

Board footer

Powered by FluxBB