screenshot.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/env bash
  2. ## Author : Aditya Shakya
  3. ## Mail : adi1090x@gmail.com
  4. ## Github : @adi1090x
  5. ## Twitter : @adi1090x
  6. dir="$HOME/.config/rofi/applets/android"
  7. rofi_command="rofi -theme $dir/three.rasi"
  8. # Error msg
  9. msg() {
  10. rofi -theme "$dir/message.rasi" -e "Please install 'scrot' first."
  11. }
  12. # Options
  13. screen=""
  14. area=""
  15. window=""
  16. # Variable passed to rofi
  17. options="$screen\n$area\n$window"
  18. chosen="$(echo -e "$options" | $rofi_command -p '' -dmenu -selected-row 1)"
  19. case $chosen in
  20. $screen)
  21. if [[ -f /usr/bin/scrot ]]; then
  22. sleep 1; scrot 'Screenshot_%Y-%m-%d-%S_$wx$h.png' -e 'mv $f $$(xdg-user-dir PICTURES) ; viewnior $$(xdg-user-dir PICTURES)/$f'
  23. else
  24. msg
  25. fi
  26. ;;
  27. $area)
  28. if [[ -f /usr/bin/scrot ]]; then
  29. scrot -s 'Screenshot_%Y-%m-%d-%S_$wx$h.png' -e 'mv $f $$(xdg-user-dir PICTURES) ; viewnior $$(xdg-user-dir PICTURES)/$f'
  30. else
  31. msg
  32. fi
  33. ;;
  34. $window)
  35. if [[ -f /usr/bin/scrot ]]; then
  36. sleep 1; scrot -u 'Screenshot_%Y-%m-%d-%S_$wx$h.png' -e 'mv $f $$(xdg-user-dir PICTURES) ; viewnior $$(xdg-user-dir PICTURES)/$f'
  37. else
  38. msg
  39. fi
  40. ;;
  41. esac