Skip to content

Instantly share code, notes, and snippets.

@rew62
Created December 31, 2025 18:59
Show Gist options
  • Select an option

  • Save rew62/a86676cd52aa66ee42c2dc7adf006677 to your computer and use it in GitHub Desktop.

Select an option

Save rew62/a86676cd52aa66ee42c2dc7adf006677 to your computer and use it in GitHub Desktop.
Conky Horizontal Calendar
conky.config = {
-- Basic Settings
background = false,
update_interval = 1800,
-- Window/Display Settings
own_window = true,
own_window_type = 'normal',
own_window_transparent = true,
own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',
double_buffer = true,
minimum_width = 620,
minimum_height = 40,
maximum_width = 1020,
-- Text and Font Settings
use_xft = true,
xftalpha = 0.2,
font = '123:size=8',
default_color = 'white',
uppercase = false,
override_utf8_locale = true,
text_buffer_size = 2048,
-- Alignment and Positioning
alignment = 'top_middle',
gap_x = 5,
gap_y = 10,
-- Performance and Optimization
cpu_avg_samples = 2,
net_avg_samples = 2,
no_buffers = true,
imlib_cache_size = 0,
-- Drawing/Aesthetic Settings
draw_shades = false,
draw_outline = false,
draw_borders = false,
draw_graph_borders = false,
border_inner_margin = 0,
border_outer_margin = 0,
-- Misc
use_spacer = 'right',
}
conky.text = [[
${goto 16}${alignc}${font Liberation Sans:size=18}${time %A, %B %-d, %Y Day: %j Week: %U}
${voffset -15}${goto 14}${color}${hr 1}
${voffset -15}$color${execpi 36000 ./hcal.sh}${color}
]]
#!/bin/bash
# Script to display a horizontal calendar on conky
TODAY=$(date +%d)
TOPLINE=" "
OVER=" "
REST=" "
# -------- Number of days in the month (Variable 'b') -----------#
a=$(date +%-Y)
e1=$((a % 400))
e2=$((a % 100))
e3=$((a % 4))
if [ "$e1" -eq 0 ]; then
c=1
elif [ "$e2" -eq 0 ]; then
c=0
elif [ "$e3" -eq 0 ]; then
c=1
else
c=0
fi
p=$(date +%-m)
# Determine the length of the current month ('b')
if [ "$c" -eq 0 ]; then # Not a leap year
if [ "$p" -eq 2 ]; then
b=28 # February
elif [ "$p" -eq 11 ] || [ "$p" -eq 4 ] || [ "$p" -eq 6 ] || [ "$p" -eq 9 ]; then
b=30
else
b=31
fi
else # Leap year
if [ "$p" -eq 2 ]; then
b=29 # February
elif [ "$p" -eq 11 ] || [ "$p" -eq 4 ] || [ "$p" -eq 6 ] || [ "$p" -eq 9 ]; then
b=30
else
b=31
fi
fi
#------- Days of the month ----------#
i=1
# Days before today
if [ "$TODAY" -ne 1 ]; then
while [ "$i" -lt "$TODAY" ]; do
if [ "$i" -lt 10 ]; then
OVER="$OVER 0$i"
else
OVER="$OVER $i"
fi
i=$((i+1))
done
fi
i=$((i+1))
# Days after today
if [ "$TODAY" -ne "$b" ]; then
# We use -le $b to ensure the last day is captured
while [ "$i" -le "$b" ]; do
if [ "$i" -lt 10 ]; then
REST="$REST 0$i"
else
REST="$REST $i"
fi
i=$((i+1))
done
fi
#---Abbreviated weekday names (Mo, Tu, etc.) -------#
# FIX: Get the day of the week for the 1st of the current month (1=Mon, 7=Sun)
FIRST_DAY_OF_MONTH_INDEX=$(date +%u --date="$(date +%Y-%m-01)")
y=$FIRST_DAY_OF_MONTH_INDEX
# Preserve 'b' for the loop counter
month_length=$b
# Loop through the days of the month to build the weekday line
while [ "$month_length" -gt 0 ]; do
case "$y" in
1) TOPLINE="$TOPLINE Mo";;
2) TOPLINE="$TOPLINE Tu";;
3) TOPLINE="$TOPLINE We";;
4) TOPLINE="$TOPLINE Th";;
5) TOPLINE="$TOPLINE Fr";;
6) TOPLINE="$TOPLINE Sa";;
7) TOPLINE="$TOPLINE Su";;
esac
month_length=$((month_length-1))
y=$((y+1))
if [ "$y" -eq 8 ]; then
y=1
fi
done
# --- Output ---
# 1. Build the Weekday line output string (TOP_OUTPUT)
TOP_OUTPUT=$(echo '${font mono:Bold:size=10}'"${TOPLINE}" | sed 's/Su/${color red}Su${color}/g' | sed 's/Sa/${color red}Sa${color}/g')
# 2. Build the Date line output string (BOTTOM_OUTPUT)
BOTTOM_OUTPUT='\n${voffset 4}${font mono:Bold:size=10}${color C28C3A}'"$OVER"'${color 5BED1B}'" $TODAY"'${color}'${REST:1}
# 3. Echo the combined result using -e to interpret the \n character
echo -e "$TOP_OUTPUT$BOTTOM_OUTPUT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment