The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
0

lockscreen after closing my laptop

asked 2015-09-22 22:29:29 +0000

j0sch4 gravatar image

Hi Guys

This is my second Day with i3 and most thigs are pretty straight forward, but some things i just don't know how to deal with. My biggest problem along some others is that i'm not able to get a lock screen after opening my laptop again and this is essential for me. I just want to be promted for my password like i3lock does it. But why isn't it executed by my laptop going in sleep mode.?

Bye

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
1

answered 2015-09-23 03:19:16 +0000

SpicyCat gravatar image

If you want to lock your screen after some time, you can use xautolock

exec --no-startup-id xautolock -time 4 -locker "i3lock-wrapper -l"

And I create a mode to handle lock, suspend, hibernate, reboot and poweroff

set $Locker i3lock-wrapper -l && sleep 1

set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown
mode "$mode_system" {
    bindsym l exec --no-startup-id $Locker, mode "default"
    bindsym e exec --no-startup-id i3-msg exit, mode "default"
    bindsym s exec --no-startup-id $Locker && systemctl suspend, mode "default"
    bindsym h exec --no-startup-id $Locker && systemctl hibernate, mode "default"
    bindsym r exec --no-startup-id systemctl reboot, mode "default"
    bindsym Shift+s exec --no-startup-id  systemctl poweroff -i, mode "default"

    # back to normal: Enter or Escape
    bindsym Return mode "default"
    bindsym Escape mode "default"
}

bindsym $mod+Delete mode "$mode_system"

If you mean lock and suspend when closing laptop lid, you can check this repo and this post

edit flag offensive delete link more
1

answered 2015-09-23 00:41:46 +0000

dd0 gravatar image

I use these to lock, not sure if it's a good method.

# lock screen
bindsym $mod+Delete exec --no-startup-id "i3lock -c 000000"
# lock screen and suspend
bindsym $mod+End exec --no-startup-id "i3lock -c 000000 && systemctl suspend"
# lock and hibernate
bindsym $mod+Insert exec --no-startup-id "i3lock -c 000000 && systemctl hibernate"
edit flag offensive delete link more
0

answered 2015-09-24 11:28:38 +0000

ManusX gravatar image

Create a file /etc/systemd/system/sleep.target.wants/screenlock.service which contains:

[Unit]
Description=Starts i3lock at suspend time
Before=sleep.target

[Service]
User=<YOURUSERNAME>
Type=forking
Environment=DISPLAY=:0
ExecStartPre=
ExecStart=/usr/local/bin/lockandblur.sh

[Install]
WantedBy=sleep.target

/usr/local/bin/lockandblur.sh should be exchanged by whatever you want to do, a simple i3lock would also succeed (in my case this is a script which takes a screenshot, blurs it using image magick and then uses it as lockscreen).

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-09-22 22:29:29 +0000

Seen: 334 times

Last updated: Sep 24