You are not logged in.

#1 2017-03-21 23:26:13

DeletedUser211004
Member
Registered: 2017-03-20
Posts: 20

Suspend after a selected timeperiod

I would like my notebook to suspend after a selected time for example after 30 minutes.

I am not using any DE.
Just slim i3 DWM - it's cool and clean.


how do i do this in Arch?

Last edited by DeletedUser211004 (2017-03-21 23:55:16)

Offline

#2 2017-03-21 23:47:35

Lemongrass
Member
From: Central Europe
Registered: 2017-03-03
Posts: 59

Re: Suspend after a selected timeperiod

Theres a Power Manager in Xfce's settings. I don't now about other DE's such thing, but there must be something.

Such a thing will be good for you, I guess.

Last edited by Lemongrass (2017-03-21 23:47:57)

Offline

#3 2017-03-22 15:37:58

teckk
Member
Registered: 2013-02-21
Posts: 519

Re: Suspend after a selected timeperiod

Do you mean regardless of activity?

sleep 1800 && systemctl suspend

Or on event
https://wiki.archlinux.org/index.php/Power_Management

Look at
community/xautolock

and read

/etc/systemd/logind.conf

Offline

#4 2017-03-22 17:31:57

DeletedUser211004
Member
Registered: 2017-03-20
Posts: 20

Re: Suspend after a selected timeperiod

I mean that when im not doing any activity after 30 minutes the notebook should suspend

and after wake up i want my lockscreen first.

Just like in Windows 10 for example.

Offline

#5 2017-03-22 22:37:53

Lemongrass
Member
From: Central Europe
Registered: 2017-03-03
Posts: 59

Re: Suspend after a selected timeperiod

Which desktop environment do you have? Have you checked its power manager-like utility? It's just as easy to set in Xfce as in Windows. I don't have another DE now, so I can't tell about others, but I guess it's just as easy with them too. Look for something like this in the menu of your desktop environment (graphical menu, settings, just like Windows' Start button).

Last edited by Lemongrass (2017-03-22 22:39:29)

Offline

#6 2017-03-23 02:36:01

monodromy
Member
Registered: 2014-02-08
Posts: 62

Re: Suspend after a selected timeperiod

X has a built-in way of doing this, DPMS. It's always worked out of the box for me. For screen lockers, see here. i3lock, for example, works with DPMS (according to the wiki; I don't use a screen locker).

Last edited by monodromy (2017-03-23 02:38:20)

Offline

#7 2017-03-23 04:57:55

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,433

Re: Suspend after a selected timeperiod

As mentioned by teckk, look at the /etc/systemd/logind.conf

You need to uncomment and change one line

 IdleAction=suspend

, IdleActionSec already defaults to 30min

Offline

#8 2017-03-23 05:01:02

frank604
Member
From: BC, Canada
Registered: 2011-04-20
Posts: 1,212

Re: Suspend after a selected timeperiod

I use xautolock, which checks for idleness and fires up programs.  I have mine setup to notify-send me a warning, then locks screen (something like i3lock), then suspends.

Offline

#9 2017-03-23 05:03:48

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,433

Re: Suspend after a selected timeperiod

Why everyone is firing with various ways to lock the screen, while Archer98 is trying to suspend his laptop??

Offline

#10 2017-03-23 05:34:18

HiImTye
Member
From: Halifax, NS, Canada
Registered: 2012-05-09
Posts: 1,072

Re: Suspend after a selected timeperiod

Docbroke wrote:

Why everyone is firing with various ways to lock the screen, while Archer98 is trying to suspend his laptop??

xautolock specifically allows you to specify the locker to run when it triggers, allowing you to use a bash script to run some arbitrary commands instead of using just a locker. I'm sure others do the same. this allows me, for instance, to use scrot and imagemagick to blur the screen before using i3lock to display it, or someone to lock their screen and suspend. it isn't an avoidance of the question, just suggestions on how to achieve the question.

another alternative is to use xset/DPMS to suspend. this would be an alternative to using a locker, if all you want to achieve is a suspend without invoking a lock screen, to quickly recover from

Last edited by HiImTye (2017-03-23 05:34:31)

Offline

#11 2017-03-23 05:54:00

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,433

Re: Suspend after a selected timeperiod

1. True, I was unaware of ability of xautolock to run scripts.
2. xset/DPMS suspend is not like systemctl suspend, it just suspends the display. http://webpages.charter.net/dperr/dpms.htm

Offline

#12 2017-03-23 06:23:19

HiImTye
Member
From: Halifax, NS, Canada
Registered: 2012-05-09
Posts: 1,072

Re: Suspend after a selected timeperiod

Docbroke wrote:

2. xset/DPMS suspend is not like systemctl suspend, it just suspends the display. http://webpages.charter.net/dperr/dpms.htm

right, my mistake. I've never used xset much, except to disable screen blanking because it's annoying lol

Offline

#13 2017-03-24 16:11:18

DeletedUser211004
Member
Registered: 2017-03-20
Posts: 20

Re: Suspend after a selected timeperiod

I tried it with the logind.conf worked fine first.

Then I noticed that it also suspends even if I'm working on my machine. So the "idle detection" is pretty much crap.

So now i tried it with xautolock and the suspend+xautolock command is working alone

but what i want in my .config/i3/config is:

exec xautolock -time 15 -locker ~/.lock.sh &
exec xautolock -time 30 -locker "systemctl suspend" & 

but this doesn't work like i want it to.

what is wrong?

Last edited by DeletedUser211004 (2017-03-24 20:39:25)

Offline

#14 2017-03-25 15:52:27

seth
Member
Registered: 2012-09-03
Posts: 50,957

Re: Suspend after a selected timeperiod

that lock.sh most likely grabs the X server and the second xautolock thus starts to fail.
you want to start the locker (i3lock?) wait 15 seconds and if the locker process is still running, STR

Offline

#15 2017-03-25 19:02:59

DeletedUser211004
Member
Registered: 2017-03-20
Posts: 20

Re: Suspend after a selected timeperiod

my lock.sh contains:

#!/bin/bash
scrot /tmp/screenshot.png
convert /tmp/screenshot.png -blur 0x5 /tmp/screenshot.png
i3lock -i /tmp/screenshot.png
rm screenshot.png

Offline

#16 2017-03-25 20:39:26

seth
Member
Registered: 2012-09-03
Posts: 50,957

Re: Suspend after a selected timeperiod

yes, and i3lock will grab all input devices (as will any reasonable screenlocker) so follow the approach suggested in comment #14:  fork i3lock, sleep 15 seconds and then check whether i3lock is still running to decide whether to STR or not.

Offline

#17 2017-03-25 21:33:18

DeletedUser211004
Member
Registered: 2017-03-20
Posts: 20

Re: Suspend after a selected timeperiod

with fork you mean i should modify i3lock to my suggested needs?

what is STR?
sorry i don't know this abbreviation

Offline

#18 2017-03-25 21:58:27

seth
Member
Registered: 2012-09-03
Posts: 50,957

Re: Suspend after a selected timeperiod

Archer98 wrote:

with fork you mean i should modify i3lock to my suggested needs?

No, certainly not...

#!/bin/bash
convert x:root -blur 0x5 /tmp/i3lock_screenshot.png # convert can get the screen itself, no need for conversions and disk access
i3lock -n -u -i /tmp/i3lock_screenshot.png & # the ampersand forks the process in bash syntax
LOCKER_PID=$! # the PID of the i3lock process you just forked
sleep 15 # wait 15 seconds
kill -0 $LOCKER_PID && systemctl suspend # test whether the i3lock process is still alive and only then STR
rm /tmp/i3lock_screenshot.png # tidy up the proper file ...
Archer98 wrote:

what is STR?

Suspend To Ram

Offline

#19 2017-03-25 23:21:09

DeletedUser211004
Member
Registered: 2017-03-20
Posts: 20

Re: Suspend after a selected timeperiod

thanks for your efforts on the code.

but the code doesn't work correctly

i3lock doesn't show up correctly anymore after waking up from suspension

what i want were 2 processes means one locks after 15 min and 15 min after that one that suspends my machine

Offline

#20 2017-03-26 05:24:08

seth
Member
Registered: 2012-09-03
Posts: 50,957

Re: Suspend after a selected timeperiod

What do you mean "after waking up from suspension"? Invisible or the process is gone?
If it's just "invisible" that's not related to the script, but maybe your framebuffer driver, try w/o the background image first.

what i want were 2 processes

As explained, it won't work that way.

and 15 min after that one that suspends my machine

Just adjust the sleep timer? (hint: "man sleep" before using a calculator ...)

Offline

#21 2017-03-26 11:58:26

DeletedUser211004
Member
Registered: 2017-03-20
Posts: 20

Re: Suspend after a selected timeperiod

i3lock usually shows an indicator when you type in the password.
this doesn't happen because of the kill command for the i3lock process - seems logical!

but if i adjust the sleep time, do i then have the possibility to "come back from afk" between minute 15 and minute 30 after inactivity
without having a suspended notebook?

Offline

#22 2017-03-26 14:13:35

seth
Member
Registered: 2012-09-03
Posts: 50,957

Re: Suspend after a selected timeperiod

The indicator is absent because of "-u" .... so please answer my question in how far "i3lock doesn't show up correctly anymore"
The "kill" command doesn't *kill* anything, "-0" is NOOP and can eg. be used to test PID existence (and instead of inspecting /proc/$PID is actually portable to other UNIX)

And yes; the ability to "come back" is the purpose of this script, the PID existence test and everything...


Side-topic:
Do you really use archlinux and since when do you use linux (or any POSIX system) at all?

If the answer is "yes and last week" you'll have a hard couple of days ahead where you got to learn fast - or die.
First things to learn are how to google, where the arch wiki is, how to use manpages and how to read the "--help" output of commands.
Second thing is to find a "how to bash for dummies" crash course and walk through that so you know at least the bear [sic! ;-)] necessities.

Archlinux is not for beginners and this kind of hand-holding could possibly get me banned from the forum  ...

Offline

#23 2017-03-26 20:02:01

DeletedUser211004
Member
Registered: 2017-03-20
Posts: 20

Re: Suspend after a selected timeperiod

if you got a problem with my questions then gtfo.

didn't knew that reading is that hard... hmm
topic is called N - E - W - B - I - E     C - O - R - N - E - R wink

it's not a must to answer me.
i am not that professional about arch but why should i die? is this a death threat?

seth wrote:

where you got to learn fast - or die

seth wrote:

First things to learn are how to google, where the arch wiki is

how do you think i got here???

seth wrote:

could possibly get me banned from the forum  ...

i hope you get... wink

Offline

#24 2017-03-26 20:13:10

seth
Member
Registered: 2012-09-03
Posts: 50,957

Re: Suspend after a selected timeperiod

no, it's metaphorical - and being a newbie doesn't mean you're not supposed to work on your own, please read the sticky on this.

You're apparently dealing w/ a copy pasted i3lock script that you do not understand the least and you refuse (again) to answer even clear questions regarding your problem but instead perhaps make false statements based upon apparently completely uninformed guesses - this makes it very hard to help (let alone "assist") you.

Please do your homework and ensure to not let this thread drift off-topic (to prevent it from being closed)

So last chance: how much of the process here do you understand and how do you determine i3lock ain't running after resuming from STR? (ie. is there still a process, but no window or was that assumption wrong to begin with? - Is there any problem left?)

Offline

#25 2017-03-26 20:25:02

DeletedUser211004
Member
Registered: 2017-03-20
Posts: 20

Re: Suspend after a selected timeperiod

i quite understand the script so don't think you could guess what i know and understand and what i do not!

all i want was a quick solution that fits my wishes so the problem was just that i3lock didn't showed up correctly so now i deleted the -u option and it works fine.

to be honest i'm very thankful for your quick and good help anyway you turned unfriendly and offensive.

no after i locked back in from suspending there is no i3lock process left.
so i think now everything works fine.

Last edited by DeletedUser211004 (2017-03-26 20:26:41)

Offline

Board footer

Powered by FluxBB