Sentinella in arch ? automate laptop shutdown kshutdown qshutdown

I am looking for a laptop auto shutdown or suspend to ram software.
I have one super good in windows. i wonder if there is one that is as good in linux.
I saw this software “sentinella” is as good…
It can trigger shutdown or suspend via cpu, via network tranfer rate via time via another package condition… but i can’t find it aur or depo

Kshutdown is an option, but not that rich in feature.
I want it to suspend my pc after timeshift finish backup… no idea if that works…
with windows os autoshutdown app, it can set to shutdown after hdd is not much transfer rate

qshutdown is another one, but even less feature than kshutdown.

It looks like sentinella has been long abandoned - it appears that the last update was in 2013.

I have no recommendations, as I don’t use the suspend function, but you should probably forget about sentinella.

2 Likes

Ok.
I am trying kshutdown. but don’t know if it works.
I am running timeshift , doing backup for the first time for this laptop. running timeshift gui . I don’t know if timeshift will exit after finish backup… but trying anyway. because i need to sleep . late.

If you are willing to write a script, you can use this command to shut down a computer running KDE Plasma:

3 Likes

ha! the auto suspend after timeshift finish failed. When i wake up laptop from suspend this morning, it was not even finish timeshifting.
Something else made it sleep.

What are the features in a endea kde that make a laptop sleep ?

  1. screen saver
  2. power management TLP ?
    3 ?

*if you will tell me i will obtain a complete list of it…

Why so complicated? :grin: I know you’re more into GUI’s but once you’ve set up Timeshift you can create a snapshot simply by running sudo timeshift --create in a terminal. Combine that with a suspend or shutdown command and you should be good to go.

  • Try the following in a terminal
    sudo timeshift --create && systemctl suspend
4 Likes

Wonderful! that’s was what i was looking for, simple no need to install this and that…
So timeshift have extra trick under it sleeve through terminal which gui does not have …

Thanks. You saved me tons of time …

Gracias :clap:

oh… i think it is nothing to do with timeshift isn’t it ? should be todo with linux terminal power of combining command.
I know tee can be use to tee the output to several outputs simultaneously, but have not learn about &&
May i know what is this && is under ? what should i search to get this && manual ? under OPERATOR ?

Although this cli is wonderful, the unique thing about cli that gui do not have (sometime, depent on the gui designer), but my laptop will auto suspend to ram before timeshift.

I am looking for ways this laptop will auto suspend.
could be screen saver, but i can’t find screen saver in display configuration.
or
power management…
or
screenlock

I have found this option and disabled it;
System Settings > Hardware > Energy Saving > Suspend session (disable this option to disable auto suspend before timeshift finish backup)

but i guess should be there are other settings also have the ability to suspend the laptop before timeshift finish doing its’ job. something like screen saver, but i have not locate it yet.

&& (=logical AND) is used to chain commands together, such that the next command is run if and only if the preceding command exited without errors (or, more accurately, exits with a return code of 0).

Other operators, e. g.:

  • || (=logical OR) is used to chain commands together, such that the next command is run if and only if the preceding command exited with errors (or, more accurately, exits with a return code > 0)
  • & (one &) is used to run the first command in the background and the second in the foreground; both commands run simultaneously
  • ; runs the second command after the first, regardless of the error code

You can combine these of course, e. g.
command1 && command2 ; command3

You can use different kinds of brackets too:

  • ( cmd1 ; cmd2 && ... )
    The following commands will start and run in their own shell.
  • { cmd1 ; cmd2 && ... }
    The following commands will start and run in the same shell.
2 Likes

Could be something KDE specific; can’t help you there, sorry.

It is ok. Thanks.
I am searching for it in google… Just can’t figure out the best relavent search key for it… hence result is limited…

$xset q
Screen Saver:
  prefer blanking:  yes    allow exposures:  yes
  timeout:  0    cycle:  600

Does this means my screensaver is off ?
Where is screensaver ? i can’t find it.

Where is screenlock ?
I can only imaging what else can causes my laptop to go into sleeping in certain time.

I may have a workaround.

  1. To (temporarily prevent your Linux machine from sleeping and suspending, disable the following targets at the systemd level
    sudo systemctl mask sleep.target suspend.target
    Other possible targets are hibernate.target and hybrid-sleep.target.
  2. Create your Timeshift snapshot
    sudo timeshift --create
  3. Re-enable sleep and suspend on your system after Timeshift exited
    sudo systemctl unmask sleep. target suspend.target
  4. Suspend the system
    systemctl suspend

==> One liner to disable suspend, run timeshift, re-enable suspend and finally suspend system:
sudo sh -c 'systemctl mask sleep.target suspend.target ; timeshift --create ; systemctl unmask sleep.target suspend.target ; systemctl suspend'

:sweat_smile: so complicated. lol wow!
there is so much cli can do on linux… that i don’t know where to start and where to stop… !!
I was making note of everything related prevent or make computer shutdown or suspend… so much stuff… :sweat_smile:
I will surely try it . thanks

May i know is it that systemctl is having priority over all other things that causes a laptop to suspend ?
where systemctl do changes ? is it something link *.conf ?

:grimacing: This is all systemd related stuff. Regrettably I also only partly understand some of the things happening :grin:.

You can read up on some of this here for example.

The main command used to introspect and control systemd is systemctl. Some of its uses are examining the system state and managing the system and services.

systemd-suspend.service is a system service that is pulled in by suspend.target and is responsible for the actual system suspend. Note that systemd-suspend.service or systemd-hibernate.service should never be executed directly. Instead, trigger system sleep with a command such as systemctl suspend or systemctl hibernate.

By disabling (“masking”) the targets a symlink to /dev/null is created. From now on all attempts to invoke suspend or hibernate will be sent to /dev/null. Whatever you write to /dev/null will be discarded, forgotten into the void. It’s known as the null device in a UNIX system.

So if systemd is your main system and service manager this should theoretically have priority and keep your system from suspending. You’ll have to test this on your system yourself though.


Btw, you can check the .targets with
systemctl status sleep.target suspend.target hibernate.target hybrid-sleep.target
If you see something like “Loaded: masked (/dev/null; bad)” the service is disabled, otherwise it will show “Loaded: loaded (...”.

@2000

I just tried you single liner command … and it straight away goes into suspend mode. :laughing:
I thought what script is that… does not work…
Than i realized i have a timeshift gui opened… *although it just open and do nothing. apparently that hinder the code from you to run. but since i closed the timeshift gui, it works… all thru cli… :sweat_smile: never experience timeshift in cli before…

Yes, Timeshift only allows one instance to run. Running Timeshift through cli only works if no other instance is active.

You can also list, restore and delete with cli. :wink:

The commands were chained with “;” which runs suspend even if Timeshift fails. This could be optimized … :grin:

something not that right…i never use this cli that you gave me before, hence i have no idea what is happening.

$ sudo sh -c 'systemctl mask sleep.target suspend.target ; timeshift --create ; systemctl unmask sleep.target suspend.target ; systemctl suspend'
Created symlink /etc/systemd/system/sleep.target → /dev/null.
Created symlink /etc/systemd/system/suspend.target → /dev/null.

/dev/sdc is mounted at: /run/timeshift/backup, options: rw,relatime

------------------------------------------------------------------------------
Creating new snapshot...(RSYNC)
Saving to device: /dev/sdc, mounted at path: /run/timeshift/backup
Synching files with rsync...
102.81% complete (00:00:00 remaining)

this status was there for quite sometime already…
so… is the timeshift ended doing it’s job ?
why the command prompt shows over 100% ? and the (00:00:00 remaining) ? it has being in remaining time 0:0:0 for quite sometime already… still there.
I thought it has frozen or ended , but still showing that…
but as i was typing, the % changed to 104.05% with (00:00:00 remaining).

How come it took so long for timeshift to backup ?

Accidentally happened, as i was trying to copy the output of the timeshift. instead of copy, i cancelled it…
hence i restarted the exact same command again… it still not running fast.
for 5 minutes already, but only at 10%… is that consider fast ? for a timeshift that i have just done a couple minutes ago ?