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 Thu 24 Apr 2014, 00:53
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Change default action of clicked files (SOLVED, so far)
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [9 Posts]  
Author Message
R-S-H

Joined: 18 Feb 2013
Posts: 490

PostPosted: Tue 20 Aug 2013, 17:43    Post subject:  Change default action of clicked files (SOLVED, so far)
Subject description: ...while pressing a shift-key
 

Hi.

I think anyone knows this:

- left-click onto a RoxApp directory runs the RoxApp
- left-click while pressing a shift key opens up the directory

- left-click onto a script executes the script
- left-click while pressing a shift key sends script to defaulttexteditor script

- left-click onto a jpg image sends the image to the image viewer
- left-click while pressing a shift key sends the image to... ... ...

... ... ...no, not to the image editor!

It sends the image to defaulttexteditor script also!

I want to change/modify this behavior.

So, where to do this?

Thanks

RSH

_________________
LazY Puppy Home
The new LazY Puppy Information Centre


Last edited by R-S-H on Wed 21 Aug 2013, 09:23; edited 1 time in total
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3860
Location: Kiel,Germany

PostPosted: Tue 20 Aug 2013, 18:11    Post subject:  

Openbox should have its configuration files somewhere ..

?

Icewm had them in /usr/share/*icewm?* or /usr/lib/*icewm?* I think ( Lupu-5.1.1 ) .

ROX-Filer :
Quote:
User-definable shortcuts are disabled by default in Gtk2, and you have not enabled them. You can turn this feature on by:

1) using an XSettings manager, such as ROX-Session or gnome-settings-daemon, or

2) adding this line to ~/.gtkrc-2.0:
gtk-can-change-accels = 1
(this only works if NOT using XSETTINGS)

Hmm .. seems to be hardcoded ..?
Back to top
View user's profile Send private message Visit poster's website 
Karl Godt


Joined: 20 Jun 2010
Posts: 3860
Location: Kiel,Germany

PostPosted: Tue 20 Aug 2013, 18:21    Post subject:  

/usr/local/apps/ROX-Filer/Help/Manual.html wrote:
Left button click Open the file or directory clicked on. Hold down Control to select things instead of opening them. Hold down Shift to look inside applications, treat files as text, follow symlinks, or get more control over mount points (see Removable devices).
Back to top
View user's profile Send private message Visit poster's website 
R-S-H

Joined: 18 Feb 2013
Posts: 490

PostPosted: Wed 21 Aug 2013, 09:22    Post subject:  

Thank you, Karl.

I've solved this using a sub-script (defaulttexteditor-bin) which is executed now by the defaulttexteditor script. In this sub-script I do check at first, if the submitted file or file list includes images (just checking for .png, .jpg, .bmp and .xpm at the moment)

If so, it will send the file/s to my defaultimageeditor script (gimp) - otherwise it will go to defaulttexteditor-bin (geany).

Works pretty good, so far.

RSH

_________________
LazY Puppy Home
The new LazY Puppy Information Centre

Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3860
Location: Kiel,Germany

PostPosted: Wed 21 Aug 2013, 10:41    Post subject:  

I am using similar for defaultmediaplayer with file command to send to gmplayer , gnome-mplayer , ffplay , vlc or gxine .
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 204
Location: Japan

PostPosted: Mon 26 Aug 2013, 08:20    Post subject:  

Karl Godt wrote:
I am using similar for defaultmediaplayer
I'm a bit lost here. I understand that R-S-H changed the defaulttexteditor script so that the script checks the file extensions (?) of the files passed to the script, then depending on file extension opens a suitable application. Is my assumption correct?

But what do you use for the defaultmediaplayer? If you Shift click a .mp3 file it's passed to defaulttexteditor, not defaultmediaplayer. Could you post an example?
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3860
Location: Kiel,Germany

PostPosted: Mon 26 Aug 2013, 09:11    Post subject:  

Hey Moppel !

I am not using it for some ketzplank shortcut .

It's just for the
exec defaultmediaplayer "$@"
mime-type in /root/Choic/MIME-Types ie audio_mp4.

Hate shortcuts because it seems that every app uses its own syntax for shift and control and alt and that's too difficult for me to remember .

BTW must recognize, that in Precise 550 it is again "$1" instead of "$@" .. Evil or Very Mad
Have not many files with spaces though .
Back to top
View user's profile Send private message Visit poster's website 
RSH


Joined: 05 Sep 2011
Posts: 2036
Location: Germany

PostPosted: Mon 26 Aug 2013, 16:58    Post subject:  

Hi.

Here are my scripts.

This one is the defaulttexteditor script.
Code:
#!/bin/sh
exec /usr/local/bin/defaulttexteditor-bin "$@"


This one is the defaulttexteditor-bin script.
Code:
#!/bin/sh
#------------------------------------------------------------------------------
# New BackEnd for the defaulttexteditor Script
# Check for image files first and send them to 'defaultimageeditor' Script
# when doing a left-click onto the image while holding a shift key down
#------------------------------------------------------------------------------

# Send submitted file name/s into a temp file
echo "$@" > /tmp/file_submitted_shift_key_holded_down

# Check for jpg, bmp, xpm and png files
# If submitted file is a image file (picture) send file to gimp
file_is_image="false"
if (grep '.png' /tmp/file_submitted_shift_key_holded_down) then
   exec /usr/local/bin/defaultimageeditor "$@"
   file_is_image="true"
   elif (grep '.PNG' /tmp/file_submitted_shift_key_holded_down) then
   exec /usr/local/bin/defaultimageeditor "$@"
   file_is_image="true"
   elif (grep '.jpg' /tmp/file_submitted_shift_key_holded_down) then
   exec /usr/local/bin/defaultimageeditor "$@"
   file_is_image="true"
   elif (grep '.JPG' /tmp/file_submitted_shift_key_holded_down) then
   exec /usr/local/bin/defaultimageeditor "$@"
   file_is_image="true"
   elif (grep '.bmp' /tmp/file_submitted_shift_key_holded_down) then
   exec /usr/local/bin/defaultimageeditor "$@"
   file_is_image="true"
   elif (grep '.BMP' /tmp/file_submitted_shift_key_holded_down) then
   exec /usr/local/bin/defaultimageeditor "$@"
   file_is_image="true"
   elif (grep '.xpm' /tmp/file_submitted_shift_key_holded_down) then
   exec /usr/local/bin/defaultimageeditor "$@"
   file_is_image="true"
   elif (grep '.XPM' /tmp/file_submitted_shift_key_holded_down) then
   exec /usr/local/bin/defaultimageeditor "$@"
   file_is_image="true"
   else
   file_is_image="false"
fi

# Else, submitted file is not a image file (picture) - so, send file to Geany
if [ "$file_is_image" = "false" ]; then
   exec geany "$@"
fi

Even though it works, I'm sure, real programmers would laugh on it and surely able to solve this using a three-lin-script (maybe?). Laughing

RSH

_________________
LazY Puppy
RSH's DNA
SARA B.
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3860
Location: Kiel,Germany

PostPosted: Mon 26 Aug 2013, 17:22    Post subject:  

i would suggest to use -i --ignore-case option for grep .

Further : grep treats '.' as regular expression as any char placeholder by default. It needs to be escaped with blackslash to be interpreted as literal dot .
The use of '$' for last chars as regular expression might make sense too .

Example :
Code:
grep -i '\.png$' /tmp/file_submitted_shift_key_holded_down

would grep anything that ends with .png or .PNG in that temporary file .

Another approach :

Code:
SUFFIX=`echo "$@" | grep -oiE '\.png$|\.jpeg$|\.jpg$|\.ti[f]*$|\.bmp$|\.xpm$'`
case $SUFFIX in

.png|.PNG|.jpeg|.JPEG|.jpg|.JPG|.tiff|.TIFF|.bmp|.BMP|.xpm|.XPM)
file_is_image="likely_true"
exec defaultimageeditor "$@"
;;
*|'')
file_is_image="likely_false"
file  "$@" | grep -iE 'script|text' && exec defaulttexteditor "$@"
;;

esac

NOTE : normally things are not executed in shell scripts after an exec shell builtin is triggered. Therefore file_is_image= assignment before exec line .

_________________
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal Razz
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [9 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
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.0742s ][ Queries: 12 (0.0093s) ][ GZIP on ]