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 17 Apr 2014, 00:40
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
How to make clicking/running directory execute a file?
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [12 Posts]  
Author Message
sunburnt


Joined: 08 Jun 2005
Posts: 4979
Location: Arizona, U.S.A.

PostPosted: Wed 13 Jun 2012, 02:59    Post subject:  How to make clicking/running directory execute a file?  

RoxApps, or AppDirs do this, but I find no info. on the mechanism.
File associations it seems are only for files... Makes sense.

# So how to setup dir. associations?

The dir. has an extension: .sqApp
Want running the dir. to run the file SqApp inside it.

CLI would be the best because then a GUI click would be easy to setup.

For GUI I think I`ll have to pick a file browser like Xfe and mod it to work.
I dislike "Open With", never use it, I need control of click and Rt. click.
Back to top
View user's profile Send private message 
ravensrest


Joined: 22 Feb 2008
Posts: 321
Location: Hood Canal, WA

PostPosted: Wed 13 Jun 2012, 10:33    Post subject:  

I am not sure how you might do it with a mouse click, but if it is always the same directory and same file, then you could write a very simple 2-line script to do it:

CD (desired directory)
exec (desired file)

You could run it from CLI or make it an icon on the pinboard.

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


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

PostPosted: Wed 13 Jun 2012, 10:57    Post subject:  

I think the execute file is named "AppRun" for rox and maybe needs this additional AppInfo.xml .

If you want to click in the terminal : Are you referring to something like midnight commander ?

If so, did you get mouse support to work (by gpm or whatever) ?
Back to top
View user's profile Send private message Visit poster's website 
L18L

Joined: 19 Jun 2010
Posts: 2473
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Wed 13 Jun 2012, 14:13    Post subject: Re: How to make clicking/running directory execute a file?  

sunburnt wrote:
...For GUI I think I`ll have to pick a file browser like Xfe and mod it to work.
I dislike "Open With", never use it, I need control of click and Rt. click.


If you take file browser rox then everything is ready.

right click > menu
left click > AppRun is executed

working example: gparted

# ls -la
insgesamt 16
drwxr-xr-x 2 root root 4096 Jun 13 19:00 .
drwxr-xr-x 22 root root 4096 Jun 13 17:52 ..
-rwxr-xr-x 1 root root 125 Jun 13 17:47 AppInfo.xml
lrwxrwxrwx 1 root root 27 Jun 13 18:58 AppRun -> ../../../sbin/gparted_shell
-rw-r--r-- 1 root root 2903 Jun 13 19:00 .DirIcon
#


AppInfo.xml:
Code:
<?xml version="1.0"?>
<AppInfo>
  <Summary>GParted</Summary>
  <Summary xml:lang="de">Partitionen-Editor</Summary>
</AppInfo>


The answer to your question: look into rox sources Cool
gparted_in_rox_apps.png
 Description   gparted integrated into rox/apps
 Filesize   17.19 KB
 Viewed   395 Time(s)

gparted_in_rox_apps.png

Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 4979
Location: Arizona, U.S.A.

PostPosted: Wed 13 Jun 2012, 14:42    Post subject:  

Hi ravensrest; I forgot to mention it`s stand-alone like the ROX Apps.
The point is to have the dir. be the only thing required to run the app.

Hey Karl; No, not click in CLI just GUI. The CLI need is like the mime Q.
I`m looking for a method to get running a dir. to exec. a file inside it.
# Appinfo.xml only has app. info.:
Code:
<?xml version="1.0"?>
<AppInfo>
  <Summary>Abiword text editor</Summary>
</AppInfo>

I saw a patch for Bash-201 someone wrote in C that makes this happen.
Too old to be of any use now.

Hi L18L; Yeah, I know about Rox and Gobo Linix, but I don`t care for ROX-Filer.
I like the Xfe / Win.Explorer type GUI.
One would hope that there is a Rox exec. or lib. that does the work.

# But the real Q is... How to get Bash to do it? Then the GUI is a snap.
.
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2473
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Wed 13 Jun 2012, 14:57    Post subject:  

sunburnt wrote:
...# But the real Q is... How to get Bash to do it? Then the GUI is a snap.
.

Code:
# rox /usr/local/apps/gparted/
#

has launched gparted

(give a directory to a web server and it will take a default file)
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 4979
Location: Arizona, U.S.A.

PostPosted: Wed 13 Jun 2012, 22:26    Post subject:  

Hi L18L; The file rox is a shell script, I can do that too, but that`s not it.
I don`t want to have to run a shell script to run another shell script.

I put an AppRun file in a dir. and ROX-Filer changed the icon, so that`s it.

Bash in a VT does nothing with RoxApp dirs. Only running the file works.
I`d be happy if Bash would recognize a dir. by extension like a file.
I can easily write a script to do this, but it`s not what I had in mind.

If Bash had sockets, behaviors could be added without patching it.

But I will probably have to settle for writing a AppDir script for Xfe.
Back to top
View user's profile Send private message 
Bruce B


Joined: 18 May 2005
Posts: 11049
Location: The Peoples Republic of California

