summarylogtreecommitdiffstats
path: root/xlunch-create-entry
blob: 178bc31e15556dca3e7b57c3c797ee8c754cca23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

APPS=/usr/share/applications
ICONS=/usr/share/icons/hicolor
SIZE=48

echo $1 | fgrep .desktop | while read DESKTOPFILE; do
   NAME="$(cat $DESKTOPFILE | egrep -i "^Name=" | head -n 1 | cut -d "=" -f 2-)"
   EXEC="$(cat $DESKTOPFILE | egrep -i "^Exec=" | head -n 1 | cut -d "=" -f 2-)"
   ICON="$(cat $DESKTOPFILE | egrep -i "^Icon=" | head -n 1 | cut -d "=" -f 2-)"
   TERM="$(cat $DESKTOPFILE | egrep -i "^Terminal=" | head -n 1 | cut -d "=" -f 2-)"

   if [ "$TERM" = "true" ]; then
      EXEC="xterm -e ""$EXEC"
   fi

   if [ "$ICON" != "" ]; then
      ICON=$(find "$ICONS" | grep $SIZE"x"$SIZE | grep $ICON"[.]png" | head -n 1)
      if [ "$ICON" != "" -a "$EXEC" != "" -a "$NAME" != "" ]; then
         echo "$NAME;$ICON;$EXEC"
      fi
   fi
done | sort | uniq