File: importasmenu

package info (click to toggle)
afterstep 2.2.12-18.1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 33,184 kB
  • sloc: ansic: 201,695; sh: 5,894; xml: 3,721; makefile: 2,094; perl: 1,558; cpp: 811
file content (65 lines) | stat: -rw-r--r-- 1,444 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash

if [[ "X$1" = "X" || "X$2" = "X" ]]; then
    echo "Usage: importasmenu <foreignmenudir> <targetasmenudir>";
    exit;
fi

curpwd=$PWD
targetdir=$2

#rm -fr $2

if [ ! -e $2 ]; then
    if ! mkdir $2; then exit; fi
fi

cd $1

for d in `find . -maxdepth 1 -type d` ; do
    if [[ "X$d" != "X.." && "X$d" != "X." ]] ; then 
	importasmenu $d $2/$d
    fi
done;

# processing KDE entries

for f in `find . -maxdepth 1 -type f -name "*.kdelnk"` ; do

    name=`grep -w "Name" < $f| head -n 1 | cut -c '6-'`
#	name="aaaa"
    if [ "X$name" == "X" ]; then name=$f ; fi
    echo "$name"  
    if grep "Exec=" < $f > /dev/null ; then
		cmd=`grep "Exec=" < $f | head -n 1 | grep -v Swallow | cut -c '6-'`
		if echo $cmd | grep "%" > /dev/null ; then
			echo "skipping $cmd"
		else
			echo "Exec \"$name\" exec " $cmd "&" >"$2/$f"
			echo "Exec \"$name\" exec " $cmd "&"
		fi
    fi
done;

#now processing GNOME entries

for f in `find . -maxdepth 1 -type f -name "*.desktop"` ; do

    name=`grep -w "Name" < $f | head -n 1 | cut -c '6-'`
#	name="aaa"
    if [ "X$name" == "X" ]; then name=$f ; fi
    echo "$name"  
    if grep "Exec=" < $f > /dev/null ; then
		cmd=`grep "Exec=" < $f | head -n 1 | grep -v Swallow | grep -v Try |cut -c '6-'`
		if echo $cmd | grep "%" > /dev/null ; then
			echo "skipping $cmd"
		else
			echo "Exec \"$name\" exec " $cmd "&" >"$2/$f"
			echo "Exec \"$name\" exec " $cmd "&"
		fi
    fi
done;


cd $curpwd