-
-
Save gstalnaker/e6d6b02e2db5ee3db566644a008b8918 to your computer and use it in GitHub Desktop.
Conky Code by JGStalnaker/NAK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python3 | |
# Cobbled together from multiple web/blog/forum posts | |
import math | |
import sys | |
dgr = sys.argv[1] | |
def calcPoint(degHead, points): | |
maxPoints=32 | |
if points not in(8,16,32): | |
sys.exit("not a good question") | |
degHead=(degHead+(360/points/2))/(360/maxPoints) | |
j =int(int( int(degHead % 8)%8/(maxPoints/points))*maxPoints/points) | |
degHead = int(degHead / 8) % 4 | |
cardinal = ['North', 'East', 'South', 'West'] | |
pointDesc = ['W', 'W by x', 'W-z', 'Z by w', 'Z', 'Z by x', 'X-z', 'X by w']#vars not compass points | |
W = cardinal[degHead] | |
X = cardinal[(degHead + 1) % 4] | |
w=W.lower() | |
x=X.lower() | |
if (W == cardinal[0] or W == cardinal[2]) : | |
Z =W + x | |
else: | |
Z =X + w | |
z=Z.lower() | |
return pointDesc[j].replace('W', W).replace('X', X).replace('w', w).replace('x', x).replace('Z', Z).replace('z', z); | |
def getShortName(name): | |
return name.replace('North', 'N').replace('East', 'E').replace('South', 'S').replace('West', 'W').replace('north', 'N').replace('east', 'E').replace('south', 'S').replace('west', 'W').replace('by', 'b').replace(' ', '').replace('-', '') | |
print (dgr, end='° ') | |
name = calcPoint(float(dgr),16) #degrees heading, points of compass 8,16 or 32) | |
#print (name, end=' ') | |
shortName = getShortName(name) | |
print (shortName) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Conky by JGStalnaker/NAK | |
-- Displays: | |
-- Distro header with hostname/distro verion | |
-- System Info | |
-- Kernel, IP, CPU, CPU% Usage bar, LoadAvg, Processes, RAM #/bar, Buffers, Swap #/bar | |
-- Weather data based on data from three sources: Accuweather, NOAA/NWS, UW-Madison AOSS, including NEXRAD radar image | |
-- Calendar events using gcalcli for Google Calendar | |
-- Required tools, scripts, and fonts | |
-- Fonts: BebasNeue-Regular and weathericons-regular-webfont | |
-- Weather: | |
-- Three scripts that output JSON data | |
-- -- weather.sh - Accuweather for current weather description and icon | |
-- -- weather_aoss.sh - UW-Madison Atmospheric, Oceanographic, and Space Sciences center, roottop data API, local weather for himidity, dew point, precipitation, and solar flux | |
-- -- weather_nws.sh - National Weather Service API data for air pressure, Heat Index, Wind Chill data, barometer | |
-- jq to parse json data | |
-- compass_point.py python script to map degree bearing numerical value to compass point text value | |
-- curl to download the NEXRAD image and imagemagick's convert to modify its size and add the border | |
-- Calendar: | |
-- -- gcalcli with periodic update of GoogleAPI auth (no solution for this periodic reupping of Auth) called in threeDayAgenda.sh, see script notes | |
conky.config = { | |
font1 = 'Iosevka Medium:size=9', | |
font2 = 'Iosevka Medium:bold:size=9', | |
font3 = 'Iosevka Medium:size=8', | |
font4 = 'Union City Blue:bold:size=18', | |
font5 = 'bebas neue:size=16', | |
font6 = 'crackdown r2 brk:bold:size=18', | |
alignment = 'top_right', | |
minimum_width = 260, | |
minimum_height = 440, | |
maximum_width = 275, | |
gap_x = 90, | |
gap_y = 5, | |
background = true, | |
border_width = 1, | |
cpu_avg_samples = 2, | |
diskio_avg_samples = 2, | |
double_buffer = true, | |
draw_borders = false, | |
draw_graph_borders = true, | |
draw_outline = false, | |
draw_shades = false, | |
extra_newline = false, | |
net_avg_samples = 2, | |
no_buffers = yes, | |
out_to_console = false, | |
out_to_ncurses = false, | |
out_to_stderr = false, | |
out_to_x = true, | |
own_window = true, | |
own_window_class = 'Conky', | |
own_window_type = 'normal', | |
own_window_hints = 'below,undecorated,sticky,skip_taskbar,skip_pager', | |
show_graph_range = false, | |
show_graph_scale = false, | |
stippled_borders = 0, | |
update_interval = 1.0, | |
uppercase = false, | |
use_spacer = 'none', | |
use_xft = true, | |
} | |
conky.text = [[ | |
${image ~/bin/conky/left_line_blue.jpg -p 278,0 -s 1x1150} | |
# DISTRO | |
${image ~/bin/header.png -p 25,10 -s 220x43 -n} | |
${voffset -50}${font1}${color}${alignc}${execi 86400 /usr/bin/uname -n } - ${execi 86400 /usr/bin/lsb_release -s -d } | |
${voffset -10}${color #1853a1}${hr 3} | |
# SYSTEM INFO | |
${voffset -25} ${color #d97f00}${font D050000L:size=18}v ${font6}SYSTEM INFO | |
${voffset -25}${color #1853a1}${hr 2} | |
${voffset -25}${font2}${color #d97f00}KERNEL: ${font1}${color}${kernel} | |
${font2}${color #d97f00}IP ETH0: ${font1}${color}${addr enp3s0} | |
${font2}${color #d97f00}CPU: ${font1}${color}${execi 86400 grep -m1 -oP '^model name\s+:\s\K(.*)' '/proc/cpuinfo'} | |
${font2}${color #d97f00}CPU (% TTL):${font1}${color} ${cpu}% ${cpubar 4} | |
${font2}${color #d97f00}LOADAVG:${font1}${color} ${loadavg} | |
${font2}${color #d97f00}PROCESSES - TOTAL:${font1}$color $processes ${font2}${color #d97f00}RUNNING: ${font1}${color}${running_processes} | |
${font2}${color #d97f00}RAM - USED: ${color}${mem} ${color #d97f00}FREE: ${color}${memeasyfree} | |
${font2}${color #d97f00}RAM (% TTL): ${color}${font1}${memperc}% ${membar 4} | |
${font2}${color #d97f00}BUFFERS/CACHED: ${color}${font1}${buffers}/${cached} | |
${font2}${color #d97f00}SWAP - TOTAL:${font1}${color} ${swapmax}${font2}${color #d97f00} FREE:${font1}${color} ${swapfree} | |
${font2}${color #d97f00}SWAP: ${color}${font1}${swapperc}% ${swapbar 4} | |
## WEATHER ## | |
${voffset -25}${color #1853a1}${hr 2} | |
${voffset -5} ${font Dingytwo:size=18}${color #d97f00}B${voffset -5}${font6}${color #d97f00} WEATHER | |
${voffset -25}${color #1853a1}${hr 2} | |
${color} | |
${voffset -80}${alignc}${font1} ${execpi 900 date} | |
## SCRIPTS ## | |
${execi 900 ~/bin/conky/weather.sh} | |
${execi 900 ~/bin/conky/weather_aoss.sh} | |
${execi 900 ~/bin/conky/weather_nws.sh} | |
## AOSS TOWER/NWS Truax ## | |
${alignc}${voffset -105}${font5}${color #d97f00}${execi 900 cat ~/.cache/weather.json | jq -r '.weather[0].description' | sed "s|\<.|\U&|g"} · ${execi 900 cat ~/.cache/weather_aoss.json | jq -r '((.results.data.air_temp[] * 1.8)+32) | round'}°F | |
${goto 40}${voffset 15}${color}${font weather icons:size=40}${execi 900 ~/bin/conky/weather-text-icon} | |
${alignr 15}${voffset -135}${font1}${color}Heat Index: ${execi 900 cat ~/.cache/weather_nws.json | jq -r 'if (.properties.temperature.value < 26.6667 or .properties.heatIndex.value==null) then "-" else ((.properties.heatIndex.value * 1.8 + 32) | round) end'}°F | |
${alignr 15}${font1}${color}Wind Chill: ${execi 900 cat ~/.cache/weather_nws.json | jq -r 'if (((.properties.temperature.value > 10) or (.properties.windSpeed.value < 4.82803)) or (.properties.windChill.value==null)) then "-" else ((.properties.windChill.value * 1.8 + 32 ) | round) end'}°F | |
${alignr 15}${font1}${color}Humidity: ${execi 900 cat ~/.cache/weather_aoss.json | jq -r '.results.data.rel_hum[]'}% | |
${alignr 15}${font1}${color}Dew Point: ${execi 900 cat ~/.cache/weather_aoss.json | jq -r 'if .results.data.dewpoint[]==null then "-" else ((.results.data.dewpoint[] * 1.8 + 32) | round) end'}°F | |
${alignr 15}${font1}${color}Pressure: ${execi 900 cat ~/.cache/weather_nws.json | jq -r '.properties.barometricPressure.value/100'} hPa | |
${alignr 15}${font1}${color}Precipitation: ${execi 900 cat ~/.cache/weather_aoss.json | jq -r '.results.data.accum_precip[]'}" | |
${alignr 15}${font1}${color}Barometer: ${execi 900 cat ~/.cache/weather_aoss.json | jq -r '.results.data.altimeter[]'} inHg | |
${alignr 15}${font1}${color}Solar Flux: ${execi 900 cat ~/.cache/weather_aoss.json | jq -r '.results.data.solar_flux[]'} W/m^2 | |
${alignc}${voffset 10}${font1}${color}Wind: ${execi 900 cat ~/.cache/weather_aoss.json | jq -r '(.results.data.wind_speed[] * 2.236936) | round'} MPH from ${execi 900 ~/bin/conky/compass_points.py `cat ~/.cache/weather_aoss.json | jq -r '.results.data.wind_direction[]'`} | |
## AAOS NEXRAD RADAR IMAGE ## | |
${execpi 900 curl -s https://tempest.aos.wisc.edu/radar/swi3comp.gif | /usr/bin/convert - -trim -mattecolor DarkOrange -frame 10x10+4+4 ~/.cache/swi3comp.png } | |
${image ~/.cache/swi3comp.png -p 25,660 -s 220x220 -n} | |
## CALENDAR ## | |
${voffset 155}${color #1853a1}${hr 2} | |
${voffset -15} ${font Poky:size=18}${color #d97f00}d${font6}${color #d97f00} CALENDAR | |
${voffset -25}${color #1853a1}${hr 2}$color | |
${voffset -30}${font3}${execpi 1200 ~/bin/conky/threeDayAgenda.sh} | |
]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Closebox73 | |
# This script is to get weather data from openweathermap.com in the | |
# form of a json file so that conky will still display the weather | |
# when offline even though it isn't up to date | |
# Based on the scripts by Zavijava found in: | |
# https://github.com/closebox73/Orion | |
# you can use this or replace with yours | |
api_key=6fe678dbe75769bb1a3e352cf93ad0e5 | |
# get your city id at https://openweathermap.org/find and replace | |
city_id=5250074 | |
url="api.openweathermap.org/data/2.5/weather?id=${city_id}&appid=${api_key}&cnt=5&units=imperial&lang=en" | |
# Get data and store in .json file | |
curl ${url} -s -o ~/.cache/weather.json | |
exit | |
# Full command for testing | |
# curl "api.openweathermap.org/data/2.5/weather?id=5250074&appid=6fe678dbe75769bb1a3e352cf93ad0e5&cnt=5&units=imperial&lang=en" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# gcalcli requires an OAuth process for access to Google Calendar. The OAuth is time limited and Google without warning | |
# expires the authorization. This kills conky when execi runs the script and gcalcli initiates a re-auth process in a | |
# browser that conky cannot handle. Only option is to run gcalgli from a prompt, get the OAuth redone, kill conky, | |
# restart conky. Annoying, but it works. | |
# replace <calendarAccount> with Google Calendar UID | |
#set -x | |
gcalCmdComplete2="/usr/bin/gcalcli --calendar "<calendarAccount>" agenda $(date +%D) $(date -d "+3 days" +%D) --tsv" | |
agenda=$(${gcalCmdComplete2}) | |
if [ -z "${agenda}" ] | |
then | |
echo "No events found..." | |
else | |
echo "${agenda}" | awk 'BEGIN {FS="\t"}; { split($2,A,":"); if(A[1]>12) { V=sprintf("%02d",A[1]-12); sub(/[0-9]+:/,V":",$2); $2=$2"p"; } else if(A[1]==12) { $2=$2"p"; } else if(A[1]==0) { sub(/[0-9]+:/,"12:",$2); $2=$2"a"; } else $2=$2"a"; }; { printf "%s %s %.28s\n", $1, $2, $5 }' | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
curl "http://metobs.ssec.wisc.edu/api/data.json?site=aoss&inst=tower&symbols=air_temp:rel_hum:dewpoint:wind_speed:wind_direction:accum_precip:pressure:altimeter:solar_flux&begin=-01:00:00&order=column&interval=1h" -s -o ~/.cache/weather_aoss.json | |
# $(echo "scale=2;(1.8 * <temp>) + 32" |bc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
curl -X GET "https://api.weather.gov/stations/KMSN/observations/latest" -H "accept: application/geo+json" -o ~/.cache/weather_nws.json | |
# $(echo "scale=2;(1.8 * <temp>) + 32" |bc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment