LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-17-2021, 06:05 PM   #1
camerabambai
Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 408

Rep: Reputation: 54
Slackware-current: is possible to run loginctl hibernate as user?


I'm on Slackware current usingd elogind, I can sleep and hibernate only using sudo from terminal.
With the old good pm-utils I had only to edit the 10-enable-suspend.rules, make init 3 && init 4 and I can hibernate as user.
Now I make those steps

a)copying the two polkit rules

Code:
    cp /usr/share/polkit-1/rules.d/10-enable-* /etc/polkit-1/rules.d/
b)I add my user in power group

Code:
    usermod -aG power myuser
c)in logind.conf I had those options enabled

Code:
 grep -v ^# /etc/elogind/logind.conf
    
    [Login]
    HandlePowerKey=poweroff
    HandleHibernateKey=hibernate
    HandleLidSwitch=hibernate
    
    [Sleep]
    AllowSuspend=yes
    AllowHibernation=yes
    AllowSuspendThenHibernate=yes
    AllowHybridSleep=yes
d) I reboot the system

Code:
    reboot
And from xfce4-power-manager I cannot hibernate or sleep.

I tried also from cli

Code:
    $ loginctl hibernate
    $ echo $?
    1
 
Old 06-17-2021, 06:15 PM   #2
saxa
Senior Member
 
Registered: Aug 2004
Location: Nova Gorica, Salvador
Distribution: Slackware
Posts: 1,213

Rep: Reputation: 297Reputation: 297Reputation: 297
I think it should be possible, tomorrow I will see if I can try that on my slackware-current install.
 
Old 06-20-2021, 09:56 AM   #3
chrisretusn
Senior Member
 
Registered: Dec 2005
Location: Philippines
Distribution: Slackware64-current
Posts: 2,969

Rep: Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548
I just tryed 'loginctl hibernate' on my laptop from the CLI (runlevel 3) after logging out of Plasma. It worked, so it is possible.
 
Old 06-20-2021, 11:05 AM   #4
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
I can "loginctl hibernate" from within a KDE Plasma5 session, as normal user, and it takes only a few seconds to complete. After restarting the laptop and loading the hibernation image from disk, I am right back where I started the hibernation. No sudo needed for this.
 
Old 06-20-2021, 11:57 AM   #5
lovemeslk
Member
 
Registered: Feb 2020
Location: Rantoul IL
Distribution: Slackware
Posts: 350

Rep: Reputation: 72
If you created your user from The adduser script then your user is in the Power group gives him rights.
for Hibernate I set up a in lilo and or grub2 resume=/dev/sda4 that is my swap partition.
Not sure if that is needed anymore but I still use it for hibernate.
Sleep gets saved to ram. system stays on.

Hibernate
During hibernate the system is fully powered off, and system state is saved to disk.
The system does not require power, and can stay in hibernate mode indefinitely.
Most modern systems require 15 to 45 seconds to enter and leave hibernate, and entering and
leaving hibernate takes longer when you have more memory.

Hybrid-Hibernate
Hybrid-suspend is the process where the system does everything it needs to hibernate, suspends instead of shutting down.
This means that your computer can wake up quicker than for normal hibernation if you do not run out of power, and
you can resume even if you run out of power
 
Old 06-21-2021, 08:03 PM   #6
camerabambai
Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 408

Original Poster
Rep: Reputation: 54
Quote:
Originally Posted by lovemeslk View Post
If you created your user from The adduser script then your user is in the Power group gives him rights.
for Hibernate I set up a in lilo and or grub2 resume=/dev/sda4 that is my swap partition.
Not sure if that is needed anymore but I still use it for hibernate.
Sleep gets saved to ram. system stays on.

Hibernate
During hibernate the system is fully powered off, and system state is saved to disk.
The system does not require power, and can stay in hibernate mode indefinitely.
Most modern systems require 15 to 45 seconds to enter and leave hibernate, and entering and
leaving hibernate takes longer when you have more memory.

Hybrid-Hibernate
Hybrid-suspend is the process where the system does everything it needs to hibernate, suspends instead of shutting down.
This means that your computer can wake up quicker than for normal hibernation if you do not run out of power, and
you can resume even if you run out of power
my hibernation work, but only as root
my problem is, that I want to hibernate from user

Code:
groups |grep --color power
wheel floppy audio video cdrom games plugdev power netdev scanner users kvm vdr
loginctl hibernate
echo $?
1
syslog said..

Code:
loginctl[2419]: Failed to hibernate system via elogind: Interactive authentication required.

Last edited by camerabambai; 06-21-2021 at 08:13 PM.
 
Old 06-22-2021, 05:47 AM   #7
saxa
Senior Member
 
Registered: Aug 2004
Location: Nova Gorica, Salvador
Distribution: Slackware
Posts: 1,213

Rep: Reputation: 297Reputation: 297Reputation: 297
Please check if your user is listed in the power group ?
If not you should add your user to the power group in /etc/group .

I can confirm that my system suspends when I do "loginctl suspend" as user, but it does not return back very well,
it powers up but nothing shows on the screen.
 
