Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 21 Nov 2017, 13:58
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
How to make Rox filer open the right programs
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [19 Posts]   Goto page: 1, 2 Next
Author Message
Rattlehead


Joined: 11 Sep 2008
Posts: 367

PostPosted: Thu 26 May 2016, 23:58    Post subject:  How to make Rox filer open the right programs
Subject description: A workaround script I made to solve this problem
 

With certain files, Rox Filer has a hard time detecting which program must use to open them. The problem seems to be that it checks the type of file not by looking on the file name termination, but on something called "Mime types".

As a result, different kind of files, with different file extensions, can share the same Mime type and therefore Rox will not allow them to open with different programs: if you change the default action for one of them with the "Set run action" option, it will change for both, so one of them will be wrong.

The baseline result is that you cannot open one of those files by simply clicking on them or press enter; it will open with a wrong program and generate a weird error, so you have to select them, press "!" for the execute command, and write the name of the appropriate program time after time. A drag and a continuous source of errors.

Here is a recent way I found to circumvent that problem; for those programs who share the same Mime type, we'll send control to a bash script, which will the one in charge of doing the checking and execute the correct program. Here it is:

Code:

#!/bin/bash

#Get extension
 filename=`basename $1`
 fileext=${filename##*.}

case $fileext in

h2song)

hydrogen -s $1 &
;;

aup)

audacity $1 &

;;

ardour)

ardour2 $1 &
;;

esac


Now we need to tell Rox to send the files to it. We Select one of the conflicting files -anyone will do-, execute "set run action" (keyboard shortcut "*"), and in the field "Enter a shell command", type the complete path to the script, keeping the "$@" symbol at the end (a wildcard that means current selection). In my case the line would be: /root/my-scripts/rox-wrapper.sh "$@". Click "Use command" to save the changes.

As Rox does not differentiate between the types of files, we only need to do this change once, and it will be applied automatically to the other files. Finally, in each of the "case" entries in the script, we put one file termination that we want to use, and the program with which we want it to be executed. In my example script, it recognizes three kind of files: Hydrogen, Audacity, and Ardour. Previously to this trick, Rox filer considered the three of them to be Ardour, so it was easy to make mistakes when trying to open something. Other programs where I remember this happens are the Xmind mind mapping software, and the Portabase database.

Hope some of you find this little trick helpful Smile
Back to top
View user's profile Send private message 
LazY Puppy


Joined: 21 Nov 2014
Posts: 2007
Location: Germany

PostPosted: Fri 27 May 2016, 19:42    Post subject:  

If clicking a file by holding a shift key down, Rox will send the file to /usr/local/bin/defaulthandler (the file is interpeted as text file then, so the defaulthandler will send it to defaulttexteditor).

Just edit /usr/local/bin/defaulthandler to the like.

In between of case and esac in my defaulthandler script wrote:
# SFS Modules
iso|ISO)
filemnt "$FFILE"
;;

# SFS Modules
sfs|SFS)
sfs-handler "$FFILE"
;;

# Archives
gz|GZ|bz|BZ|tar*|TAR*|zip|ZIP|tgz|TGZ)
/usr/bin/xarchive "$FFILE"
;;

# Install Packages
deb|DEB|pet|PET)
/usr/local/petget/petget "$FFILE"
;;

# Plain Text Documents
txt|TXT|lst|LST|cfg|CFG|specs|SPECS|rc|RC|sh|SH|py|PY|js|JS|json|JSON)
/usr/local/bin/defaulttexteditor "$FFILE"
;;

# Word Office Document
doc|DOC|rtf|RTF|docx|DOCX|odt|ODT)
/usr/local/bin/defaultwordprocessor "$FFILE"
;;

# Spreadsheet Office Documents
xls|XLS|gnumeric|GNUMERIC|odc|ODC|ods|ODS)
/usr/local/bin/defaultspreadsheet "$FFILE"
;;

# HTML/XML and similar Documents
htm*|HTM*|xml|XML|css|CSS|php|PHP)
/usr/local/bin/defaulttexteditor "$FFILE"
;;

# Image Documents 1 - GIMP should be the 'defaultimageeditor'
xcf|XCF|ico|ICO|psd|PSD|gs|GS)
/usr/local/bin/defaultimageeditor "$FFILE"
;;

# Image Documents 2 - ViewNior
bmp|BMP|jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF|tif*|TIF*|xpm|XPM)
#/usr/local/bin/defaultimageeditor "$FFILE"
[ "$IMGEDITNOVIEW" = "true" ] && /usr/local/bin/defaultimageeditor "$FFILE" || /usr/local/bin/defaultimageviewer "$FFILE"
;;

