Skip to content

Instantly share code, notes, and snippets.

@advilm
Last active September 27, 2024 07:56
Show Gist options
  • Select an option

  • Save advilm/f8d4ba12e34fae9090f3b47e8b0836a3 to your computer and use it in GitHub Desktop.

Select an option

Save advilm/f8d4ba12e34fae9090f3b47e8b0836a3 to your computer and use it in GitHub Desktop.
Just some files relating to my i3lock setup
# /etc/systemd/system/suspend.service
[Unit]
Description=Delay suspend until i3lock starts
Before=sleep.target suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target
[Service]
Type=oneshot
ExecStart=/bin/bash -c 'while ! pidof i3lock; do sleep 1; done'
[Install]
WantedBy=sleep.target suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target
# scripts/lock.sh
#!/bin/sh
if ! pidof i3lock; then
scrot -o /tmp/screenshot.png
convert /tmp/screenshot.png -blur 0x5 /tmp/screenshot.png
# Turn on DND
old="$(xfconf-query -c xfce4-notifyd -p /do-not-disturb)"
xfconf-query -c xfce4-notifyd -p /do-not-disturb -s true
# Pause stuff and mute audio
playerctl -a pause > /dev/null
aold="$(amixer get Master | tail -2 | grep '\[on\]')"
amixer set Master mute > /dev/null
i3lock -ui /tmp/screenshot.png
while pidof i3lock > /dev/null; do
if (timeout 5 fprintd-verify | grep -q verify-match); then
pkill i3lock
fi
done
# Set settings back to what they were before
if ! [ -z "$aold" ]; then
amixer set Master unmute > /dev/null
fi
xfconf-query -c xfce4-notifyd -p /do-not-disturb -s $old
fi
# xss-lock command
xss-lock -- ~/scripts/lock.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment