Page 1 of 3

It was so obvious... :-) ...yet nobody saw it!

Posted: Sat 30 May 2015, 18:29
by musher0
What's been staring at every Puppyist in the face for years and we
haven't seen it? :) ... A sub-menu for the default apps in Puppy...

(Edit May 31st, 2015, 23 h 00, Gatineau time:
A much prettier and much faster version is here and illustrated
in following posts.)


Sooo obvious and sooo useful !

Code: Select all

#!/bin/sh
# /usr/local/bin/progs-default.sh
# But : créer un aemenu des logiciels par défaut
# dans PuppyLinux pour le gest. de fen. aewm, echinus ou autre.
# Dépendance : aemenu
# (c) musher0, 30 mai 2015.
####
cd /usr/local/bin/

ls -Algoh --file-type defau* | awk '$1 !~ /lrw/ && $7 !~ /.cdr/ && $7 !~ /.bak/ && $7 !~ /han/ { print $7 }' > liste-progs

case ${LANG:0:2} in
	fr)Header="~ Par défaut ~"
	Footer="~ dans Puppy ~"
	Vide="Certaines entrées peuvent être vides."
	;;
	
	*)Header="~ By default ~"
	Footer=" ~ in Puppy ~"
	Vide="Some entries may be empty."
	;;
esac

echo "menu \" $Header\"" > progs-default
echo "cmd \"~~~~~~~~~~\" \" \"" >> progs-default

for i in `cat liste-progs`;do
echo "cmd ${i#*t} $i" >> progs-default
done

echo "cmd \"~~~~~~~~~~\" \" \"" >> progs-default
echo end >> progs-default

echo "cmd \" $Footer\" \" \"" >> progs-default

echo "menu \"~~~~~~~~~\"" >> progs-default
echo "cmd \" $Vide\" \"\"" >> progs-default
echo end >> progs-default >> progs-default

echo "cmd \" ~ 'Chooser' ~\" /usr/bin/defaults-chooser" >> progs-default

aemenu -rc /usr/local/bin/progs-default

rm -f liste-progs
Please shed a tear for our collective oversight. :lol: 8)

The wiggly line warns that some entries may be empty. The last line
invites the user to use the "Default Chooser" to fill those voids or to insert
your own default programs.

Finally, you'll need aemenu, from the aewm package, as a dependency
to get to this sub-menu profit. Don't go hunting on the 'Net, there are 2-3
ready-made, compiled, copies lying around on this board. Just put your
muzzle to the ground, and use your usual detective powers!

And don't enjoy, nah, don't bother enjoying this. Enjoyment is overrated. :twisted:

Bye for now.

musher0

Posted: Sat 30 May 2015, 20:31
by Flash
I have no idea what this would do for me. Could you elaborate a bit?

Posted: Sun 31 May 2015, 03:21
by musher0
Flash wrote:I have no idea what this would do for me. Could you elaborate a bit?
Hi, Flash.

This script offers direct and express menu access to most default
programs that all Puppies have in /usr/local/bin under the name
"default-something". Their choice is initially decided by the creator of the
Puppy version.

Those default-something scripts in /usr/local/bin contain the default
choice for spreadsheet, word processor, text viewer, image editor, image
viewer, etc. etc., offered to the user by BK, 0micko, 666philb, or whoever
assembled the particular Puppy.

I.e., if you look inside the script
"defaultspreadsheet", you find that it launches gnumeric
"defaultimageeditor", you find that it launches mt-paint,
"defaulttexteditor", you find that it launches geany,
etc., etc.

The only "default" ones excluded are
* "default-handler" -- which is a universal launcher and
* "default-changer" -- a CLI script to change the contents of the "default"
programs themselves.

Direct and express menu access to these default programs has never
been offered before in Puppy.


Using this menu, you can save a couple of mouse clicks to launch geany,
or seamonkey, or mt-paint, or any of the other significant programs you
may need, because they're all there in front of you by type of program.

I hope the above explanation makes it clearer why I am offering this
script to Puppyists.

Bye for now.

musher0

Posted: Sun 31 May 2015, 04:43
by Flash
Thanks! :D

Posted: Sun 31 May 2015, 20:06
by musher0
Hello all.

Here is a prettier and much faster version of this default apps menu.

* prettier, IMO, because the entries are now centered (see pic);
* much faster, because the script now runs in ash instead of bash, AND
__ the menu is only re-created if something in it has changed. In v. 1, the
__ menu was re-created at each launch. With v. 2, if nothing's changed,
__ boom, here's your menu.

Enjoy.

musher0

~~~~~~~~~~

Code: Select all

#!/bin/ash
# /usr/local/bin/progs-default.sh, version 2 
# (avec mise en forme centrée et détection d'existence)
# But : créer un aemenu des logiciels par défaut dans
# 	PuppyLinux pour le gest. de fen. aewm, echinus ou autre.
# Dépendance : aemenu
# (c) musher0, 31 mai 2015.
#### set -xe
cd /usr/local/bin/
DeFProgs="/tmp/progs-default"

construire (){
wc -l /tmp/liste-progs > /tmp/compte-de-lignes
case ${LANG:0:2} in
	fr)Header="~ Par défaut ~";Footer="~ dans Puppy ~" ;;
	*)Header="~ By default ~";Footer=" ~ in Puppy ~" ;; esac

echo -e "menu \" $Header\" \ncmd \"~~~~~~~~~~\" \" \"" > "$DeFProgs"

for i in `cat /tmp/liste-progs`;do j="${i#*t}"
if [ "`echo $j | wc -c`" -eq "4" -o "`echo $j | wc -c`" -eq "5" ];then
	echo "cmd \"        $j\" $i" >> "$DeFProgs"
elif [ "`echo $j | wc -c`" -eq "6" -o "`echo $j | wc -c`" -lt "7" ];then
	echo "cmd \"       $j\" $i" >> "$DeFProgs"
elif [ "`echo $j | wc -c`" -eq "8" -o "`echo $j | wc -c`" -lt "9" ];then
	echo "cmd \"      $j\" $i" >> "$DeFProgs"
elif [ "`echo $j | wc -c`" -eq "10" -o "`echo $j | wc -c`" -lt "11" ];then
	echo "cmd \"     $j\" $i" >> "$DeFProgs"
elif [ "`echo $j | wc -c`" -eq "12" -o "`echo $j | wc -c`" -lt "13" ];then
	echo "cmd \"    $j\" $i" >> "$DeFProgs"
else
	echo "cmd \"  $j\" $i" >> "$DeFProgs"
fi;done # création du menu avec entrées centrées

echo -e "cmd \"~~~~~~~~~~~\" \" \" \ncmd \" $Footer\" \" \" \nend \n menu \"~~~~~~~~~~\" \ncmd \" ~ 'Chooser' ~\" /usr/bin/defaults-chooser \nend \n cmd \" ~ ROX-Filer ~\" \"rox ~\"" >> "$DeFProgs"
}

ls -Algoh --file-type defau* | awk '$1 !~ /lrw/ && $7 !~ /.cdr/ && $7 !~ /.bak/ && $7 !~ /han/ && $7 !~ /NON/ { print $7 }' > /tmp/liste-progs

[ ! -f /tmp/compte-de-lignes ] || [ "`awk '{ print $1 }' /tmp/compte-de-lignes`" -ne "`wc -l /tmp/liste-progs | awk '{ print $1 }'`" ] && construire
# Si les décomptes de ligne ne concordent pas ou si le fichier de réf. n'existe pas,
# on reconstruit le menu. Si par contre tout est ok, l'affichage est immédiat.
# NOTA. Si vous changez quelque chose dans les "default-quelque-chose" dans
# /usr/local/bin et que le menu ne semble pas se rafraîchir, effacez le fichier
# /tmp/compte-de-lignes et relancez le script.

aemenu -rc "$DeFProgs"
# set +xe

Posted: Sun 31 May 2015, 20:42
by Puppus Dogfellow
nice.

other than trash and terminal, i think this covers all the default desktop icons in most puppies...


thanks, musher0!

sooo, how do you hack it? how can you pipe in or add custom menus? (not that it's not already really cool).


:D

Posted: Sun 31 May 2015, 21:48
by musher0
Hi, Puppus.

Thanks for the thanks!

~~~
In answer to the icons question:

Maybe not all programs, maybe not the "install" icon and "Add'l pets" icon
that some Puppies have. But it was one of my goals that this "aemenu"
bring together in a list a lot of programs usually launched through icons
on the Puppy desktop.

~~~
In answer to aemenu's usage:

aemenu uses a very simple structure:

Code: Select all

# aemenu -- menufile1 (or whatever name you wish)
menu "Name of menu" # beginning of menu
cmd "name of program" "program" # program to launch
end # end of menu
You can create the menu through a script, with "echo" lines, for example (1),
or write directly in a "menu" file structured as in the code example above.

You create the menu file, and then to call it, you type:

Code: Select all

aemenu -rc /path/menufile1
From within menu file 1, you can call another menu, say, menufile2.

Code: Select all

# aemenu file 1
cmd "Another menu" "aemenu -rc /path/menufile2"
As an extreme case, you can also use aemenu to display explanations,
something like this:

Code: Select all

cmd "This is an explanation." ""
cmd "This is another explanation." ""
You simply put nothing between the quotation marks where the program
should be. This way, you can provide the user with needed information
"on-the-fly".

This is a very simple but very powerful little program.

The only caveat I discovered over the years is that aemenu sometimes
(not always!) hangs if you use many aemenus in short succession. So
now, in my menu scripts, I routinely write:

Code: Select all

killall -q aemenu
sleep 0.1s
aemenu -rc /path/filemenuN
and it prevents the problem.

Menus are made to be used repeatedly and often, of course. I think the
kernel uses a queue for shutting down programs, and if you restart
aemenu (or indeed any program, for that matter) before the kernel has
gone to close it proprely, aemenu will be in kernel limbo and won't show.
But if you use the killall command just before calling aemenu, the
problem is prevented. Again, this will happen only if you use aemenu
many times in close succession.

I hope this answers the question?

Bye for now.

musher0

~~~~~~~~~~~~
BTW, here's a copy of aemenu.

~~~~~~~~~~~~
(1) for a splendid example of the creation of a full-blown Puppy menu
__ using aemenu, please refer to aragon's code here.

__ It's actually my remake of aragon's previous code, which was itself
__ based on work by technosaurus & al., initiated somewhere 4-5 years
__ ago in this sometimes "pigsty" of a forum!

__ (No offense intended, Flash! The moderating team is doing a great job!
__ But could the forum's search engine be updated | improved?
__ Thanks in advance.)

Posted: Sun 31 May 2015, 23:48
by Puppus Dogfellow
I hope this answers the question?
yes, thanks.

calling it mushu (musher menu) on my root one menu, and renamed it mushu to call it from gexec, etc. nifty and i'm sure i'll continue to fiddle...

:D

Posted: Sun 31 May 2015, 23:56
by musher0
Nice compliment! Thanks. TWYL.

Posted: Mon 01 Jun 2015, 02:37
by musher0
Hello again, people.

The attached screen capture comes from a VividPup 6.5 with jwm wm.
The "progs-default.sh" script is represented by the icon at top left. That
ROX icon has been linked in ROX to hot keys Crtl-Alt-M, so the defaults
aemenu (or "mushnu" to use the nickname given by Puppus! :) ) can be
displayed from wherever the cursor is on the desktop.

Using this defaults menu, you'll notice that the on-screen space of
about ten program icons was regained
on the Puppy desktop.
Nevertheless, the menu gives us access to 22 programs defined as
"defaults" in Puppy.

We seem to lose access to 10 icons. In fact, through the defaults menu,
we preserve access to those, plus we gain access to 12 more programs
that we didn't have access to before. Nice trade-off, I'd say! :)

BFN.

musher0

i have your menu/script added to an aemenu

Posted: Mon 01 Jun 2015, 04:24
by Puppus Dogfellow
hey musher, working well and i'm currently calling it (indirectly) with mm (yours was further "shortcutted" from mushu to mue):

Code: Select all

# aemenu  mushu1
menu "mushu1" # beginning of menu
cmd "cr" "cr" # program to launch
cmd "sk" "sk" # program to launch
cmd "cadi" "cadi" # program to launch
cmd "ccdi" "ccdi" # program to launch
cmd "findnrun" "fnr" # program to launch
cmd "prun" "prun" # program to launch
cmd "grun" "grun" # program to launch
cmd "gexec" "gexec" # program to launch
end # end of menu	

cmd "mue" "mue" # most other defaults

menu "mushu2" # beginning of menu
cmd "rxvt" "rxvt" 
cmd "urxvt" "urxvt" 
cmd "winswitcher" "winswitcher" 
cmd "jwm -restart" "jwm -restart" 
cmd "pcp" "pcp"
cmd "geany" "geany" 
cmd "ppm" "ppm" 
cmd "applications" "rox /usr/share/applications"
cmd "my-applications" "rox /root/my-applications/bin"
cmd "my-documents" "rox /root/my-documents"
cmd "/etc" "rox /etc"
end # end of menu	

menu "mushu3" # beginning of menu
cmd "5copies" "5copies" 
cmd "5copiesDir" "5copiesDir" 
cmd "nwp" "wp"
cmd "rox recents" "rr" 
cmd "left full" "b5" 
cmd "right full" "b10"
cmd "rox /tmp" "rox /tmp"
cmd "rox /" "rox /"
cmd "/mnt" "rox /mnt"
cmd "slocate search all" "slac"
cmd "slocate search limited" "sloc"
cmd "slocate update databases" "sluc"

end # end of menu	
launcher script:

Code: Select all

#!/bin/sh

aemenu -rc /root/mushu1	

#place in /bin, /usr/bin, /sbin, /usr/sbin, /usr/local/bin, /usr/X11R7/bin, /root/my-applications/bin, /usr/X11R7/bin/custom, or /usr/games
#name mm for convenience/musher menu
but what's the correct way to do the reverse and have the my custom menus appear on your script's menu?

Posted: Mon 01 Jun 2015, 05:38
by musher0
In your file menu, add a line such as

Code: Select all

cmd "PuppusDogfellow's Menu"  "aemenu -rc PuppusMenu"

Posted: Mon 01 Jun 2015, 05:56
by musher0
Hi, people.

This may concern you or not. There's a glitch in defaultcontact, specially for
the new Puppies that don't have seamonkey on board. If you don't and you
try to launch defaultcontact, nothing will happen. Please replace the
original file at /usr/local/bin/defaultcontact with this one.

BFN.

musher0

Re: i have your menu/script added to an aemenu

Posted: Mon 01 Jun 2015, 06:36
by Puppus Dogfellow
Puppus Dogfellow wrote:
but what's the correct way to do the reverse and have the my custom menus appear on your script's menu?
musher0 wrote:In your file menu, add a line such as

Code: Select all

cmd "PuppusDogfellow's Menu"  "aemenu -rc PuppusMenu"
adding something to my menu file is supposed to make it appear as a slot on your script/the menu your script produces? or is a file menu something different from the menu file? iirc, there's a stock file slot on jwm, but i doubt that's what you mean...

anyway, i've placed

Code: Select all


cmd "PuppusDogfellow's Menu"  "aemenu -rc /root/mushu1" 
all over the thing with no luck.

--------------------------

edit: never mind. easy solution/new menu:

Code: Select all

menu "defaults/original puppy desktop" 
cmd " audiomixer" defaultaudiomixer
cmd " audioplayer" defaultaudioplayer
cmd " browser" defaultbrowser
cmd " calendar" defaultcalendar
cmd " cdplayer" defaultcdplayer
cmd " chat" defaultchat
cmd " chmviewer" defaultchmviewer
cmd " ~ 'Chooser' ~" /usr/bin/defaults-chooser 
cmd " connect" defaultconnect
cmd "console" "urxvt"
cmd " contact" defaultcontact
cmd " draw" defaultdraw
cmd " email" defaultemail
cmd " htmleditor" defaulthtmleditor
cmd " htmlviewer" defaulthtmlviewer
cmd " imageviewer" defaultimageviewer
cmd " mediaplayer" defaultmediaplayer
cmd " notecase" notecase
cmd " paint" defaultpaint
cmd "puppy package manager" "ppm" 
cmd "puppy control panel" "pcp" 
cmd " spreadsheet" defaultspreadsheet
cmd "screen shot" "tas"
cmd " texteditor" defaulttexteditor
cmd " textviewer" defaulttextviewer
cmd " videoplayer" defaultvideoplayer
cmd " wizardwizard" wizardwizard
cmd " wordprocessor" defaultwordprocessor
cmd "Xlock setup" "/usr/local/apps/Xlock/AppRun -configure" 
cmd  "Xlock lock screen" "/usr/local/apps/Xlock/AppRun -locknow"
end 

 menu "rox"
 cmd "rox /" "rox /"
  cmd " ~ ROX-Filer ~" "rox ~"
 cmd " Close All Rox" "cr"
  cmd "  rox Recents  " "rr"
  cmd " rox Bookmarks" "rb"
  cmd "applications" "rox /usr/share/applications"  
  cmd "/etc" "rox /etc"
 cmd "/mnt" "rox /mnt"
 cmd "/mnt/home" "rox /mnt/home"
cmd "my-applications" "rox /root/my-applications/bin"
cmd "my-documents" "rox /root/my-documents"
cmd "rox /tmp" "rox /tmp"
cmd "rox /root/.Trash" "rox /root/.Trash"

end   
 
menu "launchers and consoles" # beginning of menu 
cmd "findnrun" "fnr" 
cmd "gexec" "gexec" 
cmd "grun" "grun" 
cmd "lxterminal" "lxterminal" 
 cmd "pexec" "pexec" 
cmd "prun" "prun"
cmd "roxterm" "roxterm"
cmd "rxvt" "rxvt"
cmd "sakura" "sakura" # program to launch
cmd "urxvt" "urxvt"
end # end of menu   



menu "supplemental 1" # beginning of menu
cmd "close all desktop instances" "cadi" # program to launch
cmd "close current desktop instances" "ccdi" # program to launch
cmd "partview" "partview" # program to launch
cmd "lxtask" "lxtask" # program to launch
cmd "htop" "htop" # program to launch
cmd "winswitcher" "winswitcher"
cmd "jwm -restart" "jwm -restart"
cmd "5copies" "5copies"
cmd "5copiesDir" "5copiesDir"
cmd "nwp" "wp" 
cmd "left full" "b5"
cmd "right full" "b10"
cmd "slocate search all" "slac"
cmd "slocate search limited" "sloc"
cmd "slocate update databases" "sluc"
cmd "spacefm" "spacefm"
end # end of menu   

menu "supplemental 2" # beginning of menu
cmd "chromium" "chromium"
cmd "firefox" "firefox"
cmd "galculator" "galculator"
cmd "gcolor2" "gcolor2"
cmd "gfnrename" "gfnrename"
cmd "gfontsel" "gfontsel"
cmd "goldendict" "goldendict"
cmd "google-chrome" "google-chrome"
cmd "palemoon" "palemoon"
cmd "pfind" "pfind"
cmd "recoll" "recoll"
cmd "xpad-backup" "xpad-backup"
cmd "xpad-clear" "xpad-clear"
cmd "xpad" "xpad"
end # end of menu 


#menu "supplemental 3" # beginning of menu

#end # end of menu 


