SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#101 2014-12-16 13:23:11

PeterIHughes
New Member
Registered: 2014-12-15
Posts: 5

Re: HOW TO : using lua scripts in conky

Offline

Be excellent to each other!

#102 2014-12-16 20:56:57

twoion
Emerald Caffeine
From: 星界
Registered: 2012-05-11
Posts: 1,648

Re: HOW TO : using lua scripts in conky

Offline

#103 2014-12-18 15:28:17

PeterIHughes
New Member
Registered: 2014-12-15
Posts: 5

Re: HOW TO : using lua scripts in conky

# 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

#104 2015-06-15 21:12:27

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: HOW TO : using lua scripts in conky

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: bleh

Debian Logo