i3-blur 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/bash
  2. # This is a simple program that blurs the current screen and uses it as
  3. # a screensaver. scrot and i3lock have to be installed in order to make it
  4. # work.
  5. # i3-blur - A simple i3lock addon for a blurred screensaver
  6. # Copyright (C) 2017 Fabrizio Romano Genovese <egonigredo@gmail.com>
  7. # This copyrighted material is made available to anyone wishing to use,
  8. # modify, copy, or redistribute it subject to the terms and conditions of
  9. # the GNU General Public License v.2, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful, but WITHOUT
  12. # ANY WARRANTY expressed or implied, including the implied warranties of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  14. # Public License for more details.
  15. # You should have received a copy of the
  16. # GNU General Public License along with this program; if not,
  17. # see <http://www.gnu.org/licenses/>
  18. # Put this file in /bin/ or in /usr/bin. Do not forget to give
  19. # sudo chmod +x i3-blur
  20. # to make it executable.
  21. version=1.0
  22. if [[ "$#" -ge 2 ]]; then
  23. echo "Usage: $0 {-v, --version | -h --help}"
  24. exit 0
  25. elif [[ "$#" -eq 1 ]]; then
  26. case $1 in
  27. -v | --version)
  28. echo "$0 - Version $version"
  29. exit 0;;
  30. -h | --help)
  31. echo "This is a simple program that blurs the current screen and uses it as a screensaver. scrot and i3lock have to be installed in order to make it work."
  32. echo "- v, --version Display current version"
  33. echo "-h, --help Display this message"
  34. exit 0;;
  35. *)
  36. echo "Usage: $0 {-v, --version | -h, --help}"
  37. exit 2;;
  38. esac
  39. fi
  40. # Check if scrot and i3lock are installed
  41. if [ -f /bin/scrot -a -f /bin/i3lock ]; then
  42. # Take a screenshot
  43. scrot /tmp/screenshot.png
  44. # Blur it
  45. convert /tmp/screenshot.png -blur 0x5 /tmp/screenshotblur.png
  46. # Invoke the i3lock screensaver using it as a background
  47. i3lock -f -i /tmp/screenshotblur.png
  48. else
  49. # Abort if they are not
  50. echo "i3lock and/or scrot are not installed. Please install them."
  51. exit 2
  52. fi