power.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. # This script invokes the system mode in the i3 config file. Useful with acpid if
  3. # Power button is pressed.
  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 power.sh
  18. # to make it executable.
  19. # ALL THE COMMANDS IN THE SCRIPT HAVE TO BE GIVEN VIA sudo SPECIFYING DISPLAY
  20. # BECAUSE OF QUBESOS WEIRDNESS.
  21. # IN OTHER SYSTEMS EVERYTHING IS MAYBE EASIER.
  22. # Grep the system variable in the i3 config file, that defines the correspondent mode.
  23. sysname=`sudo -u Nigredo -H sh -c 'DISPLAY=:0 sudo grep "set \\$system" /home/Nigredo/.config/i3/config | tail -c +13'`
  24. # Invoke the mode in i3
  25. sudo -u Nigredo -H sh -c "DISPLAY=:0 i3-msg mode '$sysname'"