diff --git a/X/.config/xresources/xinitrc b/X/.config/xresources/xinitrc index 6152ecd..6a90b79 100644 --- a/X/.config/xresources/xinitrc +++ b/X/.config/xresources/xinitrc @@ -72,4 +72,6 @@ setxkbmap -option grp:alt_shift_toggle # 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 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 diff --git a/bootstrap/packages.txt b/bootstrap/packages.txt index 42f4c61..1e2d1c6 100644 --- a/bootstrap/packages.txt +++ b/bootstrap/packages.txt @@ -220,6 +220,7 @@ xclip xorg-xev xorg-xinit xorg-xinput +xss-lock youtube-dl zathura-pdf-mupdf zsh-autosuggestions diff --git a/i3/.config/i3/config b/i3/.config/i3/config index 03a778a..b33d749 100644 --- a/i3/.config/i3/config +++ b/i3/.config/i3/config @@ -180,12 +180,6 @@ bindsym $mod+F12 reload # restart i3 inplace (preserves your layout/session, can be used to upgrade i3) 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 # assign [class="^qutebrowser$"] → number 1 # 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: ' # 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: ' + +# launch polybar (script ensures only 1 instance existing at a time) +exec_always --no-startup-id polybar-launch top + diff --git a/scripts/.local/bin/lockscreen b/scripts/.local/bin/lockscreen index f242276..ad0b212 100755 --- a/scripts/.local/bin/lockscreen +++ b/scripts/.local/bin/lockscreen @@ -1,8 +1,54 @@ #!/usr/bin/env sh -# In case we want to pause any players -# (see https://github.com/LukeSmithxyz/voidrice/blob/archi3/.config/sxhkd/sxhkdrc for that) -# mpc -q pause -# amixer set Master mute +# Example locker script -- demonstrates how to use the --transfer-sleep-lock +# option with i3lock's forking mode to delay sleep until the screen is locked. -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