For the few of you who might be interested, there's a tiny little (1.1Kb) script you can run which will display the phase of the moon in Conky without having to install conkyForecasts.
First, create an executable file in home/[user name] and name it moon.py
The script is as follows - the original did not have the "Lunar Phase:" there:
- Code: Select all
#!/usr/bin/env python
"""
moonphase.py - Calculate Lunar Phase
Author: Sean B. Palmer, inamidst.com
Cf. http://en.wikipedia.org/wiki/Lunar_phase#Lunar_phase_calculation
"""
import math, decimal, datetime
dec = decimal.Decimal
def position(now=None):
if now is None:
now = datetime.datetime.now()
diff = now - datetime.datetime(2001, 1, 1)
days = dec(diff.days) + (dec(diff.seconds) / dec(86400))
lunations = dec("0.20439731") + (days * dec("0.03386319269"))
return lunations % dec(1)
def phase(pos):
index = (pos * dec(8)) + dec("0.5")
index = math.floor(index)
return {
0: "Lunar Phase: New Moon",
1: "Lunar Phase: Waxing Crescent",
2: "Lunar Phase: First Quarter",
3: "Lunar Phase: Waxing Gibbous",
4: "Lunar Phase: Full Moon",
5: "Lunar Phase: Waning Gibbous",
6: "Lunar Phase: Last Quarter",
7: "Lunar Phase: Waning Crescent"
}[int(index) & 7]
def main():
pos = position()
phasename = phase(pos)
roundedpos = round(float(pos), 3)
print "%s (%s)" % (phasename, roundedpos)
if __name__=="__main__":
main()
Add the following line to Conky:
- Code: Select all
${exec python moon.py}
And you're done.
The output will display e.g.
- Code: Select all
Lunar Phase: First Quarter (0.272)
That last figure indicates fullness, with 1.0 of course being a full moon. As you can see, this moon brightness is calculated into the thousandths, and datetime.datetime calculates time to the microsecond, so you could change the Conky command to e.g.
- Code: Select all
${execi 5 python moon.py}
... and get moon brightness updates every five seconds! OK, maybe you don't want updates that often, but the phase does increase in brightness every few minutes, I've seen; the moon's a fast-moving object.
EDIT: Guess I might as well show my Conky here then. Click for fullsize:

I do not use conkyForecast, as last I checked this required adding Ubuntu repositories, and I'm running LMDE. So instead I installed Debian's weather.util package. Apart from the moon.py script, I also use a .conky_start.sh script that delays Conky's start by 20 seconds - in this way, the desktop is fully loaded when Conky turns on, and there are no rendering problems. The code for the .conky_start.sh script is simple enough:
- Code: Select all
#!/bin/bash
sleep 20 && conky
Then I change the Conky command in Startup Applications to sh .conky_start.sh - easy peasy!
And this is my .conkyrc:
- Code: Select all
#avoid flicker
double_buffer yes
#own window to run simultanious 2 or more conkys
own_window yes
own_window_transparent yes
own_window_type normal
own_window_hints undecorate,sticky,skip_taskbar,skip_pager
#borders
draw_borders no
border_margin 0
#shades
draw_shades no
#position
gap_x 5
gap_y 40
alignment top_right
#behaviour
update_interval 1
#colour
default_color e0e0e0
#default_shade_color 242424
own_window_colour 000000
#font
use_xft yes
xftfont sans:size=8
# Force UTF8? note that UTF8 support required UFT
override_utf8_locale yes
#to prevent window from moving
use_spacer no
minimum_size 200 0
#mpd
#mpd_host localhost
#mpd_port 6600
TEXT
${alignr}${time %H:%M:%S} ${alignr}${time %a %d %b %Y}
${alignr}Kernel: $kernel
${alignr}Distro: Linux Mint Debian
${alignr}Memory: $mem / $memmax
${alignr}RAM: ${memperc}%
${alignr}CPU1: ${cpu cpu1}% CPU2: ${cpu cpu2}%
${alignr}Temp: ${nvidia temp}°C
${alignr} TOP CPU% MEM%
${alignr}${top name 1} ${top cpu 1} ${top mem 1}
${alignr}${top name 2} ${top cpu 2} ${top mem 2}
${alignr}${top name 3} ${top cpu 3} ${top mem 3}
${alignr}${top name 4} ${top cpu 4} ${top mem 4}
${alignr}${top name 5} ${top cpu 5} ${top mem 5}
${alignr}${top name 6} ${top cpu 6} ${top mem 6}
${alignr}${top name 7} ${top cpu 7} ${top mem 7}
${alignr}${top name 8} ${top cpu 8} ${top mem 8}
${alignr}${top name 9} ${top cpu 9} ${top mem 9}
${alignr}File System: Free:${fs_free /}
${alignr} Used:${fs_used /}
${alignr}Home: Free:${fs_free /home}
${alignr} Used:${fs_used /home}
${alignr}Data: Free:${fs_free /home/[me]/Desktop/Data}
${alignr} Used:${fs_used /home/[me]/Desktop/Data}
${alignr}${execi 5 weather -i BIRK -q -m}
${alignr}${execi 5 python moon.py}