maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   [Solved] Script to show days left (https://talk.maemo.org/showthread.php?t=76299)

ejasmudar 2011-09-04 09:04

[Solved] Script to show days left
 
I want to make a QBW that will show the no of days remaining to a particular day. Can somebody please show me how we can make a bash/python script that will output, say for example "56 days remaining"?

Kindof like this config for rainmeter:http://jrweinman.deviantart.com/art/...Days-199156665

BluesLee 2011-09-04 09:24

Re: [Request] Script to show days left
 
Quote:

Originally Posted by ejasmudar (Post 1081595)
I want to make a QBW that will show the no of days remaining to a particular day. Can somebody please show me how we can make a bash/python script that will output, say for example "56 days remaining"?

Something like that?

Code:

echo "$(( ($(date -d "110923" +%s) - $(date +%s)) / 86400 )) days remaining"
p.s. 1. 110923=particular day X=23rd September of 2011 in my case
2. "date +%s" gives you the seconds since unix epoch, i.e. since 1970-01-01 00:00:00 UTC
3. 86400 secs a day = 60 secs * 60 min * 24 hours

ejasmudar 2011-09-04 09:30

Re: [Request] Script to show days left
 
can u explain what those constants (110923, 86400) are ?

phap 2011-09-04 17:18

Re: [Request] Script to show days left
 
like he says:
110923 = 23rd September 2011
86400 secs a day = 60 secs * 60 min * 24 hours

ejasmudar 2011-09-04 17:26

Re: [Request] Script to show days left
 
Quote:

Originally Posted by phap (Post 1081850)
like he says:
110923 = 23rd September 2011
86400 secs a day = 60 secs * 60 min * 24 hours

oh thanks that makes sense.

But is the date format dependent on the region/date-format settings? ie, my date is shown as 23/09/2011 so will it be 230911 or is it independant of those settings?

vkthor 2011-09-05 08:02

Re: [Request] Script to show days left
 
It'd be cool to have a desktop widget for this.

ejasmudar 2011-09-05 08:20

Re: [Request] Script to show days left
 
1 Attachment(s)
Thanks to the brilliant QBW, i made a widget on my desktop with the above scripts.
Thanks blueslee and phap!

TMO rocks!

peterch405 2011-09-05 08:36

Re: [Solved] Script to show days left
 
Nice, this looks really good, perhaps an step by step walkthough on how to create one of these babies for us mortals would be fitting. :)

vkthor 2011-09-07 21:33

Re: [Solved] Script to show days left
 
Well done! I'd also love a step by step walkthrough :). Thanks!

ejasmudar 2011-09-08 04:09

Re: [Solved] Script to show days left
 
@peterch405, vkthor

Do you guys have Queen Beecon Widget installed? If not, pls install it.

Now, in the desktop screen, click on add new widget, and add a queen beecon widget (aka QBW)

Now, click on the widget edit button (the spanner icon thingy) of the QBW. A settings window will popup.

Here are the MAIN thing to do in that window:
1. Click on "add Cmd"
2. Give the new command a name (something like Days Remaining)
3. Copy the above command by BluesLee and paste it in the Command Box.
4. Change "Type" from Beecon to Snippet
5. Towards the bottom of the window, there is a section "Update Policies & GPS/Location". Change the @Interval to 1 day.

The rest of the settings are mainly cosmetic and can be changed as you wish to get the look you want. Dont be afraid to experiment.


All times are GMT. The time now is 06:13.

vBulletin® Version 3.8.8