From f12a78597a7056b2f51ce908fb51d1d14d1e176c Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 25 Feb 2014 18:48:32 +0100 Subject: add example that can be used from xmobar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- examples/xmobar | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 examples/xmobar (limited to 'examples') diff --git a/examples/xmobar b/examples/xmobar new file mode 100644 index 0000000..a262aa4 --- /dev/null +++ b/examples/xmobar @@ -0,0 +1,31 @@ +# -*- python -*- + +# This example can be used in xmobar to display the +# Sun's elevation and to what degree it is day time. + + +# Geographical coodinates. +# (KTH building D computer laboratories in this example.) +latitude, longitude = 59.42430, 17.83521 + +# The colour temperature at day and at night. +temperature_day, temperature_night = 6500, 3700 + + +# The visibility of the Sun. +dayness = sun(latitude, longitude) + +# The Sun's elevation. +elevation = solar_elevation(latitude, longitude) + + +# Calculation of the whitepoint with adjusted colour temperature. +temperature_now = temperature_day * dayness + temperature_night * (1 - dayness) +whitepoint = divide_by_maximum(cmf_10deg(temperature_now)) +whitepoint = [('0' + hex(int(c * 255 + 0.5))[2:].upper())[-2:] for c in whitepoint] +whitepoint = whitepoint[0] + whitepoint[1] + whitepoint[2] + + +# Print information. +print('%.1f° (%.2f%%)' % (whitepoint, elevation, dayness)) + -- cgit v1.2.3-70-g09d2