pcur 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #!/bin/sh
  2. #(c) copyright Barry Kauler aug 2009. Licence LGPL.
  3. #120202 rodin.s: i18n
  4. #121020 fix msg where locate 'cursor_themes' pet pkg.
  5. export TEXTDOMAIN=pcur
  6. export OUTPUT_CHARSET=UTF-8
  7. CURLIST=""
  8. FIRSTITEM=""
  9. LISTHEIGHT=50
  10. PREVTHEME=""
  11. [ -e $HOME/.icons/default ] && PREVTHEME="`readlink $HOME/.icons/default | rev | cut -f 1 -d '/' | rev`"
  12. mkdir -p /tmp/xcur2png
  13. func_switch (){
  14. ln -snf "$1" $HOME/.icons/default
  15. [ "$(</etc/windowmanager)" = "jwm" ] && jwm -restart
  16. }
  17. func_download (){
  18. REPO=http://distro.ibiblio.org/puppylinux/pet_packages-noarch
  19. PKG=`grep -iE "cursor_themes" ~/.packages/Packages-puppy-noarch-official|awk -F'|' '{print $8}'`
  20. download_file ${REPO}/${PKG}
  21. [ $? -ne 0 ] && /usr/lib/gtkdialog/box_ok "pCur - $(gettext 'Cursor theme setter')" error "$(gettext 'Failed to download package')" && exit 1
  22. petget +${PKG}
  23. [ $? -ne 0 ] && /usr/lib/gtkdialog/box_ok "pCur - $(gettext 'Cursor theme setter')" error "$(gettext 'Failed to install package')" && exit 1
  24. rm $PKG
  25. /usr/lib/gtkdialog/box_ok "pCur - $(gettext 'Cursor theme setter')" complete "$(gettext 'New themes are installed. <b>Please restart pCur</b> - Cursor theme setter.')" && exit 0
  26. }
  27. export -f func_switch func_download
  28. for ONEITEM in `ls -1 $HOME/.icons | grep -v 'ROX'`; do
  29. #precaution that 'cursors' subdir exists...
  30. [ ! -d $HOME/.icons/${ONEITEM}/cursors ] && continue
  31. if [ ! -f /usr/share/icons/${ONEITEM}.png ]; then
  32. cd $HOME/.icons/${ONEITEM}/cursors
  33. xcur2png -d /tmp/xcur2png left_ptr
  34. mv -f /tmp/xcur2png/left_ptr_000.png /usr/share/icons/${ONEITEM}.png
  35. rm -f /tmp/xcur2png/left_ptr_*.png
  36. fi
  37. if [ "$ONEITEM" = "$PREVTHEME" ]; then
  38. # FIRSTITEM="<item icon=\"${ONEITEM}\">${ONEITEM} CURRENT THEME</item>"
  39. FIRSTITEM="<item icon=\"${ONEITEM}\">${ONEITEM}</item>"
  40. else
  41. CURLIST="${CURLIST}<item icon=\"${ONEITEM}\">${ONEITEM}</item>"
  42. fi
  43. LISTHEIGHT=`expr $LISTHEIGHT + 25`
  44. done
  45. [ $LISTHEIGHT -gt 550 ] && LISTHEIGHT=550
  46. CURITEMS='
  47. <tree>
  48. <label>'$(gettext 'Cursor theme')'</label>
  49. '${FIRSTITEM}'
  50. <item icon="default_left_ptr">ORIGINAL THEME</item>
  51. '${CURLIST}'
  52. <variable>CHOOSECUR</variable>
  53. <height>'${LISTHEIGHT}'</height>
  54. <action>func_switch "$CHOOSECUR"</action>
  55. </tree>'
  56. if [ "$CURLIST" = "" ]; then
  57. TXT="$(gettext "<b>No themes found.</b> Click the install button to get a nice collection of cursor themes.")"
  58. CURITEMS='
  59. <frame>
  60. <hbox homogeneous="true" space-fill="true" space-expand="true">
  61. <hbox margin="20" space-fill="false" space-expand="false">
  62. <button image-position="2">
  63. '"`/usr/lib/gtkdialog/xml_button-icon install huge`"'
  64. <label>'$(gettext 'Download and Install')'</label>
  65. <action>func_download &</action>
  66. <action type="exit">exit</action>
  67. </button>
  68. </hbox>
  69. </hbox>
  70. </frame>'
  71. elif [ "$(</etc/windowmanager)" != "jwm" ]; then
  72. TXT="<b>$(gettext 'You must restart X to use the new theme.')</b>"
  73. else
  74. TXT="$(gettext '<b>Choose your prefered mousepointer theme.</b> Themes are installed to') $HOME/.icons."
  75. fi
  76. export Pcur='
  77. <window title="Pcur - '$(gettext 'Cursor theme setter')'">
  78. <vbox space-fill="true" space-expand="true">
  79. '"`/usr/lib/gtkdialog/xml_info fixed mouse_cursor.svg 60 "$(gettext "$TXT")"`"'
  80. <vbox space-fill="true" space-expand="true">
  81. '${CURITEMS}'
  82. <hbox space-expand="false" space-fill="false">
  83. <button space-expand="false" space-fill="false">
  84. <label>'$(gettext "Apply")'</label>
  85. '"`/usr/lib/gtkdialog/xml_button-icon apply`"'
  86. <action>func_switch "$CHOOSECUR"</action>
  87. </button>
  88. <button space-expand="false" space-fill="false">
  89. <label>'$(gettext "Ok")'</label>
  90. '"`/usr/lib/gtkdialog/xml_button-icon ok`"'
  91. <action>func_switch "$CHOOSECUR"</action>
  92. <action>exit:quit</action>
  93. </button>
  94. <button space-expand="false" space-fill="false">
  95. <label>'$(gettext "Quit")'</label>
  96. '"`/usr/lib/gtkdialog/xml_button-icon quit`"'
  97. <action>exit:quit</action>
  98. </button>
  99. '"`/usr/lib/gtkdialog/xml_scalegrip`"'
  100. </hbox>
  101. </vbox>
  102. </vbox>
  103. </window>'
  104. . /usr/lib/gtkdialog/xml_info gtk #build bg_pixmap for gtk-theme
  105. RETVARS="`gtkdialog -p Pcur`"
  106. [ "$CURLIST" = "" ] && exit
  107. echo "$RETVARS"
  108. eval "${RETVARS}"
  109. [ "$EXIT" != "OK" ] && exit
  110. [ "`echo "$CHOOSECUR" | grep 'CURRENT THEME'`" != "" ] && exit #already current.
  111. if [ "$CHOOSECUR" = "ORIGINAL THEME" ]; then
  112. rm -f $HOME/.icons/default
  113. exit
  114. fi