Lock Screen before hibernate hibernate the kernel method to a swap FILE

First off I’m using gnome 3 and opensuse 12.2 on my laptop (check sig). I have Ubuntu, openSUSE, windows 8 beta, and Kubuntu on it.
I wanted to multi-hibernate my laptop so I switched my swap from my swap partition (/dev/sda5) to a file on /dev/sda6. I changed my /etc/fstab, I then changed my grub2 statement
to
resume=/dev/sda6 resume_offset=whatever running swap-offset myfile was
Then I noticed hibernate button doesn’t work
I think I also tried editing some pm-utils config files, but I guess you must use the kernel method.

so I switched to the kernel method and wrote a script

          
#!/bin/bash 
echo shutdown > /sys/power/disk 
echo disk > /sys/power/state

Then I made a keyboard shortcut to F11

gnomesu my_hibernate_script

notice the gnomesu in order to get root priv.
Works very nicely
but my screen won’t lock b4 it shutsdown
I’ve tried editing my script to include:


su <myname> -c gnome-screensaver-command --lock &

all combinations of such
to no avail

so my question is if its possible to lock it b4, whether there is some other place to signify this

and what do you think about my hibernate setup anyway. AFAIK the kernel method is the only way to hibernate to a swap file, if not can you point me in the right direction
(pm-utils etc). Would be nice if I could use the already made button under the menu for powering down/logout.

Thanks for any help

I don’t use Gnome, but you can try this:

export DISPLAY=:0
gnome-screensaver 
gnome-screensaver-command -d

For KDE 4 users Try:

qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock

The latter works for me using KDE 4 from a bash script…

Thank You,

On 2012-10-10 23:46, cw9000 wrote:

> Then I noticed hibernate button doesn’t work

I’m unsure you can hibernate to a file, I think it needs a partition.


Cheers / Saludos,

Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)

[all variants] HOWTO: Use swapfile instead of partition and hibernate - Ubuntu Forums](http://ubuntuforums.org/showthread.php?t=1042946)

On 2012-10-11 02:36, please try again wrote:
>
> robin_listas;2495080 Wrote:
>> On 2012-10-10 23:46, cw9000 wrote:
>>
>>> Then I noticed hibernate button doesn’t work
>>
>> I’m unsure you can hibernate to a file, I think it needs a partition.
>>
>
> ‘[all variants] HOWTO: Use swapfile instead of partition and hibernate
> - Ubuntu Forums’ (http://ubuntuforums.org/showthread.php?t=1042946)

Oh. :open_mouth:

But you have to do some work, it is not automatic, right? I did not understand it all (very
late night here). Which means that if the designers of the hibernate button functionality think
that it is not possible, the button will not work.


Cheers / Saludos,

Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)

This is how I started
Hibernation/Hibernate_Without_Swap_Partition - Debian Wiki


su -
fallocate -l 4000m /swap_file  #4000 mb, You may want to put the number higher if you have a lot of memory
swapoff -a
mkswap /swap_file

nano /etc/fstab
#delete previous swap entry then add
/swap_file   swap    swap    defaults        0       0
#then save and exit

swap-offset /swap_file
nano /etc/grub.d/40_custom
add to linux line:    resume=<partition swapfile is on> resume_offset=<swap-offset return data>

swapon -a
nano /home/name/bin/hibernate_shutdown
#!/bin/bash
echo shutdown > /sys/power/disk
echo disk > /sys/power/state

create shortcut. system-settings->keyboard->shortcuts->custom shortcuts  add
gnomesu /home/name/bin/hibernate_shutdown
set to F11
chmod +x /home/name/bin/hibernate_shutdown
restart computer

viola
if you want to restart after hibernate instead of shutdown
echo reboot > /sys/power/disk
echo disk > /sys/power/state

so just hit F11 put in your password and you’re hibernated
but the screen will not lock before hibernate, no matter what I try

thanks for the suggestion jdmcdaniel3
but it didn’t work.
well, guess I’ll have to live with it for now.

On 2012-10-12 06:16, cw9000 wrote:

> Code:
> --------------------
> nano /home/name/bin/hibernate_shutdown
> #!/bin/bash
> echo shutdown > /sys/power/disk
> echo disk > /sys/power/state
> --------------------

This hibernating method bypasses all preparations done before hibernation. I would try pm-hibernate
instead.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” (Minas Tirith))

does pm-hibernate allow you to hibernate to a swap file, if so, how. pm-hibernate didn’t work on my system. I checked the log /var/log/pm-suspend.log and it said something…well I can’t remember exactly what it said, but said something
about user method vs kernel method or something like that. I don’t think it likes the resume_offset in grub

On 2012-10-13 02:46, cw9000 wrote:
>
> does pm-hibernate allow you to hibernate to a swap file, if so, how.
> pm-hibernate didn’t work on my system. I checked the log
> /var/log/pm-suspend.log and it said something…well I can’t remember
> exactly what it said, but said something
> about user method vs kernel method or something like that. I don’t
> think it likes the resume_offset in grub

Ah… yes, I see the problem. Right, pm-hibernate would not work, not without some hacking somewhere
(and I don’t know how/what)


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” (Minas Tirith))