lid.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. # This script invokes the screensaver when the lid is closed,
  3. # then puts the pc to sleep.
  4. # Copyright (C) 2017 Fabrizio Romano Genovese <egonigredo@gmail.com>
  5. # This copyrighted material is made available to anyone wishing to use,
  6. # modify, copy, or redistribute it subject to the terms and conditions of
  7. # the GNU General Public License v.2, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful, but WITHOUT
  10. # ANY WARRANTY expressed or implied, including the implied warranties of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  12. # Public License for more details.
  13. # You should have received a copy of the
  14. # GNU General Public License along with this program; if not,
  15. # see <http://www.gnu.org/licenses/>
  16. # Put this file in /etc/acpi/actions/. Do not forget to give
  17. # sudo chmod +x lid.sh
  18. # to make it executable.
  19. # ALL THE COMMANDS IN THE SCRIPT HAVE TO BE GIVEN VIA su -c BECAUSE OF QUBESOS WEIRDNESS.
  20. # IN OTHER SYSTEMS EVERYTHING IS MAYBE EASIER.
  21. # Modify the username to suit yours!
  22. user=Nigredo
  23. screensaver=i3-blur
  24. # Grepping the lid status
  25. state=`grep open /proc/acpi/button/lid/*/state`
  26. # Checks if the scring is empty. If it is, executes the if
  27. if [ -z $state ]; then
  28. sudo -u $user -H sh -c "DISPLAY=:0 $screensaver"
  29. systemctl suspend
  30. fi