install.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/sh
  2. # Installs LYNX SHARE for the current user (no root): the program in ~/.local/opt/LYNX, a launcher in ~/.local/bin,
  3. # the menu entry, the icon and the .lynx file type. Run it again to update; ./install.sh --uninstall removes it.
  4. set -e
  5. here="$(cd "$(dirname "$0")" && pwd)"
  6. data="${XDG_DATA_HOME:-$HOME/.local/share}"
  7. opt="$HOME/.local/opt/LYNX"
  8. bin="$HOME/.local/bin"
  9. if [ "$1" = "--uninstall" ]; then
  10. rm -rf "$opt" "$bin/LYNX" "$data/applications/lynx.desktop" "$data/mime/packages/lynx-mime.xml"
  11. for s in 16 24 32 48 64 128 256 512; do rm -f "$data/icons/hicolor/${s}x${s}/apps/lynx.png"; done
  12. command -v update-mime-database > /dev/null && update-mime-database "$data/mime" || true
  13. command -v update-desktop-database > /dev/null && update-desktop-database "$data/applications" || true
  14. echo "LYNX SHARE removed (your settings stay in ${XDG_CONFIG_HOME:-$HOME/.config}/LYNX)."
  15. exit 0
  16. fi
  17. mkdir -p "$opt" "$bin" "$data/applications" "$data/icons/hicolor/256x256/apps" "$data/mime/packages"
  18. cp -r "$here"/. "$opt"/
  19. ln -sf "$opt/LYNX" "$bin/LYNX"
  20. sed "s|^Exec=.*|Exec=\"$opt/LYNX\" %F|" "$here/lynx.desktop" > "$data/applications/lynx.desktop"
  21. if [ -d "$here/icons/hicolor" ]; then
  22. for s in 16 24 32 48 64 128 256 512; do
  23. [ -f "$here/icons/hicolor/${s}x${s}/apps/lynx.png" ] || continue
  24. mkdir -p "$data/icons/hicolor/${s}x${s}/apps"
  25. cp "$here/icons/hicolor/${s}x${s}/apps/lynx.png" "$data/icons/hicolor/${s}x${s}/apps/lynx.png"
  26. done
  27. else
  28. cp "$here/lynx.png" "$data/icons/hicolor/256x256/apps/lynx.png"
  29. fi
  30. cp "$here/lynx-mime.xml" "$data/mime/packages/lynx-mime.xml"
  31. command -v update-mime-database > /dev/null && update-mime-database "$data/mime" || true
  32. command -v update-desktop-database > /dev/null && update-desktop-database "$data/applications" || true
  33. command -v gtk-update-icon-cache > /dev/null && gtk-update-icon-cache -q "$data/icons/hicolor" 2> /dev/null || true
  34. echo "LYNX SHARE installed: start it from the applications menu or run $bin/LYNX"