# Image Documents 3 - Corel Photopaint
cpt|CPT)
/usr/local/bin/defaultcorelphotoeditor "$FFILE"
;;

# Image Documents 3 - Corel Draw
cdr|CDR)
/usr/local/bin/defaultcoreldraweditor "$FFILE"
;;

# Image Documents 3 - Corel Dream 3D
d3d|D3D)
/usr/local/bin/defaultcoreldreameditor "$FFILE"
;;

# PDF/PostScript Documents
pdf|PDF|ps|PS|eps|EPS)
/usr/local/bin/defaultpdfviewer "$FFILE"
;;

# Audio Documents
mp3|MP3|wav|WAV|flac|FLAC|ogg|OGG)
#/usr/local/bin/defaultaudioeditor "$FFILE"
#/usr/local/bin/defaultplayer "$FFILE"
[ "$AUDEDITNOPLAY" = "true" ] && /usr/local/bin/defaultaudioeditor "$FFILE" || /usr/local/bin/defaultmediaplayer "$FFILE"
;;

# Video Documents
mp4|MP4|mpg|MPG|mpeg|MPEG|avi|AVI|mkv|MKV)
/usr/local/bin/defaultmediaplayer "$FFILE"
;;

#---------------------------
# End of default Definitions
#---------------------------

# Any else Documents
*)
#/usr/local/bin/defaulttexteditor-bin "$FFILE"
"$BINSDIR"/defaulttexteditor-bin "$FFILE"
;;

_________________
RSH

"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) Laughing

No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! Wink
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1392
Location: Japan

PostPosted: Fri 27 May 2016, 21:49    Post subject:  

The wrapper script proposed by Rattlehead is supposed to open the "right program" with a simple click, not a Shift-click.

LazY Puppy wrote:
If clicking a file by holding a shift key down, Rox will send the file to /usr/local/bin/defaulthandler
Does it? I've never seen this in any Puppy, and if it would, it would be a bad idea - at least if it would open the slightly messy defaulthandler in my Slacko 5.6. Does anyone know why this defaulthandler exists?
Back to top
View user's profile Send private message 
LazY Puppy


Joined: 21 Nov 2014
Posts: 2007
Location: Germany

PostPosted: Fri 27 May 2016, 23:04    Post subject:  

MochiMoppel wrote:
The wrapper script proposed by Rattlehead is supposed to open the "right program" with a simple click, not a Shift-click.

LazY Puppy wrote:
If clicking a file by holding a shift key down, Rox will send the file to /usr/local/bin/defaulthandler
Does it? I've never seen this in any Puppy, and if it would, it would be a bad idea - at least if it would open the slightly messy defaulthandler in my Slacko 5.6. Does anyone know why this defaulthandler exists?

This is default in Linux/Rox. Any file clicked by holding shift key down is handled/interpreted as .txt file and will go to defaulthandler/defaulttexteditor.

I know about Rattlehead's proposal since I did understand the post's content.

Just wanted to show how I do send files to its programs easily.

Clicking a .jpg file usually ends in image viewer. When I'm holding shift key down, it ends up in image editor which is The GIMP in my setup.

If you have a plain defaulthandler click a binary holding shift key down - text editor will appear on the screen (though, the binary will not load, of course).

In my opinion, it's not a bad idea. It gives control over files without to change default behavior in general.

_________________
RSH

"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) Laughing

No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! Wink
Back to top
View user's profile Send private message 
Rattlehead


Joined: 11 Sep 2008
Posts: 367

PostPosted: Sat 28 May 2016, 00:15    Post subject:  

@Lazy Puppy, thank you for the info on defaulthandler, I didn't know it existed.

I've been trying to look into it, as it would be great to have a set of two possible executable programs (for example for cases like what you mention, an image that sometimes you just want to see but sometimes want to edit). There is something I don't understand. In my /usr/local/bin/defaulthandler, which I have never touched, there is already a case command with several options. One of them is "png":

Code:
 png|PNG|gif|GIF|jpg|JPG|jpeg|JPEG|xpm|XPM)
  /usr/local/bin/defaultpaint "$1"
 ;;


