Change default action of clicked files (SOLVED, so far)
Change default action of clicked files (SOLVED, so far)
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
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
Last edited by R-S-H on Wed 21 Aug 2013, 13:23, edited 1 time in total.
[b][url=http://lazy-puppy.weebly.com]LazY Puppy Home
The new LazY Puppy Information Centre[/url][/b]
The new LazY Puppy Information Centre[/url][/b]
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 :
?
Icewm had them in /usr/share/*icewm?* or /usr/lib/*icewm?* I think ( Lupu-5.1.1 ) .
ROX-Filer :
Hmm .. seems to be hardcoded ..?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)
/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).
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
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
[b][url=http://lazy-puppy.weebly.com]LazY Puppy Home
The new LazY Puppy Information Centre[/url][/b]
The new LazY Puppy Information Centre[/url][/b]
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
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?Karl Godt wrote:I am using similar for defaultmediaplayer
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?
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 "$@" ..
Have not many files with spaces though .
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 "$@" ..

Have not many files with spaces though .
Hi.
Here are my scripts.
This one is the defaulttexteditor script.
This one is the defaulttexteditor-bin script.
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?). 
RSH
Here are my scripts.
This one is the defaulttexteditor script.
Code: Select all
#!/bin/sh
exec /usr/local/bin/defaulttexteditor-bin "$@"
Code: Select all
#!/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

RSH
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]
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 :
would grep anything that ends with .png or .PNG in that temporary file .
Another approach :
NOTE : normally things are not executed in shell scripts after an exec shell builtin is triggered. Therefore file_is_image= assignment before exec line .
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: Select all
grep -i '\.png$' /tmp/file_submitted_shift_key_holded_down
Another approach :
Code: Select all
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
«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 :P
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal :P