Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 21 Sep 2018, 04:06
All times are UTC - 4
 Forum index » House Training » Beginners Help ( Start Here)
How to set the timer for save2flash?[Solved, can improve]
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [8 Posts]  
Author Message
frenchiveruti

Joined: 15 Feb 2017
Posts: 102

PostPosted: Sun 26 Nov 2017, 15:15    Post subject:  How to set the timer for save2flash?[Solved, can improve]
Subject description: ...using only commands -- Intended for scripting a simple program.
 

JUMP TO SOLUTION: http://www.murga-linux.com/puppy/viewtopic.php?p=975295#975295

Normally I don't have the timer on, but I have a KeyBoard key set to that command so on keypress it issues the save.
Ok, lets say I want to make a script to set the timer for save2flash..
I want the script to do the following:

  1. Set the timer to 30min.
  2. Execute whatever the script executes (in this case a Wine Game called Anno 1503).
  3. On game close, set the timer again to 0 in order to disable save2flash


I already have the "execute" part:
Code:
#!/bin/sh
cd /root/.wine/drive_c/Program\ Files/Anno\ 1503/
wine 1503startup.exe


What I'm missing is the timer command.

Thanks.
I searched in the forums but all answers rely on "puppy event manager" in the menu, and my idea is to make it in the script (see for example the last 2 comments: Here)

Last edited by frenchiveruti on Sun 26 Nov 2017, 17:07; edited 2 times in total
Back to top
View user's profile Send private message 
rufwoof

Joined: 24 Feb 2014
Posts: 2538

PostPosted: Sun 26 Nov 2017, 15:58    Post subject:  

A save occurs when save2flash is run. If you boot with no saves automatically being performed then you could use a simple sleep command within a script prior to the save2flash command and either have that script running or not.

Or something a little more elaborate such as using :
Code:
yad --timeout=1800 --timeout-indicator=top --button="Quit!$HOME/icons/quit.png":1 gtk-cancel:1

instead of sleep (1800 seconds timeout = 30 minutes) as part of a script ... maybe something like a script called xxx.sh
Code:
#!/bin/sh
yad --timeout=1800 --timeout-indicator=top --button="Quit!$HOME/icons/quit.png":1 gtk-cancel:1
ret=$?
[[ $ret -eq 1 ]] && exit 0
save2flash &
xxx.sh &

(or just wrap it in a perpetual while loop). That yad command will show a dialog with a progress bar that declines down to zero

(Ignore the title bar buttons in the attached image, I just wrote and posted that in my OpenBSD session where I have a 'unusual' set of buttons in the windows titlebar)
s.png
 Description   
 Filesize   9.06 KB
 Viewed   136 Time(s)

s.png

Back to top
View user's profile Send private message 
frenchiveruti

Joined: 15 Feb 2017
Posts: 102

PostPosted: Sun 26 Nov 2017, 16:03    Post subject:  

Ok, so on the IRC of puppy some users pointed out to the file named "/etc/eventmanager" where the line "RAMSAVEINTERVAL=0" needs to be edited in order to set the timer I want.
The thing is, I know less than 0 in file editing commands, but that would solve the problem whit the "overlapping" save2flash commands running, as it will be dictated by the eventmanager script itself..
Does someone know how to edit the line?
Back to top
View user's profile Send private message 
frenchiveruti

Joined: 15 Feb 2017
Posts: 102

PostPosted: Sun 26 Nov 2017, 16:11    Post subject:  

Also, the evenmanager GUI uses this:
https://github.com/puppylinux-woof-CE/woof-CE/blob/testing/woof-code/rootfs-skeleton/usr/sbin/eventmanager#L382
To edit the line in question. If I understood this enough, I can do something like:
Code:
CONFIG="`cat /etc/eventmanager`"

rsPATTERN="s/^RAMSAVEINTERVAL=.*/RAMSAVEINTERVAL=${NEWRAMSAVEINTERVAL}/"
CONFIG="`echo "$CONFIG" | sed -e "$rsPATTERN"`"

echo "$CONFIG" > /etc/eventmanager


Replacing "${NEWRAMSAVEINTERVAL}" with 30 when the script starts, and then 0 when it finishes.
Right?
Back to top
View user's profile Send private message 
frenchiveruti

Joined: 15 Feb 2017
Posts: 102

PostPosted: Sun 26 Nov 2017, 16:55    Post subject:  

Ok guys thanks to KuLuSz and well, some minor testing with "sed" (very dangerous if used badly) without any puppies killed I managed to come out with those two lines of code:
Code:

sed -e s/^RAMSAVEINTERVAL=.*/RAMSAVEINTERVAL=30/ /etc/eventmanager > /etc/TEMP && mv -f /etc/TEMP /etc/eventmanager

#This one is for setting up the timer to 30 min.


Code:

sed -e s/^RAMSAVEINTERVAL=.*/RAMSAVEINTERVAL=0/ /etc/eventmanager > /etc/TEMP && mv -f /etc/TEMP /etc/eventmanager

#This one is for setting up the timer to 0 min, disabling the save2flash timer.


What they do is "search" in "eventmanager" file, edit the line in question to 0 or 30 min and then running a simple move command replacing the original file.[/code]
Back to top
View user's profile Send private message 
rufwoof

Joined: 24 Feb 2014
Posts: 2538

PostPosted: Mon 27 Nov 2017, 02:10    Post subject:  

Puppy's tend to have a menu/control option to set that somewhere via the gui interface. Usually something like "Menu->System->Puppy Event Manager->save session->save Interval"
Back to top
View user's profile Send private message 
phat7

Joined: 05 Jun 2015
Posts: 115

PostPosted: Mon 27 Nov 2017, 03:05    Post subject: Re: [SLVD][CAN IMPROVE] How to set the timer for save2flash...
Subject description: ...using only commands -- Intended for scripting a simple program.
 

frenchiveruti wrote:
Ok, lets say I want to make a script to set the timer for save2flash..
I want the script to do the following:

  1. Set the timer to 30min.
  2. Execute whatever the script executes (in this case a Wine Game called Anno 1503).
  3. On game close, set the timer again to 0 in order to disable save2flash

Does this make sense? If you play for 25 minutes nothing will be saved and if you play 59 min the last 29 min will not be saved. Why not keep RAMSAVEINTERVAL at 0? You can force a save2flash after finishing the game. In script run save2flash after wine 1503startup.exe.
Back to top
View user's profile Send private message 
frenchiveruti

Joined: 15 Feb 2017
Posts: 102

PostPosted: Mon 27 Nov 2017, 06:05    Post subject:  

Yeah sure until you are in the middle of the game and power goes out.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [8 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Beginners Help ( Start Here)
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1219s ][ Queries: 12 (0.0159s) ][ GZIP on ]