mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.5 KiB

  1. #!/bin/bash
  2. dir="/tmp/dir"
  3. rm -rf ${dir}
  4. mkdir -p ${dir}
  5. tmpfile="/tmp/tmpfile"
  6. rm -rf ${tmpfile}
  7. style="freedesktop"
  8. [ "$1" == "--rock" -o -e /usr/share/icewm/rockstyle ] && style="rock"
  9. process_desktop(){
  10. file=${1}
  11. . ${file}
  12. [ -z "${Exec}" ] && return
  13. if [ "${style}" == "freedesktop" ] ; then
  14. Categories=${Categories//;//}
  15. Categories=${Categories%/}
  16. elif [ "${style}" == "rock" ] ; then
  17. Categories="`grep '\[C\]' /var/adm/descs/${X_ROCK_Name} | head -n 1 | cut -f2 -d' '`"
  18. fi
  19. mkdir -p "${dir}/${Categories}"
  20. if [ "${Terminal}" == "true" -o "${Terminal}" == "1" ] ; then
  21. Exec="xterm -bg black -fg grey -e '${Exec}'"
  22. fi
  23. echo "prog \"${Name}\" \"${Icon:-${Name}}\" ${Exec}" > "${dir}/${Categories}/${Name}"
  24. unset Exec Name Icon Terminal Categories X_ROCK_Name
  25. }
  26. for x in /usr/share/applications/*desktop ; do
  27. [ ! -e ${x} ] && continue
  28. entry=0
  29. while read line ; do
  30. [ -z "${line}" -o "${line:0:1}" == "#" ] && continue
  31. if [ "${line:0:1}" == "[" ] ; then
  32. entry=$(( ${entry} + 1 ))
  33. if [ ${entry} -gt 1 ] ; then # this is to support multiple entries in one file
  34. [ -f ${tmpfile} ] && process_desktop ${tmpfile}
  35. rm -f ${tmpfile}
  36. fi
  37. else
  38. [ "${line:0:5}" == "Exec=" ] && echo "${line}" | sed -e 's,=\(.*\)$,="\1",g' >>${tmpfile}
  39. [ "${line:0:5}" == "Name=" ] && echo "${line}" | sed -e 's,=\(.*\)$,="\1",g' >>${tmpfile}
  40. [ "${line:0:5}" == "Icon=" ] && echo "${line}" | sed -e 's,=\(.*\)$,="\1",g' >>${tmpfile}
  41. [ "${line:0:9}" == "Terminal=" ] && echo "${line}" | sed -e 's,=\(.*\)$,="\1",g' >>${tmpfile}
  42. [ "${line:0:11}" == "Categories=" ] && echo "${line}" | sed -e 's,=\(.*\)$,="\1",g' >>${tmpfile}
  43. [ "${line:0:12}" == "X-ROCK-Name=" ] && echo "${line}" | sed -e 's,=\(.*\)$,="\1",g' -e 's,^.*=,X_ROCK_Name=,g' >>${tmpfile}
  44. fi
  45. done < ${x}
  46. [ -f ${tmpfile} ] && process_desktop ${tmpfile}
  47. rm -f ${tmpfile}
  48. done
  49. scan_file() {
  50. for n in 1 `seq 1 1 ${2} 2>/dev/null` ; do
  51. echo -en "\t"
  52. done
  53. cat "${1}"
  54. }
  55. scan_dir() {
  56. for n in `seq 1 1 ${2} 2>/dev/null` ; do
  57. echo -en "\t"
  58. done
  59. echo "menu \"${1##*/}\" folder {"
  60. for x in "${1}"/* ; do
  61. if [ -d "${x}" ] ; then
  62. scan_dir "${x}" $(( ${2} + 1 ))
  63. elif [ -f "${x}" ] ; then
  64. scan_file "${x}" ${2}
  65. fi
  66. done
  67. for n in `seq 1 1 ${2} 2>/dev/null` ; do
  68. echo -en "\t"
  69. done
  70. echo "}"
  71. }
  72. rm -f /usr/share/icewm/ROCK
  73. for x in ${dir}/* ; do
  74. if [ -d "${x}" ] ; then
  75. scan_dir "${x}" 0
  76. elif [ -f "${x}" ] ; then
  77. scan_file "${x}" 0
  78. fi
  79. done >/usr/share/icewm/ROCK
  80. rm -rf ${tmpfile} ${dir}