PostPosted: Thu 14 Jun 2012, 06:02    Post subject:  

Quote:
I`d be happy if Bash would recognize a dir. by extension like a file.


Bash can recognize directories by at least two methods I know of.

1) the test command using the -d switch. For details type help test on the CLI

2) an ls file listing output. Example below:

ls -l | grep ^d would display only the directories

3) I suppose there are other ways I just don't know about.

~~~~~~~~~~~~

_________________
New! Puppy Linux Links Page
Back to top
View user's profile Send private message 
Karl Godt


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

PostPosted: Thu 14 Jun 2012, 12:12    Post subject:  

Just a short idea :

how about a function in .bashrc ?

like

Code:
toggle_mybash(){
something=1
while [ $something ];do
read -p "Enter [command] : # " ENTRY
[ "$ENTRY" ] || continue
EVTL_COMMAND=${ENTRY%% *}
EVTL_PARAMETERS=${ENTRY##* }
if test `which $EVTL_COMMAND` ;then
$EVTL_COMMAND "$EVTL_PARAMETERS"
elif test -d "$ENTRY" ;then
[ -x "$ENTRY"/AppRun ] && "$ENTRY"/AppRun
elif test -f "$ENTRY" ;then
"$ENTRY"
elif test "`type $ENTRY`" ;then
$ENTRY
elif test "$ENTRY" ;then
"$ENTRY"
else
"$ENTRY"
fi;done; };toggle_mybash


which can be left/escaped by "return" or "exit" command.
Back to top
View user's profile Send private message Visit poster's website 
sunburnt


Joined: 08 Jun 2005
Posts: 4979
Location: Arizona, U.S.A.

PostPosted: Thu 14 Jun 2012, 15:30    Post subject:  

Hi Bruce B; The thought was that Bash would recognize an "extension" on a dir. just like it does for a file.
Then this would allow for mime behavior with dirs. as well as files.
Of course Bash doesn`t really use mime any way, but it could / should.
That`s why I was dreaming of Bash plug-ins. Idea

Karl; This comes about as close as I think it can get.
I was thinking maybe something could be done in profile.local or .bashrc.

Q: Wouldn`t all the tests after running AppRun be easier with just "else"?

I think this could work for the junction hack I made, and Bash mime too!
I`ll see how the whole idea pans out and let you know.
Back to top
View user's profile Send private message 
Karl Godt


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

PostPosted: Thu 14 Jun 2012, 15:45    Post subject:  

i think that this can implemented in the bash source code . I am guessing the soure already uses a C case loop for this like i have often seen in main()s parsing parameters .

Don't know if you want a full bash or just your_bash .

which command seems not to work on shell buitins like return, here type is needed .
Back to top
View user's profile Send private message Visit poster's website 
sunburnt


Joined: 08 Jun 2005
Posts: 4979
Location: Arizona, U.S.A.

PostPosted: Thu 14 Jun 2012, 17:26    Post subject:  

I tried your function and it works of course, but console is plain-vanilla.
There`s no command history and probably other behaviors are lost too.
But I`m thinking that a special sh fork could run the loop and be used?
This would keep Bash from being hijacked and made partly unusable.
Code:
sh-4.1# /mnt/sdb3/AppDir/Fox-1.6.45
sh: /mnt/sdb3/AppDir/Fox-1.6.45: is a directory
sh-4.1# bash
sh# ^[sddfsf: command not found ............... bash not taking arrows, etc.
sh# : type:
sh#
sh# ^[[A^[[B
bash: type: : not found
bash: : command not found
sh# /mnt/sdb3/AppDir/Fox-1.6.45 .................. command works
sh#

Notice that the sh shell didn`t respond, but entering the bash shell did.

### Here`s your script I modded and added to .bashrc
Code:
shmod(){               # intercept commands and process them
   while :
   do
      read -p "sh# " ENTRY
      [ "$ENTRY" ] || continue
      EVTL_COMMAND=${ENTRY%% *}
      EVTL_PARAMETERS=${ENTRY##* }

      if test `which $EVTL_COMMAND` ;then
         $EVTL_COMMAND "$EVTL_PARAMETERS"
      elif test -d "$ENTRY" ;then
         [ -x "$ENTRY"/AppRun ] && "$ENTRY"/AppRun
      elif test -f "$ENTRY" ;then
         "$ENTRY"
      elif test "`type $ENTRY`" ;then
         $ENTRY
      elif test "$ENTRY" ;then
         "$ENTRY"
      else
         "$ENTRY"
      fi
   done;
}
shmod


I can write a C exec. in BaCon of this and it will be better.
The code could be added to Bash`s daemon loop, but I wouldn`t know how...
But I think more development on it is needed.

I`m going to try it for mime and with my junction hack.
This shell mod and mime are Bash items, but the junction is really a kernel item.

# I`m taking my boy to see the movie: The Avengers ( action and funny! ).
So I`ll be gone for 4 hours or more.

Thanks for the point in the right direction Karl, I`m hopeful about this!

Ihr Freund... Terry B.
.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [12 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.0777s ][ Queries: 12 (0.0082s) ][ GZIP on ]