Countdown to Action - GUI timer

Miscellaneous tools
Post Reply
Message
Author
stu90

Countdown to Action - GUI timer

#1 Post by stu90 »

[Admin note: the posts in this thread were moved from this thread.]
Hi L18L,
Sorry for not replying sooner :oops:

I got side tracked with another little yad project 'Countdown to Action' (circumstance permitting your input would be greatly appreciated)

No biggie with the font selection - your original fc-list update has been working ok for me. - i think urxvtset has turned out pretty sweet considering it was only a few input boxes to start with. :)

thanks for help.
Attachments
countdown.gz
(770 Bytes) Downloaded 613 times
Last edited by stu90 on Mon 20 Jun 2011, 16:37, edited 1 time in total.

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

Countdown to Action

#2 Post by L18L »

Hi stu90
you wrote:I got side tracked with another little yad project 'Countdown to Action' (circumstance permitting your input would be greatly appreciated)
I have installed 'Countdown to Action' and at first run I had some problems.

Code: Select all

# ./cou*
Countdown: 0,000000 minutes
Execute: urxvt 
rxvt: unable to calculate font width for 'Dingbats:style=Regular:pixelsize=16:minspace=True', ignoring.
rxvt: unable to load base fontset, please specify a valid one using -fn, aborting.
#
Having changed the font to Fixed Bold it was OK.
So I am thinking there is a bug with Dingbats.
Or why is it rxvt instead of urxvt???

What input are you expecting?
-Date?
-Drag and drop for Execute?
-Editable Combobox ?
-Passing the task to cronjob?
Everything seems to be possible.

Cheers

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

Countdown to Action

#3 Post by L18L »

v 0.2

Code: Select all

#!/bin/bash

TITLE="Countdown To Action"
VERSION="0.2"
ICON="/usr/share/pixmaps/yad.png"
TEXT="<b>Enter Time \nto countdown\nbefore Action. </b> "
TIME=`date +%H:%M`
DATE=`date +%Y-%m-%d`


 ### GUI countdown - action ###
 
  COUNTDOWN=$(yad --title="$TITLE $VERSION" --text="$TEXT" --image=/usr/share/pixmaps/away.png \
 --form --separator=" " \
 --field="Minutes":NUM "0!0..59" \
 --field="Hours":NUM "0!0..23" \
 --field="Action" "urxvt" )

echo $COUNTDOWN
  if [ "$COUNTDOWN" = "" ];then
  echo "Exiting" && exit
  else
  ## get minutes ##
  MINS=`echo $COUNTDOWN | cut -d" " -f1 | cut -d "." -f1 | cut -d "," -f1`
  echo "Countdown: $MINS minutes"

  ## get hours ##
  HOURS=`echo $COUNTDOWN | cut -d" " -f2 | cut -d "." -f1 | cut -d "," -f1`
  echo "Countdown: $HOURS hours"

  ## get new action ##
#  SETACTION=`echo $COUNTDOWN | cut -d" " -f2-` 
  SETACTION=`echo $COUNTDOWN | cut -d" " -f 3` 
  [[ ! "$SETACTION" ]] && yad --title="$TITLE Info" --text=" Make sure to add an Action to perform " && echo "Exiting" && exit 
  echo "Execute: $SETACTION "
  
  TIMER=`echo $(($MINS*60))`
  
  ASTART=`date | cut -d" " -f-4`
  
  exec 3> >(yad --notification  --image="$ICON" --listen)
  echo tooltip: "Countdown action will be performed in $MINS minutes time from <b>$ASTART</b> " >&3
  sleep $TIMER
  exec 3>&-

 ### 10 seconds to cancel action ###
(
	echo "99" ; sleep 1
	echo "90" ; sleep 1
	echo "80" ; sleep 1
	echo "70" ; sleep 1
	echo "60" ; sleep 1
	echo "50" ; sleep 1
	echo "40" ; sleep 1
	echo "30" ; sleep 1
	echo "20" ; sleep 1
	echo "10" ; sleep 1 ) |
#  yad --progress --title="$TITLE $VERSION" --text=" Your action will executed in 10 seconds.\n <b>To abort click cancel!</b> " \
#  --percentage=0 --auto-close --auto-kill 
  yad --progress --title="$TITLE $VERSION" --text=" Your action will executed in 10 seconds.\n To abort click cancel! " \
  --percentage=0 --auto-close --auto-kill 
  if [ "$?" = -1 ] ; then
  yad --error --text=" Aborted by user! "
  fi
  ### action to execute ###
  echo $SETACTION startet.
  time eval $SETACTION
  
fi
exit
Attachments
count_action.png
-
(9.29 KiB) Downloaded 1977 times

stu90

Re: Countdown to Action

#4 Post by stu90 »

L18L wrote:v 0.2
Hi L18L,
Great update on Countdown to Action - perhaps we should start a new thread for this application?

My own need for it is to turn off my laptop when downloading torrents so as not to use up all my internet allowance.

I already though of another idea though as a PC/internet timer for parents - probably won't fool any of the older more savy kids who could kill its process but should work ok for younger kids with timedown progress window set to no buttons and borderless to stop them from canceling it. :)