However, if I click+shift on a .png file, it opens in the text editor. What should I change in the script to unlock these additional options? (I've already backed it up first lol).
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1392
Location: Japan

PostPosted: Sat 28 May 2016, 01:15    Post subject:  

LazY Puppy wrote:
Any file clicked by holding shift key down is handled/interpreted as .txt file
That's the basic idea behind the "Open as text" menu item (which is the same as Shift-click)
Quote:
and will go to defaulthandler/defaulttexteditor.
It will go to the defaulttexteditor, not to defaulthandler - unless your Puppy is configured to use the defaulthandler for MIME type text/plain.

I don't say that defaulthandler is a bad idea as such. Your setup of allowing a JPG file be opened either by the imageviewer or the imageeditor is a good example. It makes no sense to send a JPG file to a text editor. But this requires a careful configuration. In the current defaulthandler I see that html , pdf, rtf files are all sent to their respective default applications, i.e. simple clicking or Shift-clicking has the same effect. That's not what it should be. If I Shift-click a rtf file I do want to see the source code in an editor, if I Shift-click a html file I do want to see the mark up text in an editor, not necessarily Geany, but this is where the customization comes in. I definitely don't want to open the browser when Shift-clicking on a html file.

Rattlehead wrote:
if I click+shift on a .png file, it opens in the text editor. What should I change in the script to unlock these additional options?
Nothing in this script.
When you Shift-click on any file ROX will run the script /root/Choices/MIME-types/text_plain. Edit this script and change
Code:
exec defaulttexteditor "$1"

to
Code:
exec defaulthandler "$1"

Or you could right click a text file and set the run action for type text/plain to defaulthandler "$@"

BTW: Hopping from wrapper script to wrapper script is an old Puppy tradition, but couldn't this be done much easier?
Instead of
ROX => /root/Choices...text_plain => defaulthandler => defaulteditor => Geany
it could be
ROX => /root/Choices...text_plain => Geany
Extension sniffing and application choice, i.e. all the logic of defaulthandler, could be handled with only one script between ROX and the application.
Back to top
View user's profile Send private message 
LazY Puppy


Joined: 21 Nov 2014
Posts: 2007
Location: Germany

PostPosted: Sat 28 May 2016, 10:16    Post subject:  

Quote:
In the current defaulthandler I see that html , pdf, rtf files are all sent to their respective default applications, i.e. simple clicking or Shift-clicking has the same effect. That's not what it should be. If I Shift-click a rtf file I do want to see the source code in an editor, if I Shift-click a html file I do want to see the mark up text in an editor, not necessarily Geany, but this is where the customization comes in. I definitely don't want to open the browser when Shift-clicking on a html file.

My defaulthandler script still is a modified version from old Lucid 528. It is mainly used by JWM menu pipes to send files from within $BOOTPARTITION/My-Files/SubDirs-here to its programs by a file's menu pipe entry.

My defaulttexteditor script calls defaulttexteditor-bin which is modified almost equal to the defaulthandler script - just overseen this. Didn't have a look into these files for a long time - as usual when it's still/just working.

_________________
RSH

"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) Laughing

No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! Wink
Back to top
View user's profile Send private message 
Rattlehead


Joined: 11 Sep 2008
Posts: 367

PostPosted: Mon 06 Jun 2016, 01:31    Post subject:  

Thank you for the explanations (sorry for the time it took me to answer).

I'd like to apply the aforementioned customization, but I find an obstacle: I open plain text files, and .otl (vim outline) files, with the set run action "gvim $@". If I use defaulthandler instead, I get the double option (mtpaint of viewnior) for images, which is great, but texts open in geany instead.

My brain is not fully engaged right now, but I think maybe I could achieve this if I modified defaulttexteditor to gvim. Do you know how to do it? If not nevermind, I'll find it somewhere in this forum I'm sure.
Back to top
View user's profile Send private message 
Sailor Enceladus

Joined: 22 Feb 2016
Posts: 1289

PostPosted: Tue 07 Jun 2016, 12:49    Post subject:  

I just did a similar thing to get "oga" (from ETP's thread here) to open in browser but ogg in audio player.

Here's the contents of audio.ogg:

Code:
#! /bin/sh
# open oga (ogg container/opus codec) in browser

if [ "`echo "$1" | tail -c 4 | head -c 3`" == "oga" ]; then
   defaultbrowser "$@"
else
   defaultaudioplayer "$@"
fi

edit: I think this might work better (still testing random oggs with it, I needed to upgrade to file-5.27 to see "Opus"):

Code:
#! /bin/sh

if [ "`file -b "$1" | grep Opus`" ]; then
   defaultbrowser "$@"
else
   defaultaudioplayer "$@"
fi
Screenshot.png
 Description   
 Filesize   20.78 KB
 Viewed   440 Time(s)

Screenshot.png


Last edited by Sailor Enceladus on Tue 07 Jun 2016, 21:00; edited 2 times in total
Back to top
View user's profile Send private message 
Smithy


Joined: 12 Dec 2011
Posts: 794

PostPosted: Tue 07 Jun 2016, 19:23    Post subject:  

Whilst people are talking about Rox, is it possible to make a progress display for files?
I have sat there waiting for the copy or move dialog box to close wondering if it has crashed when copying or moving a file (it never has crashed).

Here's an example of what I mean:
https://bash.cyberciti.biz/guide/A_progress_bar_%28gauge_box%29

Maybe in a fetching green..
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1392
Location: Japan

PostPosted: Wed 08 Jun 2016, 01:14    Post subject:  

Sailor Enceladus wrote:

edit: I think this might work better (still testing random oggs with it, I needed to upgrade to file-5.27 to see "Opus"):

Code:
#! /bin/sh

if [ "`file -b "$1" | grep Opus`" ]; then
   defaultbrowser "$@"
else
   defaultaudioplayer "$@"
fi
I think this might not work at all Laughing
1) I downloaded the sample oga file from ETP's thread (Old Love.oga), and file -b "Old Love.oga" returns "Ogg data" - no Opus Crying or Very sad

2) I downloaded a sample ogg file, and in Slacko 5.6 the MIME type for this file is x-vorbis+ogg, so ROX would not read your audio_ogg script (ROX would expect an audio_x-vorbis+ogg script)

