Clean up i3exit script.
This commit is contained in:
@@ -2,51 +2,38 @@
|
|||||||
|
|
||||||
### From http://www.archlinux.org/index.php/i3
|
### From http://www.archlinux.org/index.php/i3
|
||||||
|
|
||||||
LOGFILE="$LOGDIR/i3/i3exit.log"
|
_logfile="$LOGDIR/i3/i3exit.log"
|
||||||
LOGFILE_MAXSIZE=100000
|
|
||||||
|
|
||||||
FALLBACK_COLOR=000000
|
_fallback_color=000000
|
||||||
|
|
||||||
touch "$LOGFILE"
|
touch "$_logfile"
|
||||||
[[ $(stat -c%s "$LOGFILE") -gt $LOGFILE_MAXSIZE ]] && >$LOGFILE
|
|
||||||
|
|
||||||
log()
|
log()
|
||||||
{
|
{
|
||||||
echo "$1"
|
echo "$*"
|
||||||
echo "[$(date +%FT%T)] $1" >> "$LOGFILE"
|
echo "[$(date +%FT%T)] $*" >> "$_logfile"
|
||||||
}
|
}
|
||||||
|
|
||||||
lock()
|
lock()
|
||||||
{
|
{
|
||||||
resolution=$(xrandr | grep '*' | awk '{ print $1 }' | head -n1)
|
if [[ "$LOCKSCREEN" ]] ; then
|
||||||
log "[I] Resolution found: \"$resolution\""
|
i3lock --show-failed-attempts --image "$LOCKSCREEN"
|
||||||
lockscreen="$HOME/.i3/data/lockscreen/$resolution.png"
|
|
||||||
log "[I] Looking for lockscreen at \"$lockscreen\""
|
|
||||||
if [[ -f "$lockscreen" ]] ; then
|
|
||||||
log "[I] Lockscreen found, will be used as background image."
|
|
||||||
background_options="--image $lockscreen -t"
|
|
||||||
else
|
else
|
||||||
log "[W] Lockscreen not found, using color #$FALLBACK_COLOR as background."
|
i3lock --show-failed-attempts --color "$_fallback_color"
|
||||||
background_options="--color $FALLBACK_COLOR"
|
|
||||||
fi
|
fi
|
||||||
i3lock $background_options #-p win --image "$HOME/pictures/windows-lockscreen.jpg"
|
|
||||||
retval=$?
|
|
||||||
[[ -z "$1" ]] && sleep 3 && xset dpms force off
|
|
||||||
return $retval
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "$1" == '-' ]]; then
|
screen_off() {
|
||||||
read signal
|
xset dpms force off
|
||||||
else
|
}
|
||||||
signal="$1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
signal="$1"
|
||||||
log "[I] Received signal \"$signal\"."
|
log "[I] Received signal \"$signal\"."
|
||||||
|
|
||||||
case "$signal" in
|
case "$signal" in
|
||||||
lock)
|
lock)
|
||||||
log "[I] Locking session."
|
log "[I] Locking session."
|
||||||
lock
|
lock && screen_off
|
||||||
;;
|
;;
|
||||||
logout)
|
logout)
|
||||||
log "[I] Exiting i3."
|
log "[I] Exiting i3."
|
||||||
@@ -54,11 +41,10 @@ case "$signal" in
|
|||||||
;;
|
;;
|
||||||
suspend)
|
suspend)
|
||||||
log "[I] Suspending."
|
log "[I] Suspending."
|
||||||
lock "1" && systemctl suspend
|
lock && systemctl suspend
|
||||||
;;
|
;;
|
||||||
hibernate)
|
hibernate)
|
||||||
log "[I] Hibernating."
|
log "[I] Hibernating."
|
||||||
#lock &&
|
|
||||||
systemctl hibernate
|
systemctl hibernate
|
||||||
;;
|
;;
|
||||||
reboot)
|
reboot)
|
||||||
@@ -71,7 +57,7 @@ case "$signal" in
|
|||||||
;;
|
;;
|
||||||
screen-off)
|
screen-off)
|
||||||
log "[I] Turning screen off."
|
log "[I] Turning screen off."
|
||||||
xset dpms force off
|
screen_off
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}"
|
echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}"
|
||||||
|
|||||||
Reference in New Issue
Block a user