How to set timer to turn off laptop?

Using applications, configuring, problems
Post Reply
Message
Author
liatodua
Posts: 26
Joined: Thu 25 Aug 2011, 15:38

How to set timer to turn off laptop?

#1 Post 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

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

#2 Post by L18L »


User avatar
JSonic
Posts: 37
Joined: Sun 21 Aug 2011, 17:59
Location: Finland

#3 Post 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.

liatodua
Posts: 26
Joined: Thu 25 Aug 2011, 15:38

#4 Post 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?

aarf

#5 Post 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.

aarf

#6 Post by aarf »

Choose ext3 for your pupsave and put pfix=fsck into your grub boot kernel line.

liatodua
Posts: 26
Joined: Thu 25 Aug 2011, 15:38

#7 Post by liatodua »

Thanks. Installed pwidgets. Looking now for the script to modify

liatodua
Posts: 26
Joined: Thu 25 Aug 2011, 15:38

#8 Post 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?

ahoppin
Posts: 172
Joined: Mon 16 May 2011, 04:13

#9 Post 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.

User avatar
pemasu
Posts: 5474
Joined: Wed 08 Jul 2009, 12:26
Location: Finland

#10 Post 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.
Attachments
laptop-acpi-battery-tools-0.0.1.pet
(161.21 KiB) Downloaded 999 times
Last edited by pemasu on Mon 12 Sep 2011, 18:58, edited 2 times in total.

liatodua
Posts: 26
Joined: Thu 25 Aug 2011, 15:38

#11 Post by liatodua »

Thanks a lot! I'll try it.

liatodua
Posts: 26
Joined: Thu 25 Aug 2011, 15:38

#12 Post 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!!!

aarf

#13 Post 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.

User avatar
playdayz
Posts: 3799
Joined: Fri 25 Apr 2008, 18:57

#14 Post 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.

User avatar
pemasu
Posts: 5474
Joined: Wed 08 Jul 2009, 12:26
Location: Finland

#15 Post 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/*

buzby01
Posts: 15
Joined: Sun 11 Mar 2012, 06:27

Suspend to Ram

#16 Post 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

User avatar
vtpup
Posts: 1420
Joined: Thu 16 Oct 2008, 01:42
Location: Republic of Vermont
Contact:

#17 Post 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)
[color=darkblue]Acer Aspire 5349-2635 laptop Tahrpup.[/color]
[color=blue]Acer R11 and C720 Chromebks Bionicpup64[/color]
[color=olive]Acer Iconia A1-830 tablet no pup[/color]
[color=orange]www.sredmond.com[/color]

User avatar
TwoPuppies
Posts: 77
Joined: Wed 29 Dec 2010, 05:13
Location: Melbourne, Australia

#18 Post 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?
[color=#006699]What you really need is two puppies:
Puppy Linux, and the sort with four legs and a tail.[/color]

Post Reply