Your best bet might be to do the extension sniffing in the defaultaudioplayer script. That's the place where all (?) music files pass through and where you can send them to the most suitable application.
Back to top
View user's profile Send private message 
Sailor Enceladus

Joined: 22 Feb 2016
Posts: 1289

PostPosted: Wed 08 Jun 2016, 13:12    Post subject:  

MochiMoppel: Haha yeah, it's pretty messed up, I had to compile file-5.27 from source to even see the "Opus audio" with file -b (older versions don't know what it is) and even then some oggs/ogas use weird things like x-flac+ogg (ogg containers for flac! wth) instead of audio_ogg like you said. I ended up just compiling MPlayer 1.3 from the source snapshot and now all that Opus stuff opens automatically without having to use a browser, working nice so far and beats awkward file manager exceptions! Laughing
Back to top
View user's profile Send private message 
scientist

Joined: 23 May 2015
Posts: 864

PostPosted: Wed 08 Jun 2016, 16:08    Post subject:  

Smithy wrote:
Whilst people are talking about Rox, is it possible to make a progress display for files?
I have sat there waiting for the copy or move dialog box to close wondering if it has crashed when copying or moving a file (it never has crashed).

Here's an example of what I mean:
https://bash.cyberciti.biz/guide/A_progress_bar_%28gauge_box%29

Maybe in a fetching green..


Thunar file manager has a progress display when moving or copying files.

_________________
Thanks,
Andy


Slacko 6.3.0 FULL INSTALL
JWM
File Manager - Thunar
Back to top
View user's profile Send private message 
Smithy


Joined: 12 Dec 2011
Posts: 794

PostPosted: Wed 08 Jun 2016, 18:52    Post subject:  

Hi Scientist, I liked Thunar very much, but Rox filer seems to be the one the developers go with, so I was wondering about refinements in the woof git ce thing..
Another niggle was, I transferred 56gb recently, and Rox said there were three errors.
However, it did not say what three errors they were!
So at some point I might load up just an archive file that maybe corrupted!
Hey ho, three out of thousands 'aint bad, or whatever Meatloaf sang.
Back to top
View user's profile Send private message 
LazY Puppy


Joined: 21 Nov 2014
Posts: 2007
Location: Germany

PostPosted: Wed 08 Jun 2016, 20:05    Post subject:  

Smithy wrote:
Another niggle was, I transferred 56gb recently, and Rox said there were three errors.
However, it did not say what three errors they were!

Assuming those 56gb was a huge collection of files and not just a single one:

There should be a GUI while copying is executed and copied files are scrolling heavily in its window - dependent on the size of the files.

If the GUI doesn't quit and tells you of some errors, you can scroll the list manually to find out the errors.

Those 'copy-error-files' lines in the text field of the GUI will appear in red color.

Though it's a bit uncomfortable I must say...

_________________
RSH

"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) Laughing

No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! Wink
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 2 [19 Posts]   Goto page: 1, 2 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0968s ][ Queries: 12 (0.0098s) ][ GZIP on ]