thanks.

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

Re: Countdown to Action

#5 Post by L18L »

Hi stu90,
you wrote:My own need for it is to turn off my laptop when downloading torrents so as not to use up all my internet allowance.

I already though of another idea though as a PC/internet timer for parents - probably won't fool any of the older more savy kids who could kill its process but should work ok for younger kids with timedown progress window set to no buttons and borderless to stop them from canceling it. :)
why not just

Code: Select all

wget http://....... && shutdown
timer,
there is /usr/local/pschedule
parents,
kid should use wary112 (unprivileged user fido)

Sorry, I do not see a reason to reinvent these wheels at the moment. :wink:

stu90

Re: Countdown to Action

#6 Post by stu90 »

L18L wrote:Hi stu90,
you wrote:My own need for it is to turn off my laptop when downloading torrents so as not to use up all my internet allowance.

I already though of another idea though as a PC/internet timer for parents - probably won't fool any of the older more savy kids who could kill its process but should work ok for younger kids with timedown progress window set to no buttons and borderless to stop them from canceling it. :)
why not just

Code: Select all

wget http://....... && shutdown
timer,
there is /usr/local/pschedule
parents,
kid should use wary112 (unprivileged user fido)

Sorry, I do not see a reason to reinvent these wheels at the moment. :wink:
You can use wget to download torrent files - i was unaware of this :?:

Yes running as fido would be best to stop any mishaps but Lucid puppy and most all the earlier puppies do not have this option :(

Sure most things have been done before - but i don't see it as reinventing the wheel - merely more choice, with the added bonus of of having some fun and hopefully learning something along the way 8)

cheers.

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

Re: Countdown to Action

#7 Post by L18L »

stu90 wrote: added bonus of of having some fun and hopefully learning something along the way 8).
Bingo
If you start a new thread I will join :)

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

Countdown to Action

#8 Post by vovchik »

Dear L18L,

Countdown to Action is a great little utility. I would only make one slight change to line 32. As written, the input field does not accept arguments. In order for parameters to be passed, line 32 should look like this:

Code: Select all

SETACTION=`echo $COUNTDOWN | cut -d" " -f 3-`
I just added a "-" after 'cut -d" " -f ', which means cut takes all fields starting with f3. Thanks for the utility.

With kind regards,
vovchik

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

Re: Countdown to Action

#9 Post by L18L »

vovchik wrote:...
I just added a "-" after 'cut -d" " -f ', which means cut takes all fields starting with f3. Thanks for the utility.
...
Learning from each other is fun.
Thank you very much for the - (Minus) :)

The credits go to stu90.
I have just added the field HOUR and ranges for the numeric fields.

Code: Select all

man yad
8)

stu90

#10 Post by stu90 »

This is a little Yad application to perform a simple countdown for x minutes or hours then perform a user defined action or string of actions, such as shutdown puppy (wmpoweroff) or play a media file etc.

When you set a countdown action there will be an icon in the system tray as a reminder - 10 second before the countdown action is performed a little gui window will open alerting you an action is to be performed in 10 seconds and giving the option to cancel the action if you wish.

urxvt in the action field is not needed to run an action, it is just there as an example.

Image

Dependencies:
Countdown to Action requires Yad-0.12.2 to be installed - download is available on this link:
http://www.murga-linux.com/puppy/viewto ... 533#536533

Tested on Lucid Puppy.

Thanks.
Attachments
countdown-0.3.pet
(5.28 KiB) Downloaded 569 times

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

c2a

#11 Post by vovchik »

Sorry Stu,

I guess my thanks should have been addressed mainly to you :) In any case, the utility is useful, and collaboration is always nice to see. To make this app even more complete, you might consider adding a launch at hh:mm and a file select button for the action that would update the input box.

With kind regards,
vovchik

PS. I use this icon for the GUI. It's a bit big, but I like it.
Attachments
clock4.png
(61.46 KiB) Downloaded 1972 times

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

Countdown

#12 Post by L18L »

An additional combobox for choosing from /usr/share/applications.
The checkbox decides where to take the action from.
The input field which I have renamed to "Command" has to be at last position because it can contain more than 1 string.

Writing this down I have got the idea taking another separator than blank that this condition would exist no more.

Code: Select all

#!/bin/bash 

 ## Stu90 ## L18L ##
 ## Countdown to Action ##
 ## editable command or combobox v3a
 
 TITLE="Countdown To Action" 
 VERSION="0.3a" 
 ICON="/usr/share/pixmaps/c2a.png" 
 TEXT="<b>Enter Time to countdown \nbefore\nAction or Command. </b> " 
 TIME=`date +%H:%M.%P` 
 DATE=`date +%d-%m-%Y` 


  ### GUI countdown - action ### 
  COUNTDOWN=$( yad --title="$TITLE $VERSION" --text="$TEXT" --form --separator=" " --image="$ICON" \
--field="Minutes":NUM "0!0..59" \
--field="Hours":NUM "0!0..23" \
--field="Action":CB "`ls /usr/share/applications | tr '\n' '!' | sed s/.desktop//g `" \
--field="Ignore Command":CHK TRUE \
--field="Command" "urxvt" \
)

   echo $COUNTDOWN 
   if [ "$COUNTDOWN" = "" ];then 
   echo "Exiting" && exit 
   else 
  
   ## get minutes ## 
   MINS=`echo $COUNTDOWN | cut -d" " -f1 | cut -d "." -f1 | cut -d "," -f1` 
   echo "Countdown: $MINS minutes" 
   ## countdown minutes ##
   TIMERM=`echo $(($MINS))`'m'

   ## get hours ## 
   HOURS=`echo $COUNTDOWN | cut -d" " -f2 | cut -d "." -f1 | cut -d "," -f1` 
   echo "Countdown: $HOURS hours" 
   ## coundown hours ## 
   TIMERH=`echo $(($HOURS))`'h'   

   ## get new action ## 
   IGNORE_COMMAND=`echo $COUNTDOWN | cut -d" " -f4`
   if [ "$IGNORE_COMMAND" = "TRUE" ] ; then   
    SETACTION=`echo $COUNTDOWN | cut -d" " -f 3` 
    SETACTION=`cat /usr/share/applications/${SETACTION}.desktop | grep Exec= | cut -d "=" -f 2 `
   else
    # must be the last input because number of parameters is unknown
    SETACTION=`echo $COUNTDOWN | cut -d" " -f 5-` 
    [[ ! "$SETACTION" ]] && yad --title="$TITLE Info" --text=" Make sure to add an Action to perform " && echo "Exiting" && exit 
   fi
   echo "Execute: $SETACTION " 
   
   ## tray notification ##
   exec 3> >(yad --notification  --image="$ICON" --listen) 
   echo tooltip: "Countdown action will be performed \n in <b>$HOURS</b> hours and <b>$MINS</b> minutes time from \n <b>$TIME $DATE</b> " >&3 
   
   ## sleep for x hours + x minutes ##
   sleep $TIMERH | sleep $TIMERM
   exec 3>&- 

   ### 10 seconds / cancel notification ### 
  ( 
    echo "99" ; sleep 1 
    echo "90" ; sleep 1 
    echo "80" ; sleep 1 
    echo "70" ; sleep 1 
    echo "60" ; sleep 1 
    echo "50" ; sleep 1 
    echo "40" ; sleep 1 
    echo "30" ; sleep 1 
    echo "20" ; sleep 1 
    echo "10" ; sleep 1 ) | 
  yad --progress --title="$TITLE $VERSION" --text=" Your action will be executed in 10 seconds. " \
  --percentage=0 --auto-close --auto-kill 
  if [ "$?" = -1 ] ; then
  yad --error --text=" Aborted by user! "
  fi   
  
  ### action to execute ### 
  echo $SETACTION startet. 
  time eval $SETACTION 
   
 fi 
 exit
Attachments
countdown3a.png
(9.03 KiB) Downloaded 2029 times

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#13 Post by RSH »

Hello,

i have downloaded and installed the pet, but it won't run.

Error Message:

Code: Select all

sh-3.00# /root/my-applications/bin/countdown
/root/my-applications/bin/countdown: line 17: yad: command not found

Exiting
sh-3.00# 
What does it mean and what can i do, to get this tool running? I'm using Puppy Studio 3.3 and Lucid 525 (528).

RSH

Edit:

Sorry, but i must have been blind. Found the yadxxx.pet, downloaded it, and now it works.

DPUP5520
Posts: 800
Joined: Wed 16 Feb 2011, 05:38

#14 Post by DPUP5520 »

You are missing yad

http://www.murga-linux.com/puppy/viewtopic.php?p=438811

you can find it in the first post of the above link
[url=http://www.murga-linux.com/puppy/viewtopic.php?t=69651][b][i]PupRescue 2.5[/i][/b][/url]
[url=http://www.murga-linux.com/puppy/viewtopic.php?t=72178][b][i]Puppy Crypt 528[/i][/b][/url]

DPUP5520
Posts: 800
Joined: Wed 16 Feb 2011, 05:38

#15 Post by DPUP5520 »

wtf thats weird, anyway you need yad which can be found here

http://www.murga-linux.com/puppy/viewtopic.php?p=438811
[url=http://www.murga-linux.com/puppy/viewtopic.php?t=69651][b][i]PupRescue 2.5[/i][/b][/url]
[url=http://www.murga-linux.com/puppy/viewtopic.php?t=72178][b][i]Puppy Crypt 528[/i][/b][/url]

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#16 Post by RSH »

Got still another Question: what is yad? Is it something like gtkdialog?

RSH

stu90

#17 Post by stu90 »

RSH wrote:Got still another Question: what is yad? Is it something like gtkdialog?

RSH
Hello RSH,
Yes - it allows you to add GUI's to bash scripts.
You can type yad--help-all in the terminal for a full list of options. 8)

puppyto
Posts: 78
Joined: Sat 10 Apr 2010, 18:15

#18 Post by puppyto »

Why countdown, does not works with poweroff?? the system (lucid puppy 5.2.8 on usb, frugal) becomes stopped, like a photo, and I must remove from electricity ( battery) to reboot again.

Post Reply