slitaz-tools rev 868

Add jwm-menu generator using XDG desktop files
author Christophe Lincoln <pankso@slitaz.org>
date Wed Apr 30 15:51:23 2014 +0200 (2014-04-30)
parents 828bfb6a1f94
children 95727d7587e7
files jwm/README jwm/jwm-menu
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/jwm/README	Wed Apr 30 15:51:23 2014 +0200
     1.3 @@ -0,0 +1,11 @@
     1.4 +JWM menu generator
     1.5 +================================================================================
     1.6 +
     1.7 +
     1.8 +Developped for the needs of SliTaz Raspberry Pi distribution. JWM is faster and
     1.9 +use less resources than Openbox. And Ob also need a panel, JWM provide a nice
    1.10 +built-in panel. To generate jwm-menus use XDG standard .desktop file locatedin
    1.11 +the folder: /usr/share/applications
    1.12 +
    1.13 +
    1.14 +================================================================================
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/jwm/jwm-menu	Wed Apr 30 15:51:23 2014 +0200
     2.3 @@ -0,0 +1,100 @@
     2.4 +#!/bin/sh
     2.5 +#
     2.6 +# JWM Menus generator
     2.7 +# (C) 2014 SliTaz GNU/Linux - BSD Licence
     2.8 +#
     2.9 +
    2.10 +menus="/etc/xdg/jwm/menus.jwmrc"
    2.11 +apps="/usr/share/applications"
    2.12 +
    2.13 +categories() {
    2.14 +	cat << EOT
    2.15 +Accessories
    2.16 +Internet
    2.17 +Graphics
    2.18 +Multimedia
    2.19 +Games
    2.20 +Development
    2.21 +Documentation
    2.22 +System
    2.23 +EOT
    2.24 +}
    2.25 +
    2.26 +header() {
    2.27 +	cat > ${menus} << EOT
    2.28 +<?xml version="1.0"?>
    2.29 +<JWM>
    2.30 +	<!-- Applications menu -->
    2.31 +	<RootMenu height="22" onroot="12">
    2.32 +EOT
    2.33 +}
    2.34 +
    2.35 +footer() {
    2.36 +	cat >> ${menus} << EOT
    2.37 +	<!-- System menus -->
    2.38 +	<RootMenu height="22" onroot="3">
    2.39 +		<Program icon="terminal.png" label="Terminal Emulator">terminal</Program>
    2.40 +		<Program icon="file-manager.png" label="File Manager">file-manager</Program>
    2.41 +		<Separator/>
    2.42 +		<Restart label="Restart JWM" icon="system-restart.png" />
    2.43 +		<Exit label="Exit JWM" confirm="true" icon="system-suspend.png" />
    2.44 +		<Program icon="system-restart.png" label="Reboot system">reboot</Program>
    2.45 +		<Program icon="system-shut-down.png" label="Shutdown system">poweroff</Program>
    2.46 +	</RootMenu>
    2.47 +</JWM>
    2.48 +EOT
    2.49 +}	
    2.50 +
    2.51 +header
    2.52 +for cat in $(categories)
    2.53 +do
    2.54 +	case "$cat" in
    2.55 +		Accessories)
    2.56 +			icon="applications-accessories.png" 
    2.57 +			name="Utility" not="System" ;;
    2.58 +		Internet) 
    2.59 +			icon="applications-internet.png"
    2.60 +			name="Network" ;;
    2.61 +		Graphics) 
    2.62 +			icon="applications-graphics.png"
    2.63 +			name="$cat" ;;
    2.64 +		Multimedia)
    2.65 +			icon="applications-multimedia.png"
    2.66 +			name="AudioVideo" not="Utility" ;;
    2.67 +		Games) 
    2.68 +			icon="applications-games.png"
    2.69 +			name="Game" ;;
    2.70 +		Development) 
    2.71 +			icon="applications-development.png"
    2.72 +			name="$cat" ;;
    2.73 +		Documentation)
    2.74 +			icon="text-x-generic.png"
    2.75 +			name="$cat" ;;
    2.76 +		System)
    2.77 +			cat="System Tools"
    2.78 +			icon="applications-system.png"
    2.79 +			name="System" ;;
    2.80 +	esac
    2.81 +	echo "	<Menu icon=\"$icon\" label=\"$cat\">" >> ${menus}
    2.82 +	# Parse *.desktop files
    2.83 +	for app in $(fgrep -l "${name}" $apps/*.desktop)
    2.84 +	do
    2.85 +		# Skipp OnlyShowIn
    2.86 +		if fgrep -q 'OnlyShowIn=' ${app}; then
    2.87 +			continue
    2.88 +		fi
    2.89 +		# Skip not show in category
    2.90 +		if fgrep -q "$not" ${app}; then
    2.91 +			continue
    2.92 +		fi
    2.93 +		name="$(grep '^Name=' $app | cut -d '=' -f 2)"
    2.94 +		icon="$(grep '^Icon=' $app | cut -d '=' -f 2)"
    2.95 +		exec="$(grep '^Exec=' $app | cut -d '=' -f 2)"
    2.96 +		echo "		<Program icon=\"$icon\" label=\"$name\">$exec</Program>" \
    2.97 +			>> ${menus}
    2.98 +		unset name icon exec
    2.99 +	done
   2.100 +	echo '	</Menu>' >> ${menus}
   2.101 +done
   2.102 +footer
   2.103 +exit 0