#!/bin/bash # This script invokes the system mode in the i3 config file. Useful with acpid if # Power button is pressed. # Copyright (C) 2017 Fabrizio Romano Genovese # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions of # the GNU General Public License v.2, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY expressed or implied, including the implied warranties of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # You should have received a copy of the # GNU General Public License along with this program; if not, # see # Put this file in /etc/acpi/actions/. Do not forget to give # sudo chmod +x power.sh # to make it executable. # ALL THE COMMANDS IN THE SCRIPT HAVE TO BE GIVEN VIA sudo SPECIFYING DISPLAY # BECAUSE OF QUBESOS WEIRDNESS. # IN OTHER SYSTEMS EVERYTHING IS MAYBE EASIER. # Grep the system variable in the i3 config file, that defines the correspondent mode. sysname=`sudo -u Nigredo -H sh -c 'DISPLAY=:0 sudo grep "set \\$system" /home/Nigredo/.config/i3/config | tail -c +13'` # Invoke the mode in i3 sudo -u Nigredo -H sh -c "DISPLAY=:0 i3-msg mode '$sysname'"