I'm trying to hibernate using a shortcut from i3. My i3 config file looks like this :

 14 # Keyboard friendly exit
 15 set $exit exit: [l]ock, [e]logout, [h]ibernate, [r]eboot, [s]hutdown
 16 mode "$exit" {
 17   bindsym h exec "i3lock; systemctl hibernate"; mode "default"
 18   bindsym l exec i3lock -c 000000; mode "default"
 19   bindsym e exec i3-msg exit
 20   bindsym r exec systemctl reboot
 21   bindsym s exec systemctl poweroff
 22   bindsym Escape mode "default"
 23   bindsym Return mode "default"
 24 }

When I press h in the right mode, my PC locks itself but doesn't hibernate. I have tried replacing systemctl hibernate by sudo systemctl hibernate but it doesn't work either.

On a terminal, I can sudo systemctl hibernate to hibernate while systemctl hibernate will prompt me to authenticate with this message

Failed to hibernate system via logind: Access denied
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to start 'hibernate.target'.
Authenticating as: $User,,, ($user)

I am able to correctly shutdown and reboot from i3 but not hibernate.

Edit : I have a swap partition and hibernate functions if done from command line with sudo sytemctl hibernate .

My fstab looks like this :

# Swap
UUID=424242-4242-4242-4242-4242424242 none swap sw 0 0
  • 2
    Just a quick question from me, but do you have swap enabled? – Terrance Oct 1 '20 at 13:14
  • What is the output of cat /proc/swaps? – Terrance Oct 3 '20 at 15:18

Can you please create a new line within sudoers for nopasswd on systemctl hibernate and see how you go?

I have hibernate mapped to Alt + Shift + F4, and I have configured my id to run sudo systemctl hibernate with no passwd

  1. Check where systemctl is : which systemctl

  2. Replace the output of the above command in the #placeholder# within sudoers and i3 config :

sudoers file :

midway ALL=(ALL) NOPASSWD: #placeholder# hibernate

i3 config :

bindsym Mod1+Shift+F4  exec sudo #placeholder# hibernate

Hope this is easier to follow.

  • I have tried your solution (by replacing midway with my username) and it didn't work. To be more specific, even doing sudo /usr/bin/systemctl hibernate in command line didn't work. It yielded sudo: /usr/bin/systemctl: command not found and also prompted me for my password. – Statistic Dean Oct 2 '20 at 9:37
  • @StatisticDean, sorry, I should have been clearer. I will edit my answer now. – MidwayNomad Oct 2 '20 at 13:44
  • This is not working for me yet. Changing the sudoers file did nothing. sudo /bin/systemctl still calls me for my password and doing from i3 still only locks my screen. – Statistic Dean Oct 5 '20 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.