Page 1 of 1

How to set timer to turn off laptop?

Posted: Sun 11 Sep 2011, 10:35
by liatodua
Is it possible in puppy to set poweroff of computer in say 30 minutes when laptop works on batteries? Can not find relevant menu.

Thanks in advance

Posted: Sun 11 Sep 2011, 14:04
by L18L

Posted: Sun 11 Sep 2011, 14:23
by JSonic
Or, if you don't want to install any additional software, you can type in terminal (Roxterm, urxvt...)

Code: Select all

sleep 30m && wmpoweroff &
But if you run this, terminal must be left open.

Posted: Sun 11 Sep 2011, 14:47
by liatodua
I guess I should have explained better:

I am setting up an old nettbook for my grandsun (2,5 years old). He usually forgets to shut down the computer (although I put big shutdown icon on desktop). So the netbook is all time switched on, but sometimes power goes off and the battery can only work for 30 minutes. After that the netbook has sudden blackout. And every time this happens puppy crashes.

Usually other distors have some power management tools where you can request that if laptop works on batteries in some minutes it automatically shuts down. I hoped that if I set up that in that case puppy would not crash.

Is it possible to make the sleep or poweroff commands dependant on whether the laptop works on AC or the batteries? Or is there any other way to prevent puppy from crashing at sudden blackout?

Posted: Sun 11 Sep 2011, 15:48
by aarf
Pwidgets has an app that monitors the battery. It pops up warnings at pre-set battery levels. Perhaps modify the script to poweroff when battery level of say zero is detected. Timer wouldn't be necessary but you could add one if you want.

Posted: Sun 11 Sep 2011, 15:57
by aarf
Choose ext3 for your pupsave and put pfix=fsck into your grub boot kernel line.

Posted: Mon 12 Sep 2011, 16:37
by liatodua
Thanks. Installed pwidgets. Looking now for the script to modify

Posted: Mon 12 Sep 2011, 16:50
by liatodua
Found script of the Battery gauge.. It says:

#! /bin/sh

if [ -d /sys/class/power_supply/BAT0 ]; then BAT='BAT0'; fi
if [ -d /sys/class/power_supply/BAT1 ]; then BAT='BAT1'; fi
if [ -d /sys/class/power_supply/BAT2 ]; then BAT='BAT2'; fi
STATUS="`cat /sys/class/power_supply/$BAT/status`"
CHARGE_FULL="`cat /sys/class/power_supply/$BAT/charge_full`"
CHARGE_NOW="`cat /sys/class/power_supply/$BAT/charge_now`"
CHARGE_PERCENT=$[$CHARGE_NOW*100/$CHARGE_FULL]
if [ $CHARGE_PERCENT -lt 7 ]; then
echo 1
STATUS="`cat /sys/class/power_supply/$BAT/status`"
TMP="`ps`"
if [ $CHARGE_PERCENT -lt 7 ] && [ $STATUS != Charging ] && [ ! "`echo "$TMP" | grep 'WARNING: Battery'`" ]; then
yaf-splash -text "WARNING: Battery are running low!" -margin 2 -bg red -bw 0 -placement top -font "9x15B" -outline 0 &
fi
fi


#find char
TMP="abcdefghijklmnopqrstu"
[[ "$CHARGE_PERCENT" -eq 0 ]] && echo a || echo ${TMP:$(( $CHARGE_PERCENT/5 )):1}


Could you tell me where should I add poweroff?

Posted: Mon 12 Sep 2011, 18:03
by ahoppin
You could replace the line that says

yaf-splash -text "WARNING: Battery are running low!" -margin 2 -bg red -bw 0 -placement top -font "9x15B" -outline 0 &

With the poweroff command.

(And shouldn't that be "Battery IS running low"?) Ah, well.

Posted: Mon 12 Sep 2011, 18:31
by pemasu
Here is the modified version of my laptop-tools. It consists of acpitool, vattery,vattery-ibam-vattery-acpitool,xbindkeys,acpid, ppower, cpu-frequency tray app needed framework, extra Fn + function buttons support like media buttons. You need to use xbindkeys-config to bind the buttons to executables found on your comp or laptop.

What it provides. It provides Vattery-ibam and Vattery-acpitool with needed framework to handle verbose warnings and also executable commands at certain battery state levels.

Check /root/.config/vattery-ibam/config and corresponding vattery-acpitool/config text files how to configure the commands for your needs.

For me...I get verbose warning at battery state level 10 % and suspending to the ram at battery level 5 %.
I have included those config files in the pet.

Also you get those other functionality for laptop or netbook. Like power button should shut down the comp. Laptop or netbook sleep button suspends to the ram, lid closing suspends to the ram.

If something is missing, report. I removed Frisbee and dhcpcd stuff from the pet so I hope I didnt remove anything needed.

Vattery-ibam is sometimes picky. If you dont get new battery icon to the tray after reboot, restart X is not enough to get whole functionality, edit /root/Startup/1vattery script and leave only shebang row and exec vattery-acpitool row. Save and restart X.

Posted: Mon 12 Sep 2011, 18:43
by liatodua
Thanks a lot! I'll try it.

Posted: Tue 13 Sep 2011, 02:34
by liatodua
Probem solved: I Installed pwidgets and changed csript of Battery (at /usr/local/pwidgets/widgets/scripts/Battery

Namely, replaced the text

yaf-splash -text "WARNING: Battery are running low!" -margin 2 -bg red -bw 0 -placement top -font "9x15B" -outline 0 &

with

wmpoweroff

With active pwidget Battery it safely shuts down the computer at critical battery.

Thanks!

And thanks to pemasu - His tool allows shutdown through simply pushing the power button. Very useful! And yes, finally - wireless connection established on Asus eee pc! (which was hopeless from any puppe except from pupeee). Thaanks!!!

Posted: Tue 13 Sep 2011, 09:43
by aarf
note that

Code: Select all

-lt 7
means less than 7%.
depending on the characteristics of your battery you may find something else more suitable. my battery runs at 1% for a long time then at 0% for quite a while.
it also goes under 7% quite quickly. so for me

Code: Select all

-lt 1
would be more convenient. your battery and needs will very likely differ.

Posted: Sun 11 Mar 2012, 16:27
by playdayz
Hi pemasu, I have a dumb question: Is this complete, or does it require some other components of acpi (or anything else) to be already installed? Thank you.

Posted: Sun 11 Mar 2012, 17:34
by pemasu
This provides all stuff. It has stuff for keybindings through xbindkeys-config, acpid demon for acpi, acpitool for suspending in ram, battery monitoring, verbose warning and possibilty to suspend at configured battery percent level or shutdown....the vattery-acpitool and vattery-ibam accepts whatever command. Also there is tray cpu frequency setting tray app and so on...

This pet provides the whole set for Lucid Puppy. I use this stuff in my Lucid builds.
Of course there might be something which needs tuning. I dont remember so accurately if I finetuned the scripts after I posted this pet.

Answer...you get Vattery tray app for verbose warnings and possiblity to execute commands, keybindings for laptop function buttons...might need reconfiguring for Lucid Puppy apps...power button shuts down...Fn + Zz button suspends to ram..ppower tray app gives tray cpu frequency scaling tray app.
It consists of all the needed binaries, /root/Startup scripts and the whole framework of scripts in /etc/acpi/*

Suspend to Ram

Posted: Fri 23 Mar 2012, 06:47
by buzby01
Thanks for ur laptop.pet. I have been struggling to get my pup to sleep since I got her.

One issue though, about every 1 out of 4 times that I put my netbook (Pendo u1000- d425 Atom, Ralink 3090 wireless card) to sleep it doesn't wake up properly. The screen does not turn on nor the wireless card and I can only guess the keyboard aswelll. The only sign of life is a solid LED and the faint noise of the cpu fan. I'm using macpup 5.2.8

Can anyone help me with this and thanks in advance

Posted: Sun 03 Jun 2012, 03:49
by vtpup
Running the laptop pet in Racy 53 I get:

Code: Select all

# acpitool
acpitool: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by acpitool)

Posted: Wed 09 Jan 2013, 07:14
by TwoPuppies
I thought it might be a nice idea to have the low battery warning as it is now, followed subsequently by the auto shutdown at a lower percentage (say 2% or 3%).

I've diddled around with the Pwidgets battery script a bit, and I can get either the warning message or the auto shutdown to work individually, but not both together.

Does anyone know how I might modify the script to get both to work consecutively?