Tiny Core Linux
Tiny Core Base => TCB Talk => Topic started by: cast-fish on December 10, 2014, 08:23:53 PM
-
Hello,
do you know any code snippet for TCL that will make the laptop switch OFF
if there is no video movement or mouse/keys interaction.?
For example
1) If there is no movement on the screen or mouse/keys activity for over 5 mins
shut down or hibernate this laptop. (what's the code snipper for that?)
2) Or just a hard command such as "shut down or hibernate this laptop 3 hours from now"
what's the code snippet for that?
thanks
V
-
Hi cast-fish
2) Or just a hard command such as "shut down or hibernate this laptop 3 hours from now"
what's the code snippet for that?
How about:
#!/bin/sh
#Number of seconds to wait before power off
DELAY=10800
sleep $DELAY
sudo poweroff
-
From busybox's website, it seems that that their power, reboot and halt commands already have a '-d SEC Delay interval' similar to the shutdown command used in other GNU/Linux systems... I've never tried it though, so I don't know..
There's also a $TMOUT built-in variable that I know of that's in bash which automatically logs the user out after a set period of inactivity from the current terminal. I don't know if something similar exists in ash. But it seems like you need something more for GUI...
-
Hello there and thanks for you reply..
Well it seemed to me to be just a scase of "scheduling a task" to do shutdown.
The web contained all the info to use "crontab" task scheduler and which line
of text and command to use......TCL also had it's cron daemon running....but
all of this still didn't work.
Something must have been wrong with my pointing the cron task to the "s2ram"
program. TCL and Cron certainly recognised that i was trying to do something but it
didnt work.
...in theory "crontab" is extremely simple to use so it's a bit
dissheartening to not get that working...
will have a try with your reply....and thanks
V
-
Rich,
many thanks to you indeed.
Your shell script for shutdown is working. It is really simple isn't it.
thanks
V
-
Hello,
Been continuing to look at what i imagined would be a readily available
and simple Linux command to "shutdown on idle" a Linux box.
Idle meaning no real screen activity or user interaction.
There are lots of web pages, but i am yet to see a global simple
command to do this....such as Bash or busybox or real simple shell script.
"5 mins has passed, there's nothing happening on this Linux box, shut it down, or hibernate it"
V
-
Try taking a look at ACPI, (I think that might be what you are looking for).
http://www.acpi.info/
Edit: Also may apply - http://www.uefi.org/specsandtesttools
-
hi friends,
i use following command-line in my ~/.xsession or ~/.xinitrc
xautolock -detectsleep -time 8 -locker "/usr/local/bin/dorm" &
/usr/local/bin/dorm
#!/bin/sh
sleep 1
vt='/usr/bin/fgconsole'
### i had to remove my sound-modules before the suspend-to-ram
sudo rmmod oss_ich
sudo rmmod oss_usb
sudo rmmod oss_hdaudio
sudo rmmod osscore
sudo s2ram --force --vbe_save
/usr/bin/chvt $vt
sleep 1
### and to reload the sound-modules after the suspend-to-ram
sudo modprobe osscore
sudo modprobe oss_hdaudio
sudo modprobe oss_usb
sudo modprobe oss_ich
as an alternative you could choose "sudo shutdown -h now" under normal conditions, but with busybox you probably need something like "sudo poweroff", instead of my suspend-to-ram-script.
it worked flawless until 4.7.7, but later suspend-to-ram was broken for my configuration and my hardware-setup :(
-
hello,,,
can you help me with trying to POWER DOWN or suspend an idle Linux box.
(idle meaning no real GUI activity mouse or keys)
I have found a command that is able to watch an "already started process" for a WHILE
......and then suspend the computer if the process stops....
so my idea is to use the existing tinycore screensaver....to then trigger a suspend...
THerfore my questions are......
1).what is the name of the "already running screensaver daemon"?....or what's its regular PID?....is it the same PID each time?
2) alternatively...is there some new "process" which is started when the screensaver kicks in? and what's the name of it...... or is there some process which is stopped like Xvesa?.... do either have a name or regular same PID?
with this info above i could somehow tailor that command to then "suspend" the computer
when the screensaver kicks in...
i set the screensaver to 3 mins usually
xset s 180
here is the info below...
------------------------------------------------------------------------------------------------------------------------------------
If you want to monitor an already started process, you can do this in a shell :
# while pgrep &>/dev/null -f process_name; do sleep 60; done; sudo s2ram -f
process_name is where you fill it in....
thanks
V
-
No, the X server's screen saver does not spawn or close any process, nor can it send an event for you to wait for, it has no code for that. Try netnomad's solution.
-
Curaga,
what is the timing amount on netnomads code?
when does it actually suspend?
also HOW is that code starting off?....automatically at boot?...
i am unsure how to do that....
V
-
Hi cast-fish
Here is a script that will check the status of the monitor every 30 seconds. Within 30 seconds of the monitor going blank the computer
will execute the shutdown command.
Create a file called AutoOff.sh
#!/bin/sh
# Check if screen is off every DELAY seconds
DELAY=30
# Loop until the screen is off
while `xset -q | grep -q "Monitor is On"`
do
sleep $DELAY
done
# Shut down the computer
sudo poweroff
If you place it in /home/tc/.local/bin/ it will be part of your backup and added to the path.
Create a file in /home/tc/.X.d containing
AutoOff.sh &
This will automatically start the script once the desktop appears.
-
Hello,
Rich, uh....this script does not work.
Having correctly followed your initial instructions and made the script file..... the last step involved creating a file at the location you stated...the file is called....AutoOff.sh.....and has the contents "AutoOff.sh &" minus qoutes.
All permissions were changed on the created files.....so they could be used.
On a virgin fresh TCL 4.3.1 boot..... from CD with a persistant TCE...
the computer just seems to boot to the desktop and immediately power off. No screensavers are ever
considered..... or a 30 second wait.
it is xvesa here
when looking at "xset -q" command....there does not seem to be any arguments like "monitor is on" or flags of that nature for the properties of x.
also Rich....all of the same stuff above was tried on a fresh frugal HDD install of tcl 4.3.1(with persistent tce)....same results as above apply...
did you test this stuff
V
-
managed to get an idle linux box to "suspend" by using similar answer to Netnomad above.
$ xautolock -time 5 -locker /mnt/sda5/./shutdown
if the above command is entered...it seems to watch the Linux computer and
as soon as there is no keys or mouse or GUI activity it shuts down the machine
5 mins later...by pointing to Rich's shutdown script
interestingly, on a RAW boot of TCL 4.3.1 from CD.....the "xautolock" extension does not work.
However, on this 4.3.1 HDD system here...many other apps are installed ......and "xautoclock" must
be finding the missing dep that it needs....
so the repo must be wrong on 4.3.1
thanks a lot....saves energy here.
V
-
Hi cast-fish
did you test this stuff
Yes I did. When I run xset -q I get:
tc@box:~$ xset -q
Keyboard Control:
auto repeat: on key click percent: 0 LED mask: 00000002
XKB indicators:
00: Caps Lock: off 01: Num Lock: on 02: Scroll Lock: off
03: Shift Lock: off 04: Group 2: off 05: Mouse Keys: off
auto repeat delay: 660 repeat rate: 25
auto repeating keys: 00ffffffdffffbbf
fadfffdfffdfe5ef
ffffffffffffffff
ffffffffffffffff
bell percent: 50 bell pitch: 400 bell duration: 100
Pointer Control:
acceleration: 2/1 threshold: 4
Screen Saver:
prefer blanking: yes allow exposures: yes
timeout: 600 cycle: 600
Colors:
default colormap: 0x20 BlackPixel: 0 WhitePixel: 16777215
Font Path:
/usr/local/lib/X11/fonts/misc/,/usr/local/lib/X11/fonts/TTF/,/usr/local/lib/X11/fonts/Type1/,/usr/local/lib/X11/fonts/75dpi/,built-ins
DPMS (Energy Star):
Standby: 600 Suspend: 600 Off: 600
DPMS is Enabled
Monitor is On
tc@box:~$
Maybe it's because I'm running Xorg and not Xvesa.
-
Yeah, the old Xvesa does not support DPMS. Xorg does, and the new Xvesa has partial support, but I don't think the tinyx versions are yet deployed.
-
yes Rich and Curaga...this could be the case with xvesa cos you don't get the same outputs
when run here on Xvesa
thanks anyway with the scripts and solution....
happy chrx
V