You are not logged in.
You can use "io.popen" to run scripts in other languages and send the results to the Lua script.
I use Python for things that can't be done or are too difficult or complicated to do in Lua that way.
Thanks for your help,
I am going to try that out.
Offline
arclance wrote:You can use "io.popen" to run scripts in other languages and send the results to the Lua script.
I use Python for things that can't be done or are too difficult or complicated to do in Lua that way.Thanks for your help,
I am going to try that out.
Well I've written exactly what you want: lua-shellio. If it can be used from within conky, that is. It's based on my lua-filterpipe (which is a dependency). Other than that, it requires lua-posix (sudo apt-get install lua-posix).
Offline
This is what I have so far
I created a python script to take the contents of the raw lunar data file
and rewrite it as-is but with new lines inserted following the date in 2014-12-31 format
as a date in Tuesday December 16th 2014 format
the daysuffix function is used to add the st, nd, rd or th after the day number
leading zeros are stripped from the day number
the raw file which originally looked like this
from line16
New Moon
on
2014-11-22
12:32
now looks like this
New Moon
on
2014-11-22
Saturday, November 22nd 2014
12:32
So this script will be run once following the retrieval of the data files
from lunaf.com (per this post - Conky weather+moon scripts)
at the beginning of the conky
Then in the TEXT section, I will replace
${execpi 600 sed -n '18p' $HOME/5_Moon/today}
with
${execpi 600 sed -n '19p' $HOME/5_Moon/raw}
The conky will then display Saturday, November 22nd 2014 instead of 2014-11-22 for the new moon date (etc for all dates)
the python script
# read Lunar raw file
# for each date in 2014-12-31 format
# write a new line after in Tuesday December 31st 2014 format
import sys
import fileinput
from datetime import datetime
def main():
# read each line of the file
for i, line in enumerate(fileinput.input('your raw file', inplace=1)):
sys.stdout.write(line)
# write full text date after the NEW MOON date line
if i == 17:
sys.stdout.write(gettextdate(datetime.strptime(line[:-1], '%Y-%m-%d')) + '\n')
# write full text date after the 1ST QUARTER date line
if i == 23:
sys.stdout.write(gettextdate(datetime.strptime(line[:-1], '%Y-%m-%d')) + '\n')
# write full text date after the FULL MOON date line
if i == 29:
sys.stdout.write(gettextdate(datetime.strptime(line[:-1], '%Y-%m-%d')) + '\n')
# write full text date after the LAST QUARTER date line
if i == 35:
sys.stdout.write(gettextdate(datetime.strptime(line[:-1], '%Y-%m-%d')) + '\n')
# write full text date after the NEW MOON (NEXT) date line
if i == 41:
sys.stdout.write(gettextdate(datetime.strptime(line[:-1], '%Y-%m-%d')) + '\n')
return "MAIN DONE"
def gettextdate(datetime):
return '{0:%A}'.format(datetime) + ', {0:%B}'.format(datetime) + ' ' + '{0:%d}'.format(datetime).lstrip("0") + daysuffix(datetime) + ' {0:%Y}'.format(datetime)
def daysuffix(t):
daysuffs = [" ", "st", "nd", "rd", "th", "th", "th", "th", "th", "th",
"th", "th", "th", "th", "th", "th", "th", "th", "th", "th",
"th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th",
"th", "st"]
return daysuffs[t.day]
if __name__ == "__main__":
print('STARTING MAIN')
print(' ')
print(' ')
msg = main()
print(' ')
print(' ')
print(msg)
Offline
The conky will then display Saturday, November 22nd 2014 instead of 2014-11-22 for the new moon date (etc for all dates)
This is where I would settle back in to the original (YYYY-MM-DD) for spacing reasons:
2015-05-01 - Sunday, May 1st 2014 - is a bit shorter than
2015-09-31 - Wednesday, September 31st 2014
However, saying that - and this is just me being honest - the idea is really nice.
But being a Canuck I'd like the option to have:
Wed. 01 May 2015
Wed. 23 Sep 2015
Of course I don't program so I'm at the mercy of those that do
· ↓ ↓ ↓ ↓ ↓ ↓ ·
BunsenLabs Forums now Open for Registration
· ↑ ↑ ↑ ↑ ↑ ↑ · BL ModSquad
Offline
Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat