SimplePuppyMenu2 (spm2)

Window managers, icon programs, widgets, etc.
Locked
Message
Author
aragon
Posts: 1698
Joined: Mon 15 Oct 2007, 12:18
Location: Germany

SimplePuppyMenu2 (spm2)

#1 Post by aragon »

SimplePuppyMenu2 (spm2) is a menu system for 'menuless' wm like echinus. The menu is similar to the jwm-menu, but no icons and no differentiated subcategories. the menu itself is run via aemenu.

spm2 is the successor of spm (see here: http://www.murga-linux.com/puppy/viewtopic.php?t=51138).
spm2 consists of only one ash-script to parse the desktop-files and generate the menu-file, thus no perl-dependency any more.

It is based on the famous jwm-tools by technosaurus (many thanks). See here for more details: http://www.murga-linux.com/puppy/viewtopic.php?t=70804

To make use of spm2, you should assign a keyboard-shortcut to 'spm2 -m'. how to do that depends on your wm.

If you want automatically recreate on every startup, make a script with 'spm2 -c &' in /root/Startup.

Update Menu and help for spm2 could also be reached from the menu itself.

Some Notes:
- spm2 checks only the first category of the desktop-file.
- spm2 will use the text in your $LANG if available in the desktop-file.

Dependency is aemenu (attached).

Changelog:
0.3:
- Added support for /usr/local/share/applications
- Added support for user-entries at top/bottom of the menu

Tested in Puppy 4.31.

aragon
Attachments
spm2-0.3.pet
(3.26 KiB) Downloaded 792 times
aemenu-1.2.12.pet
(7.91 KiB) Downloaded 785 times
spm2-0.2.pet
OLD VERSION
(3.04 KiB) Downloaded 767 times
Last edited by aragon on Wed 08 Feb 2012, 21:24, edited 1 time in total.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#2 Post by musher0 »

Hello, aragon.

Glad that you could find some time to produce this second edition.
I'll check it out pronto.

When you say:
> - spm2 checks only the first category of the desktop-file.

do you mean that your utility it checks only
/usr/share/applications/*.desktop ?

Not

/usr/local/share/applications/*.desktop

and not

/root/.local/share/applications ?

TWYL.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#3 Post by musher0 »

Hm...

> [/mnt/sdb6/lo....2/usr/bin]> spm2 -c
> Failure: You need to use one and only one option
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

aragon
Posts: 1698
Joined: Mon 15 Oct 2007, 12:18
Location: Germany

#4 Post by aragon »

hi christian,

> do you mean that your utility it checks only /usr/share/applications/*.desktop ?

no that was not meant (although it's correct). I wanted to say, that it only checks the first category-entry inside of a desktop-file.

> [/mnt/sdb6/lo....2/usr/bin]> spm2 -c
> Failure: You need to use one and only one option

interesting... this is a failure-message of spm, not spm2??? could you please rename /usr/local/bin/spm to spm.BAK and try it again?

tia
aragon

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#5 Post by musher0 »

Hello, aragon.

Finally got it to work. But what a strange place to store the resulting menu file : /tmp/spmaerc ? :) It will get clobbered at each shutdown!

In any case, the important thing is that users of small wm's (echinus, oroborus, wmx, etc.) that do not have a decent menu by default now have something to work with and optionally flesh out.

Thanks much for your trouble.
TWYL.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#6 Post by musher0 »

Afterthought: maybe provide an hyperlink to the previous spm thread? It contained info on how to flesh out the resulting file, add a top and a bottom, etc.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

aragon
Posts: 1698
Joined: Mon 15 Oct 2007, 12:18
Location: Germany

#7 Post by aragon »

Hi christian,

The strange place for the rc is intended. It's the simplest mechanism to be sure to have an up-to-date menu on every boot. As the parsing is very fast no one will notice the short delay.

I will reintegrate top/bottom. Atm there is 'only' favorites for individual items.

Aragon

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#8 Post by musher0 »

Hello, aragon.

I found a way to integrate all the *.desktop files into one aemenu.
jwm-menu-create has the same problem. The solution is:

With simple additions at the top and the bottom of your file, we can create a /tmp/applications dir and send all the *.desktop files to it, then use the spm2 process in that directory. The result is more complete, since some applications store their *.desktop files in /usr/local/share/applications. When all is finished, we remove the files and the temporary directory.

This will do for the time being. There is another depot of *.desktop files, at /root/.local/share/applications/wine/babebibobu :-) , that is created by wine. But another strategy would be needed to incorporate those, because wine processes them differently than linux.

So here the modification in plain bash format for your review. I called it spm2-mod1 and did a few changes for the recall of the program to that effect (when you ask if spm2 should recrreate the menu).

Tell me what you think? Have a great day!

Code: Select all

#!/bin/ash
##############################################################################
# spm2 - Simple Puppy Menu 2 (aemenu)
# spm2 is a simplified xdg-menu for puppylinux to use with aemenu.
#  
# It uses 
# a) a parser based on jwm_menu_create by technosaurus (thanks a lot) 
#    for jwm on puppylinux (based on version: jwm-tools 0.8)
#    Original thread: http://www.murga-linux.com/puppy/viewtopic.php?t=70804
# b) aemenu to display (and execute) the menu
# 
# Changelog:
# spm2 0.1: initial release
#      0.2: bring back code for intl. text from jwm_menu_create
# 
# aragon, 2012/02/06
##############################################################################
# ajout par musher0
# incorporer /usr/share/applications/*.desktop et /usr/local/share/applications/*.desktop
#
mkdir /tmp/applications
sleep 0.5s
cp /usr/local/share/applications/*.desktop /tmp/applications
sleep 0.5s
cp /usr/share/applications/*.desktop /tmp/applications
sleep 0.5s
##

# variables
spm2aeversion="spm2 0.2, 2012.02.06"
spm2aerc="/tmp/spmaerc"
spm2aefav="`cat /root/.config/spm2/favorites`"

{	#localization block
[ $myLANG ] || myLANG=${LANGUAGE%% *}
[ $myLANG ] || myLANG=${LANG%_*}
}

# Create the menu
spm2aecreate() {
{	#parse .desktop files and sort generated menu entries into subcategories
for DESKTOP_FILE in /tmp/applications/*.desktop ; do
	CATS="" NAME="" EXEC="" LINE="" #prevent carryover from previous file
	while read LINE || [ "$LINE" ]; do
		case $LINE in
			Name=*|Name?${myLANG%_*}?=*) NAME="${LINE#*=}"'' ;; # sc0ttman... should use "Name[$myLANG]=" if found
			#Name=*) NAME="${LINE#*=}"'' ;; # aragon: only main language
			Categories=*) CATS="${LINE#*=}"''
			CAT="${CATS/;*/}"'' ;; #strip all but first cat
			Exec=*) EXEC="${LINE#*=}"''
			EXEC="${EXEC//\"/'}"'' ;; #convert " to '
		esac
	done < $DESKTOP_FILE	

	[ "${EXEC}" ] && MenuEntry='cmd "'${NAME}'" "'${EXEC}'"
		'
	case "$CAT" in
		X-Desktop|DesktopSettings|Screensaver|Accessibility|X-DesktopCountry|X-DesktopApplets)Desktop=${Desktop}${MenuEntry};;
		System|Monitor|Security|HardwareSettings|Core|X-SystemMemory|X-SystemSchedule)System=${System}${MenuEntry};;
		X-SetupEntry|PackageManager|X-SetupWizard|X-SetupUtility)Setup=${Setup}${MenuEntry};;
		Utility|Viewer|Development|Building|Debugger|IDE|Profiling|Translation|GUIDesigner|Archiving|TerminalEmulator|Shell)Utility=${Utility}${MenuEntry};; #sc0ttman utility typo
		FileSystem|FileManager|X-FilesystemMount|X-FilesystemUtility|X-FilesystemFind)Filesystem=${Filesystem}${MenuEntry};;
		2DGraphics|3DGraphics|Photography|Presentation|Chart|FlowChart|VectorGraphics|RasterGraphics|X-GraphicUtility)Graphic=${Graphic}${MenuEntry};;
		X-Document|WordProcessor|WebDevelopment|TextEditor|X-DocumentUtility|Dictionary)Document=${Document}${MenuEntry};;
		X-Calculate|Finance|Spreadsheet|ProjectManagement|Calculator|X-CalculateUtility)Business=${Business}${MenuEntry};;
		X-Personal|Calendar|ContactManagement|X-PersonalUtility)Personal=${Personal}${MenuEntry};;
		Dialup|Network|HamRadio|RemoteAccess)Network=${Network}${MenuEntry};;
		X-Internet|WebBrowser|Email|News|InstantMessaging|Telephony|IRCClient|FileTransfer|P2P)Internet=${Internet}${MenuEntry};;
		AudioVideo|Video|Player|AudioVideoEditing|Recorder|Music|Audio|Midi|Mixer|Sequencer|Tuner|Video|TV|DiskBurning)Multimedia=${Multimedia}${MenuEntry};;
		Game|Amusement|ActionGame|AdventureGame|ArcadeGame|BlocksGame|BoardGame|CardGame|KidsGame|LogicGame|RolePlaying|Simulation|SportsGame|StrategyGame)Fun=${Fun}${MenuEntry};;
		*)Other=${Other}${MenuEntry};;
	esac
done
}

{	#Now generate the full menu with some formatting
MENU='
menu "Desktop"
	'${Desktop}'
end
menu "System"
	'${System}'
end
menu "Setup"
	'${Setup}'
end
menu "Utility"
	'${Utility}'
end
menu "Filesystem"
	'${Filesystem}'
end
menu "Graphic"
	'${Graphic}'
end
menu "Document"
	'${Document}'
end
menu "Business"
	'${Business}'
end
menu "Personal"
	'${Personal}'
end
menu "Network"
	'${Network}'
end
menu "Internet"
	'${Internet}'
end
menu "Multimedia"
	'${Multimedia}'
end
menu "Fun"
	'${Fun}'
end
menu "Other"
	'${Other}'
end
'
}

{	#Add the 'puppy'-footer to the Menu
MENU='
'"$MENU"'
	cmd "Help" "defaulthtmlviewer file:///usr/share/doc/index.html"
menu "spm2"
	cmd "Recreate menu" "spm2-mod1 -c &"
	cmd	"Help" "spm2-mod1 -h | xmessage -center -file -"
end
menu "Favorites"
'"$spm2aefav"'
end
menu "Shutdown"
	cmd "Exit to prompt" "wmexit"
	cmd "Reboot" "wmreboot"
	cmd "Power off" "wmpoweroff"
	cmd "Restart X" "restartwm"
end
'
}

echo "$MENU" 1> ${spm2aerc} 2> /dev/null
}

# display the help message in terminal
spm2aehelp() {
echo "----------------------------------------
spm2 - SimplePuppyMenu 2 (aemenu)
----------------------------------------
Info: Creates and displays a simplified xdg-menu using aemenu.

Syntax: spm2-mod1 [option]

Options:
-c Create the menu-file
-m Display the menu
-v Display version info
-h Display help

Usage: To use spm2-mod1, assign a keyboard-shortcut to 'spm2-mod1 -m'. How this is done 
depends on your windowmanager. The menu will be created on first run 
(it will be written to /tmp, so it will be rebuild on every systemstart). 
You can also recreate the menu with the so-named menu-option.

To include your own 'Favorites', create the file /root/.config/spm2/favorites 
and add your favorites. A sample file could be found at /usr/share/doc/spm2

Note: spm2 only uses the first category-entry of a desktop-file.

Version: ${spm2aeversion}
----------------------------------------"
exit 0
}

# run spm2
spm2run(){
if [ ! -f ${spm2aerc} ]
	then
	spm2aecreate
fi
aemenu -rc ${spm2aerc} &
exit 0
}

# test for aemenu
if  [ ! `which aemenu` ]
	then
	xmessage -center "Aemenu seems not to be installed, aborting!" &
	exit 1
fi

# run spm2-aemenu
case $1 in
	-c|--create) spm2aecreate &;;
	-m|--menu) spm2run &;;
	-v|--version) echo ${spm2aeversion};;
	-h|--help) spm2aehelp;;
	*) xmessage -center "Missing or wrong option! Use spm2 -h to display the help!" & exit 1;;
esac
# ajout par musher0
sleep 2s
rm /tmp/applications/*.desktop
sleep 0.2s
rmdir /tmp/applications
##
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#9 Post by musher0 »

Hello, again, aragon.

To come back to the *.desktop files created by wine, they fail to launch the intended program every time. This is no joke, but it's laughable! :)

So either the user creates valid scripts for those programs (a lot of work), or we can simply put an entry for the PortableApps utility in the "favorites". The latter is simpler. Just a thought.

TWYL.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

aragon
Posts: 1698
Joined: Mon 15 Oct 2007, 12:18
Location: Germany

#10 Post by aragon »

uploaded version 0.3 to main post.

aragon

User avatar
darkcity
Posts: 2534
Joined: Sun 23 May 2010, 19:16
Location: near here
Contact:

#11 Post by darkcity »

on puppy 5.29 I get-

aemenu not installed

do i did a particular window manager?

User avatar
harii4
Posts: 448
Joined: Fri 30 Jan 2009, 04:08
Location: La Porte City, IA , U.S.A.
Contact:

#12 Post by harii4 »

do i did a particular window manager?
you just need to install the aemenu DotPet too :)

Very nice app. 8)
3.01 Fat Free / Fire Hydrant featherweight/ TXZ_pup / 431JP2012
----------------------------------------------------------------------------------------
Peace and Justice are two sides of the same coin.

aragon
Posts: 1698
Joined: Mon 15 Oct 2007, 12:18
Location: Germany

#13 Post by aragon »

See

http://www.murga-linux.com/puppy/viewtopic.php?p=682395

for spm3, which uses mygtkmenu instead of aemenu.

cheers
aragon

Locked