Linux Compressor Humanizer https://lch.hatthieves.es
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.

108 lines
2.6 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. #!/usr/bin/env bash
  2. # Colors
  3. RESET="\e[0m"
  4. GREEN="\e[32m"
  5. RED="\e[91m"
  6. function help()
  7. {
  8. echo "Help:"
  9. echo "-----"
  10. echo ""
  11. echo "lch [-h] [-v] [-c] [-i] [FILE [FILE...]]"
  12. echo ""
  13. echo "Examples:"
  14. echo "$ lch -h - This help"
  15. echo "$ lch -v - Print version"
  16. echo "$ lch -c - Check compression systems"
  17. echo "$ lch -i - Install the compressors dependencies"
  18. echo "$ lch file.zip - Decompress"
  19. echo "$ lch file.zip /home/file - Compress"
  20. echo "$ lch files.zip file1 file2 - Compress multiple"
  21. echo ""
  22. echo "Packing/unpacking supported extensions:"
  23. echo " 7z, bz2, gz, rar, tar, tar.bz2, tbz, tbz2, tb2, tar.gz, tgz, tar.xz, txz, zip"
  24. echo ""
  25. echo "Unpacking only supported extensions:"
  26. echo " arj, cab, dmg, iso, lzh, lzma, rpm, squashfs, vdi, vhd, vmdk, win, xar, z"
  27. echo ""
  28. echo "Run 'man lch' for more info."
  29. echo ""
  30. }
  31. function check()
  32. {
  33. local a=false
  34. echo -e "Verification of compression systems:\n"
  35. echo -e "Systems\t\t\tStatus"
  36. echo "----------------------------------"
  37. for i in "7z" "bzip2" "gzip" "rar" "tar" "unrar" "unzip" "zip"
  38. do
  39. wheel true &
  40. WPID=$!
  41. if ! [ -x "$(command -v $i)" ]
  42. then
  43. echo -e "$i$RED\t\t\tNot Installed$RESET"
  44. a=true
  45. else
  46. echo -e "$i$GREEN\t\t\tInstalled$RESET"
  47. fi
  48. disown $WPID
  49. kill $WPID &> /dev/null
  50. done
  51. if $a
  52. then
  53. echo -e "\nIn order to use all the extensions install the packages."
  54. echo -e "Or use 'lch -i' to install all dependences"
  55. fi
  56. echo ""
  57. }
  58. function lowercase()
  59. {
  60. echo "$DEST" | tr 'A-Z' 'a-z'
  61. }
  62. function error_not_install()
  63. {
  64. echo -e "$@$RED is not installed$RESET, use 'lch -c' to check and 'lch -i' to install."
  65. exit 0
  66. }
  67. function executer()
  68. {
  69. wheel true &
  70. WPID=$!
  71. if [ -x "$(command -v $1)" ]
  72. then
  73. "$@" 1> /dev/null
  74. else
  75. error_not_install $1
  76. fi
  77. disown $WPID
  78. kill $WPID &> /dev/null
  79. }
  80. function complete_install(){
  81. echo -e "$@:$GREEN\t\t\tCompleted$RESET"
  82. }
  83. function failed_install(){
  84. echo -e "$@:$RED\t\t\tFailed$RESET"
  85. }
  86. function wheel() {
  87. sp='/-\|'
  88. while $1; do
  89. printf '%.1s\b' "$sp"
  90. sp=${sp#?}${sp%???}
  91. if [ -x "$(command -v bc)" ]
  92. then
  93. sleep $(echo "0.0001*$(grep 'cpu MHz' /proc/cpuinfo | head -n1 | awk '{print $4}')" | bc -l)s
  94. else
  95. sleep 0.2s
  96. fi
  97. done
  98. }