How To: i3lock with Suspend

Forum rules
Share your brain ;)
User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

How To: i3lock with Suspend

Unread post by dkeg » Tue Sep 17, 2013 7:11 pm

may or may not be useful. activate i3lock when suspend.

Full Disclosure, I forget where I came across, not my creation.

Code: Select all

#!/bin/bash

username=xxx    # insert username
userhome=/home/$username
export XAUTHORITY="$userhome/.Xauthority"
export DISPLAY=":0"
case "$1" in
hibernate|suspend)
su $username -c "/usr/bin/i3lock"    # see second example below
;;
thaw|resume)
           ;;
*) exit $NA
;;
esac
save, name, place in /etc/pm/sleep.d
chmod 755
chown root:root

I use an image for i3lock, so my syntax is

Code: Select all

su $username -c "/usr/bin/i3lock -i /home/dkeg/.i3/i3lock_back.png"

Work hard; Complain less

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5878
Joined: Tue Sep 03, 2013 7:05 am

Re: How To: I3lock with Suspend

Unread post by GekkoP » Wed Sep 18, 2013 8:01 am

Nice one. I still have to play around with i3lock, but I'll use this script.

User avatar
elixir
Weight Watcher
Posts: 357
Joined: Fri Feb 21, 2014 8:25 am

Re: How To: I3lock with Suspend

Unread post by elixir » Tue Feb 25, 2014 6:36 pm

After reading this, I used i3lock for the first time and it scared the heck out of me! Why screen turned white and I was like WHAT DID I JUST DO. I thought out the work lock though and figured it out ;) I am going to check out your script now ;)
Out of the corner of your eye you spot him... Shia LaBeouf.

https://www.youtube.com/watch?v=o0u4M6vppCI

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: How To: I3lock with Suspend

Unread post by dkeg » Tue Feb 25, 2014 10:53 pm

Cool! That same thing happened to me. And once you for this one going, I have another to share

Work hard; Complain less

User avatar
57kev
Saltimbocca-Roller
Posts: 15
Joined: Sat Jan 26, 2013 5:31 am
Location: Australia

Re: How To: I3lock with Suspend

Unread post by 57kev » Sat Mar 01, 2014 6:54 am

dkeg, nice I will borrow this, thanks.

as an aside I use a Windows 8 image with i3lock on my laptop, screws with the young and unwary. ;-)
Attachments
i3lock.png

User avatar
elixir
Weight Watcher
Posts: 357
Joined: Fri Feb 21, 2014 8:25 am

Re: How To: I3lock with Suspend

Unread post by elixir » Sat Mar 01, 2014 8:02 am

^ I saw the windows 8 picture and I was like (-.-) but when I read your post I was like (^.^)
Out of the corner of your eye you spot him... Shia LaBeouf.

https://www.youtube.com/watch?v=o0u4M6vppCI

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: How To: I3lock with Suspend

Unread post by dkeg » Sat Mar 01, 2014 2:59 pm

This is a blend of above and a post wux shared using a pixelated image

http://linuxbbq.org/bbs/viewtopic.php?f ... end#p17086

Code: Select all

#!/bin/bash

## takes screen shot
scrot /tmp/screen_locked.png
## blur the image and save
convert /tmp/screen_locked.png -scale 10% -scale 1000% /tmp/screen_locked2.png
## suspend with pm-suspend script
sudo pm-suspend
and in /etc/pm/sleep.d/suspend.sh

Code: Select all

#!/bin/bash

username=xxx    # insert username
userhome=/home/$username
export XAUTHORITY="$userhome/.Xauthority"
export DISPLAY=":0"
case "$1" in
hibernate|suspend)
## use blurred current desktop image
su $username -c "/usr/bin/i3lock -i /tmp/screen_locked2.png"
## use static image
#su $username -c "/usr/bin/i3lock -i /home/dkeg/images/i3lock_back2.png"  
;;
thaw|resume)
           ;;
*) exit $NA
;;
esac

Work hard; Complain less

User avatar
wuxmedia
Grasshopper
Posts: 6454
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: How To: I3lock with Suspend

Unread post by wuxmedia » Sat Mar 01, 2014 4:31 pm

I borrowed it from someone else !
so you mean that this script makes the i3lock come up *after* waking from suspend?
or during?
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: How To: I3lock with Suspend

Unread post by dkeg » Sat Mar 01, 2014 5:06 pm

after.

Work hard; Complain less

User avatar
wuxmedia
Grasshopper
Posts: 6454
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: How To: i3lock with Suspend

Unread post by wuxmedia » Sat Mar 01, 2014 5:15 pm

I think mine still counts to ten mins, then it wakes up then realises its supposed to be locked, so hurriedly locks the screen up again.
if i suspend/restore before that, no screen lock
So thanks, for posting that!
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: How To: i3lock with Suspend

Unread post by dkeg » Sat Mar 01, 2014 5:18 pm

so does that happen for you with the above scripts? Or before?

Work hard; Complain less

Post Reply