X: Improve lockscreen handling
Added lockscreen trapping and media pausing for lockscreen. When it is invoked `lockscreen`, all media will be attempted to be pause and the system will be muted. Then the lockscreen is engaged. This should happen automatically when the screen shuts off or the system suspends or hibernates and can be invoked manually, as before, with super+x shortcut.
This commit is contained in:
parent
7fdbe97c7e
commit
496522605f
4 changed files with 58 additions and 11 deletions
|
@ -72,4 +72,6 @@ setxkbmap -option grp:alt_shift_toggle
|
||||||
# set a timeout of 500ms, if pressed longer it will ignore esc
|
# set a timeout of 500ms, if pressed longer it will ignore esc
|
||||||
type xcape >/dev/null 2>&1 && xcape -e 'Control_L=Escape' -t 500
|
type xcape >/dev/null 2>&1 && xcape -e 'Control_L=Escape' -t 500
|
||||||
|
|
||||||
|
type feh >/dev/null 2>&1 && exec feh --bg-scale ~/media/pictures/wall.jpg &
|
||||||
|
type xss-lock >/dev/null 2>&1 && exec xss-lock &
|
||||||
type i3 >/dev/null 2>&1 && exec i3
|
type i3 >/dev/null 2>&1 && exec i3
|
||||||
|
|
|
@ -220,6 +220,7 @@ xclip
|
||||||
xorg-xev
|
xorg-xev
|
||||||
xorg-xinit
|
xorg-xinit
|
||||||
xorg-xinput
|
xorg-xinput
|
||||||
|
xss-lock
|
||||||
youtube-dl
|
youtube-dl
|
||||||
zathura-pdf-mupdf
|
zathura-pdf-mupdf
|
||||||
zsh-autosuggestions
|
zsh-autosuggestions
|
||||||
|
|
|
@ -180,12 +180,6 @@ bindsym $mod+F12 reload
|
||||||
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
|
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
|
||||||
bindsym $mod+Shift+F12 restart
|
bindsym $mod+Shift+F12 restart
|
||||||
|
|
||||||
# set a pretty wallpaper
|
|
||||||
exec_always --no-startup-id feh --bg-scale ~/media/pictures/wall.jpg
|
|
||||||
|
|
||||||
# launch polybar (script ensures only 1 instance existing at a time)
|
|
||||||
exec_always --no-startup-id polybar-launch top
|
|
||||||
|
|
||||||
# default workspaces for most used apps
|
# default workspaces for most used apps
|
||||||
# assign [class="^qutebrowser$"] → number 1
|
# assign [class="^qutebrowser$"] → number 1
|
||||||
# spotify needs for_window, see https://i3wm.org/docs/userguide.html#assign_workspace
|
# spotify needs for_window, see https://i3wm.org/docs/userguide.html#assign_workspace
|
||||||
|
@ -205,3 +199,7 @@ for_window [class="scratchpad"] move scratchpad
|
||||||
bindsym $mod+m exec i3-input -F 'mark %s' -l 1 -P 'Mark: '
|
bindsym $mod+m exec i3-input -F 'mark %s' -l 1 -P 'Mark: '
|
||||||
# read 1 character and go to the window with the character
|
# read 1 character and go to the window with the character
|
||||||
bindsym $mod+apostrophe exec i3-input -F '[con_mark="%s"] focus' -l 1 -P 'Goto: '
|
bindsym $mod+apostrophe exec i3-input -F '[con_mark="%s"] focus' -l 1 -P 'Goto: '
|
||||||
|
|
||||||
|
# launch polybar (script ensures only 1 instance existing at a time)
|
||||||
|
exec_always --no-startup-id polybar-launch top
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,54 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
# In case we want to pause any players
|
# Example locker script -- demonstrates how to use the --transfer-sleep-lock
|
||||||
# (see https://github.com/LukeSmithxyz/voidrice/blob/archi3/.config/sxhkd/sxhkdrc for that)
|
# option with i3lock's forking mode to delay sleep until the screen is locked.
|
||||||
# mpc -q pause
|
|
||||||
# amixer set Master mute
|
|
||||||
|
|
||||||
i3lock -e -f -c 1d2021
|
## CONFIGURATION ##############################################################
|
||||||
|
|
||||||
|
# Options to pass to i3lock
|
||||||
|
i3lock_options="-e -f -c 1d2021"
|
||||||
|
|
||||||
|
# Run before starting the locker
|
||||||
|
pre_lock() {
|
||||||
|
# pause all currently playing media and mute system
|
||||||
|
type mpc >/dev/null 2>&1 && mpc -q pause
|
||||||
|
type playerctl >/dev/null 2>&1 && playerctl -s pause
|
||||||
|
type amixer >/dev/null 2>&1 && amixer -q set Master mute
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run after the locker exits
|
||||||
|
post_lock() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
pre_lock
|
||||||
|
|
||||||
|
# We set a trap to kill the locker if we get killed, then start the locker and
|
||||||
|
# wait for it to exit. The waiting is not that straightforward when the locker
|
||||||
|
# forks, so we use this polling only if we have a sleep lock to deal with.
|
||||||
|
if [ -e /dev/fd/${XSS_SLEEP_LOCK_FD:--1} ]; then
|
||||||
|
kill_i3lock() {
|
||||||
|
pkill -xu $EUID "$@" i3lock
|
||||||
|
}
|
||||||
|
|
||||||
|
trap kill_i3lock TERM INT
|
||||||
|
|
||||||
|
# we have to make sure the locker does not inherit a copy of the lock fd
|
||||||
|
i3lock $i3lock_options {XSS_SLEEP_LOCK_FD}<&-
|
||||||
|
|
||||||
|
# now close our fd (only remaining copy) to indicate we're ready to sleep
|
||||||
|
exec {XSS_SLEEP_LOCK_FD}<&-
|
||||||
|
|
||||||
|
while kill_i3lock -0; do
|
||||||
|
sleep 0.5
|
||||||
|
done
|
||||||
|
else
|
||||||
|
trap 'kill %%' TERM INT
|
||||||
|
i3lock -n $i3lock_options &
|
||||||
|
wait
|
||||||
|
fi
|
||||||
|
|
||||||
|
post_lock
|
||||||
|
|
Loading…
Reference in a new issue