#name mushu1 and place in /root to be able to launch it with the mm script below/change location in mm to reflect change in location or title of mushu1


   
#launcher with the sleep/kill suggestion from above:

Code: Select all

#!/bin/sh

#aemenu -rc /root/mushu1	
#name mm and place in /root/my-applications/bin/
killall -q aemenu
sleep 0.1s
aemenu -rc /root/mushu1	


Posted: Tue 02 Jun 2015, 07:45
by musher0
Hello, Puppus.

I mentioned above aragon's Simple Puppy Menu 2,
and I finally found it again.

His scripts are good study for anyone interested in aemenu.

The next year (2013) aragon published a Simple Puppy Menu 3,
based on mygtkmenu. He could have integrated icons, but he
didn't, so this thing's faster than hell. :)

Great programmer, aragon. I wonder what he's doing now.

BFN.

musher0

Posted: Tue 02 Jun 2015, 07:53
by musher0
Hi, Puppus.

Sorry for the late reply. I was really tired yesterday.

About your implementation of an aemenu two posts up: yep, you got it! :)
Works well. Now you know everything there is to knoiw about aemenu! ;)

BFN.

musher0

Posted: Tue 02 Jun 2015, 15:51
by musher0
Hello, all.

FWIW, the final code (for a while, anyway) is here. It doesn't change
the previous (English) layout.

It just adds a French translation, which has to have a flush-left layout [for
now, anyway; why, I don't know] instead of the centered one I had
managed to achieve in the English version. Oh well, you can't win them all,
can you?...

~~~~~~~~~
Also, this may be of note: scripts defaultvideoplayer and defaultmediaplayer
in /usr/local/bin are doubles. Remedy: make the first a link of the second.

Since the present defaults menu script doesn't pick up links -- :oops: oops, I
had forgotten to tell you that! -- you'll have only one entry for this function
in the menu, while maintaining the appearance of a "defaultvideoplayer"
script if some other Puppy program needs it.

~~~~~~~~
Finally, we found and corrected two already, but I'd be grateful if you report
here any "zibarre":) behaviour in < defaultsomething > scripts. There's
probably an easy fix.

BFN.

musher0

Posted: Tue 02 Jun 2015, 18:13
by Jasper
Hi musher0 et al,

To suit my personal preference, I made some small changes to the original script from musher0 to give:

Code: Select all

#!/bin/sh
# /usr/local/bin/progs-default.sh
# But : créer un aemenu des logiciels par défaut
# dans PuppyLinux pour le gest. de fen. aewm, echinus ou autre.
# Dépendance : aemenu
# (c) musher0, 30 mai 2015.(English only version with small changes for Jasper)
#### 
cd /usr/local/bin/
ls -Algoh --file-type defau* | awk '$1 !~ /lrw/ && $7 !~ /.cdr/ && $7 !~ /.bak/ && $7 !~ /han/ { print $7 }' > liste-progs
echo "menu \"Default apps\"" > progs-default
for i in `cat liste-progs`;do
echo "cmd ${i#*t} $i" >> progs-default
done
echo "cmd \">        chooser\" /usr/bin/defaults-chooser" >> progs-default
aemenu -rc /usr/local/bin/progs-default
rm -f liste-progs
and the resulting menu was instantaneously available and I have not encountered any of the problems reported in musher0's post immediately above.

My regards

ADDENDUM

IMPORTANTLY: my thanks to musher0 as, in a post below, he has kindly both corrected and improved my above effort.
--------------

Posted: Tue 02 Jun 2015, 18:38
by musher0
Hello, Jasper.

If it works, great! But I think there is an

Code: Select all

echo end 
missing just after the < done > line in your adapted script.

Then again, maybe I need new glasses! :(

BFN.

musher0

Posted: Tue 02 Jun 2015, 19:10
by Jasper
Hi musher0,

It would take you only seconds to try it and see how and if it works for you by displaying a single list of apps ending with the "chooser".

I'm happy and pleased.

My regards and thanks