Suspend not workin.

Greets!

I’m tryin to get auto-suspend operational, but it just doesn’t work. Set it corectly in power manager, enabled the lines in sleep.conf, but it seems that it cannot work, cause i’m not usin systemD.

With ‘systemctl suspend’, i get: ‘System has not been booted with systemd as init system (PID 1). Can’t operate. Failed to connect to bus: Host is down’.

And it doesn’t suspend.

How could i enable suspend with init please?

What Linux distro are you using?

have you tried pm-utils package? Try to install it and then run:

$ pm-suspend

and see if it works…if all good we can write some auto suspend script. Something like:

https://bashscript.net/sleep-timer-bash-script-for-system-suspension/

but with a different command eg. instead of systemctl suspend -i you can use pm-suspend

Lubos

Thxs, ‘$ pm-suspend’ works, but when tryin to write the script with nano, and savin it, like this:


, got a permission denied on enter…

You simply do not have permissions to write into the directory. Change location eg. to your home directory and try again. cd ENTER will get you to your home.

Ok, managed to create the file, but when startin it, and enterin the time, it says: This utility may only be run by the root user.

And that won’t automate the suspend activation, i’ll still have to launch the file, right?

Please describe in detail what are you actually trying to achieve as there might be multiple solutions.

Just that once i left my computer untouched for a given time, it will auto-suspend.

Ok. So problem solved…!?!

Nops, that’s just what i’m tryin to achieve. And i’m askin if the script you provided could do that, or if it requires a specific triger in order to suspend the computer. The wich i could do by simply clickin the suspend buton in the log out.

you could run something like this suspend bash script:

#!/bin/bash

# Function to convert minutes to milliseconds
convert_to_milliseconds() {
    local minutes=$1
    echo $((minutes * 60000))
}

# Set the number of minutes. System will suspend after:
MINUTES=5

# Convert to milliseconds
IDLE_TIME=$(convert_to_milliseconds "$MINUTES")

while true; do
    idle=$(xprintidle)
    if [ "$idle" -gt "$IDLE_TIME" ]; then
        pm-suspend
    fi
    sleep 60  # Check every minute
done

Make sure that you have xprintidle package installed before you run the script:

$ sudo apt install xprintidle

Thxs, started the script, but after the time elapsed, got this eror message:

This utility may only be run by the root user.

And i’ll have to start it at each session, right?

I think the best approach is to find out why native tools do not work for you. What Linux Distro and desktop are you using? After that you can decide on the strategy as there are many solutions. You could also use cron etc.