Simplify i3lock script
This commit is contained in:
@@ -38,3 +38,5 @@ environment:
|
|||||||
MACHINE_HAS_NEXTCLOUD: "true"
|
MACHINE_HAS_NEXTCLOUD: "true"
|
||||||
MACHINE_HAS_RESTIC_BACKUP: "false"
|
MACHINE_HAS_RESTIC_BACKUP: "false"
|
||||||
MACHINE_DEFAULT_SCREENPROFILE: "ares"
|
MACHINE_DEFAULT_SCREENPROFILE: "ares"
|
||||||
|
MACHINE_RESOLUTION_X: "2560"
|
||||||
|
MACHINE_RESOLUTION_Y: "1440"
|
||||||
|
|||||||
@@ -51,3 +51,5 @@ environment:
|
|||||||
MACHINE_TYPE: "laptop"
|
MACHINE_TYPE: "laptop"
|
||||||
MACHINE_HAS_KEEPASSX: "true"
|
MACHINE_HAS_KEEPASSX: "true"
|
||||||
MACHINE_HAS_RESTIC_BACKUP: "true"
|
MACHINE_HAS_RESTIC_BACKUP: "true"
|
||||||
|
MACHINE_RESOLUTION_X: "1920"
|
||||||
|
MACHINE_RESOLUTION_Y: "1080"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
### 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"
|
||||||
LOCKSCREEN="$LIBDIR/wallpaper/lockscreen"
|
LOCKSCREEN="$LIBDIR/lockscreen"
|
||||||
|
|
||||||
_fallback_color="000000"
|
_fallback_color="000000"
|
||||||
|
|
||||||
@@ -19,29 +19,34 @@ lock()
|
|||||||
{
|
{
|
||||||
set -x
|
set -x
|
||||||
playing=0
|
playing=0
|
||||||
# if dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus'|grep -q Playing ; then
|
if [[ "$(playerctl status)" == "Playing" ]] ; then
|
||||||
# playing=1
|
playing=1
|
||||||
# fi
|
fi
|
||||||
# echo $playing
|
if (( $playing )) ; then
|
||||||
# (( $playing )) && dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause
|
playerctl pause
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -f "$LOCKSCREEN" ]] ; then
|
if [[ -f "$LOCKSCREEN" ]] ; then
|
||||||
|
resized_lockscreen=$(mktemp)
|
||||||
|
convert "${LOCKSCREEN}" -resize "${MACHINE_RESOLUTION_X}x${MACHINE_RESOLUTION_Y}" "${resized_lockscreen}"
|
||||||
i3lock --nofork --show-failed-attempts --ignore-empty-password \
|
i3lock --nofork --show-failed-attempts --ignore-empty-password \
|
||||||
--image "$LOCKSCREEN"
|
--image "${resized_lockscreen}"
|
||||||
|
rm "${resized_lockscreen}"
|
||||||
else
|
else
|
||||||
i3lock --nofork --show-failed-attempts --ignore-empty-password \
|
i3lock --nofork --show-failed-attempts --ignore-empty-password \
|
||||||
--color "$_fallback_color"
|
--color "$_fallback_color"
|
||||||
fi
|
fi
|
||||||
# (( $playing )) && dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play
|
if (( $playing )) ; then
|
||||||
|
playerctl play
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
screen_off() {
|
screen_off() {
|
||||||
:
|
|
||||||
xset dpms force off
|
xset dpms force off
|
||||||
}
|
}
|
||||||
|
|
||||||
reset_screen() {
|
reset_screen() {
|
||||||
xset -dpms
|
systemctl --user restart dpms.service
|
||||||
xset s off
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lock_and_screen_off() {
|
lock_and_screen_off() {
|
||||||
@@ -49,16 +54,11 @@ lock_and_screen_off() {
|
|||||||
_pid=$!
|
_pid=$!
|
||||||
dunstctl disable
|
dunstctl disable
|
||||||
screen_off
|
screen_off
|
||||||
xset dpms 0 0 5
|
|
||||||
wait $_pid
|
wait $_pid
|
||||||
dunstctl enable
|
dunstctl enable
|
||||||
reset_screen
|
reset_screen
|
||||||
}
|
}
|
||||||
|
|
||||||
disable_lid_switch() {
|
|
||||||
grep "^${ACPI_LID_NAME}.*enabled" /proc/acpi/wakeup && echo " ${ACPI_LID_NAME}" | sudo tee /proc/acpi/wakeup
|
|
||||||
}
|
|
||||||
|
|
||||||
signal="$1"
|
signal="$1"
|
||||||
log "[I] Received signal \"$signal\"."
|
log "[I] Received signal \"$signal\"."
|
||||||
|
|
||||||
@@ -74,13 +74,11 @@ case "$signal" in
|
|||||||
suspend)
|
suspend)
|
||||||
log "[I] Suspending."
|
log "[I] Suspending."
|
||||||
lock &
|
lock &
|
||||||
disable_lid_switch
|
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
systemctl suspend
|
systemctl suspend
|
||||||
;;
|
;;
|
||||||
hibernate)
|
hibernate)
|
||||||
log "[I] Hibernating."
|
log "[I] Hibernating."
|
||||||
disable_lid_switch
|
|
||||||
sudo systemctl hibernate
|
sudo systemctl hibernate
|
||||||
;;
|
;;
|
||||||
reboot)
|
reboot)
|
||||||
|
|||||||
Reference in New Issue
Block a user