screenshot.sh 1.2 KB

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