gonoticia 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/bash
  2. #------------HEADER---------------------------------------------------------------------|
  3. #DESCRIÇÃO
  4. # Programa que puxa noticias atráves do google noticias.
  5. # Necessita de algum browser gráfico instalado e o links.
  6. #
  7. #AUTOR:
  8. # Jefferson rocha <lrcjefferson@gmail.com>
  9. #
  10. #---------------------------------------------------------------------------------------|
  11. #---------(VÁRIAVEIS)
  12. LINK="links -dump https://news.google.com/news/local?hl=pt-br&gl=BR&ned=pt-br_br"
  13. OPEN=""
  14. BROWSERS=("google-chrome" "google-chrome-stable" "firefox" "vivaldi")
  15. UTIL=$(which links 2>/dev/null)
  16. TYPE_SHELL=$(echo "$SHELL")
  17. #---------(TESTES INICIAIS)
  18. [[ "$TYPE_SHELL" == "/usr/bin/fish" ]] || [[ "$TYPE_SHELL" == "/bin/fish" ]] && {
  19. echo -e "\033[32;1mVocê está utilizando o fish :( ,utilize o bash e volte.\033[m"
  20. exit 1
  21. }
  22. [[ "$UTIL" ]] || { # links existe no sistema?
  23. echo -e "\033[31;1mOpa! instale o links para continuar\033[m"
  24. exit 1
  25. }
  26. for i in ${BROWSERS[@]}; do # Vamos verificar se tem um dos navegadores.
  27. which "$i" >/dev/null 2>/dev/null
  28. if [[ $? == 0 ]]; then
  29. OPEN="$i"
  30. break
  31. fi
  32. done
  33. #========* Passado os testes agora vai! *=========#
  34. echo -e "\033[31;4;1mPuxando informações.\033[m"
  35. # Baixando página do google noticias
  36. $LINK > ~/google.txt
  37. # Fazendo conversão e arrumando texto
  38. tail -n +53 ~/google.txt | sed 's//------------------\n/ ; s/&#xE80D;/------------------\n/' | head -n 120 > ~/google-tail.txt
  39. # Removendo google.txt
  40. rm ~/google.txt && mv ~/google-tail.txt ~/noticia.txt
  41. # Executando leafpad, para ler noticia
  42. $OPEN ~/noticia.txt >/dev/null 2>/dev/null