Old 06-22-2021, 09:51 AM   #8
lovemeslk
Member
 
Registered: Feb 2020
Location: Rantoul IL
Distribution: Slackware
Posts: 350

Rep: Reputation: 72
Quote:
Originally Posted by saxa View Post
Please check if your user is listed in the power group ?
If not you should add your user to the power group in /etc/group .

I can confirm that my system suspends when I do "loginctl suspend" as user, but it does not return back very well,
it powers up but nothing shows on the screen.
Then you need to tell the kernel where to look for resume append lilo or grub resume=/dev/sdX your swap partition.
with multiple drives and operating systems at lilo or grub must log back to the one you hibernated from.
 
Old 06-22-2021, 01:15 PM   #9
saxa
Senior Member
 
Registered: Aug 2004
Location: Nova Gorica, Salvador
Distribution: Slackware
Posts: 1,213

Rep: Reputation: 297Reputation: 297Reputation: 297
I think that for suspend to ram should not be needed. Only to hibernate. In any case I have resume=/dev/sda1 in my append in lilo.conf, but the thing is that it does not even start lilo, it comes directly into the console, but most probably my problem is with the X desktop
I am running. On kernel side it seems to work fine as I can CTRL-ALT-DEL when it comes back, but I can not ssh into it.
 
Old 06-22-2021, 11:02 PM   #10
notzed
Member
 
Registered: Dec 2020
Location: South Australia
Distribution: slackware64-current
Posts: 95

Rep: Reputation: Disabled
Quote:
Originally Posted by saxa View Post
I think that for suspend to ram should not be needed. Only to hibernate. In any case I have resume=/dev/sda1 in my append in lilo.conf, but the thing is that it does not even start lilo, it comes directly into the console, but most probably my problem is with the X desktop
I am running. On kernel side it seems to work fine as I can CTRL-ALT-DEL when it comes back, but I can not ssh into it.
You're correct, the resume thing is only used for hibernate. And suspend is notoriously unreliable because it depends on PC BIOS/UEFI and ACPI and that's all such buggy junk, but sometimes you just get lucky and it works.

I don't have swap on this system so can't test hibernate but 'loginctl reboot' works so there's no permission problem. Curiously 'loginctl suspend' just crashes my system (as does writing to /sys/power/state[1]) but i've been using the the xfce 'suspend' action menu just fine since I got it setup 18 months ago. I have no idea why it behaves differently since they both seem to just use dbus to initiate the suspend.

I use xdm @ runlevel 4 to login, use xfce4, elogind is using defaults, and I never mucked about with polkit stuff. My user is not in the power group.

[1] https://www.kernel.org/doc/html/late...ep-states.html
 
Old 07-01-2021, 05:49 PM   #11
camerabambai
Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 408

Original Poster
Rep: Reputation: 54
I see as user I cannot hibernate, suspend, and change brightness down.
Syslog said

root: ACPI group video / action brightnessdown is not defined

As root all works(hibernate, suspend, bright down)
 
Old 07-01-2021, 06:13 PM   #12
camerabambai
Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 408

Original Poster
Rep: Reputation: 54
Solution found.
 
Old 07-01-2021, 06:19 PM   #13
camerabambai
Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 408

Original Poster
Rep: Reputation: 54
The solution is easy

a)I have created 3 files, one for brightness, one for suspend, one for hibernate

Code:
/etc/polkit-1/rules.d/88-suspend.rules
/etc/polkit-1/rules.d/88-hibernate.rules
/etc/polkit-1/rules.d/89-backlight.rules
b)the contents of files: I assign to the group power the possibility to decrease brightness, suspend and hibernate the os

Code:
cat /etc/polkit-1/rules.d/88-hibernate.rules
polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.login1.hibernate" &&
        subject.isInGroup("power")) {
        return polkit.Result.YES;
    }
});


cat /etc/polkit-1/rules.d/88-suspend.rules
polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.login1.suspend" &&
        subject.isInGroup("power")) {
        return polkit.Result.YES;
    }
});


cat /etc/polkit-1/rules.d/89-blacklight.rules
polkit.addRule(function(action, subject) {
    if (action.id == "org.xfce.power.backlight-helper" &&
        subject.isInGroup("power")) {
        return polkit.Result.YES;
    }
});
c)restart power-manager

Code:
xfce4-power-manager --restart
works fine from xfce4 and using loginctl hibernate as user

Last edited by camerabambai; 07-01-2021 at 08:10 PM.
 
1 members found this post helpful.
  


Reply

Tags
hibernate



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Acpi loginctl and power management hell Tonus Slackware 5 03-16-2021 02:53 PM
hanging session in systemd loginctl jleonardi Linux - Server 2 01-04-2018 07:48 PM
Hibernate one distro, de-hibernate another Ulysses_ Linux - Software 8 12-28-2010 09:34 AM
13.1 Beta1 :: KDE SC 4.4.3 :: pm-hibernate works, KDE hibernate just locks the screen zordrak Slackware 7 05-12-2010 03:55 AM
cli hibernate works but gnome panel hibernate fails BCarey Linux - Desktop 1 06-08-2007 10:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration