Added logging to i3exit.bash.
This commit is contained in:
@@ -2,32 +2,53 @@
|
|||||||
|
|
||||||
### From http://www.archlinux.org/index.php/i3
|
### From http://www.archlinux.org/index.php/i3
|
||||||
|
|
||||||
lock() {
|
LOGFILE="$HOME/.i3/logs/i3exit.log"
|
||||||
|
LOGFILE_MAXSIZE=100000
|
||||||
|
|
||||||
|
[[ $(stat -c%s "$LOGFILE") -gt $LOGFILE_MAXSIZE ]] && >$LOGFILE
|
||||||
|
|
||||||
|
log()
|
||||||
|
{
|
||||||
|
echo "$(date "+%Y-%m-%d %H:%M:%S") $1" >> "$LOGFILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
lock()
|
||||||
|
{
|
||||||
i3lock --image="$HOME/.i3/data/lockscreen.png"
|
i3lock --image="$HOME/.i3/data/lockscreen.png"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log "[I] Received signal \"$1\"."
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
lock)
|
lock)
|
||||||
|
log "[I] Locking session."
|
||||||
lock
|
lock
|
||||||
;;
|
;;
|
||||||
logout)
|
logout)
|
||||||
|
log "[I] Exiting i3."
|
||||||
i3-msg exit
|
i3-msg exit
|
||||||
;;
|
;;
|
||||||
suspend)
|
suspend)
|
||||||
|
log "[I] Suspending."
|
||||||
lock && systemctl suspend
|
lock && systemctl suspend
|
||||||
;;
|
;;
|
||||||
hibernate)
|
hibernate)
|
||||||
|
log "[I] Hibernating."
|
||||||
lock && systemctl hibernate
|
lock && systemctl hibernate
|
||||||
;;
|
;;
|
||||||
reboot)
|
reboot)
|
||||||
|
log "[I] Rebooting."
|
||||||
systemctl reboot
|
systemctl reboot
|
||||||
;;
|
;;
|
||||||
shutdown)
|
shutdown)
|
||||||
|
log "[I] Shutting down."
|
||||||
systemctl poweroff
|
systemctl poweroff
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}"
|
echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}"
|
||||||
|
log "[E] Signal \"$1\" unknown. Aborting."
|
||||||
exit 2
|
exit 2
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
log "[I] Done."
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user