-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: hackvr
action: commit
revision:
path_from:
revision_from: 55284c5f1bed4ea9b3b4a21b2df74b999a6fb010:
path_to:
revision_to:

git.thebackupbox.net

hackvr

git://git.thebackupbox.net/hackvr

commit 55284c5f1bed4ea9b3b4a21b2df74b999a6fb010
Author: epoch <epoch@enzo.thebackupbox.net>
Date:   Sat Dec 19 03:51:53 2020 -0600

    got rid of the /home/epoch in calvr. put the year in the UI. use a loop that makes more sense and is less error-prone.

diff --git a/share/hackvr/examples/calendar/calvr b/share/hackvr/examples/calendar/calvr

index 34c0f199fef87e8956299069eec31eb7351ab4ef..

index ..afef593b42fa78b2ae3f873abeb6438359feaded 100755

--- a/share/hackvr/examples/calendar/calvr
+++ b/share/hackvr/examples/calendar/calvr
@@ -19,6 +19,11 @@ year=$current_year
 month=$current_month
 day=$current_day

+### we're testing this weirdness
+#year=1752
+#month=9
+#day=1
+
 cw=30
 ch=30

@@ -33,14 +38,14 @@ cd "${WORKING_DIR}"
 #git pull

 ### hack to load in clock widget?
-/home/epoch/projects/hackvr/examples/clock/generate.py | sed 's/_clock_face_digit[^ ]* /_clock_face_ /g'
+hackvr-clock init | sed 's/_clock_face_digit[^ ]* /_clock_face_ /g'
 clock_left=15
 printf "_clock_face_hand_hour_ move -%s 0 0\n" $clock_left
 printf "_clock_face_hand_minute_ move -%s 0 0\n" $clock_left
 printf "_clock_face_hand_second_ move -%s 0 0\n" $clock_left
 printf "_clock_face_ move -%s 0 0\n" $clock_left
 while true;do
-  /home/epoch/projects/hackvr/examples/clock/set_clock.sh
+  hackvr-clock set
   sleep 1
 done &
 ###
@@ -52,24 +57,40 @@ refresh="yep"
 stdbuf -oL grep -v '^#' | while true;do
   if [ "$refresh" ];then
     unset refresh
-    first_dow="$(date -d $month/1/$year +%w)"
-    monthname="$(date -d $month/1/$year +%B)"
+#    first_dow="$(date -d $month/1/$year +%w)"
+
+### this doesn't work for august 2020. outputs 4, should output 6
+    first_dow=$[$(cal -d "${year}-${month}" | tail -n+3 | head -n1 | cut -d1 -f1 | wc -c) / 3]
+    monthname="$(date -d $month/1/2000 +%B)" #year isn't important
     dow=$first_dow
     row=0
     d=1
-    days_in_month=$(cal -d "$year-$month" | tr ' ' '\n' | grep . | tail -n1)
+
+### current month and its "button"
     printf "_cal_MONTH_ addshape 1 4  %s %s 0  %s %s 0  %s %s 0  %s %s 0\n" \
-           $[0]          $[1*$ch + $yoff] \
-           $[$cw * 7 -1] $[1*$ch + $yoff] \
-           $[$cw * 7 -1] $[1*$ch+($ch/2) + $yoff - 1] \
-           $[0]          $[1*$ch+($ch/2) + $yoff - 1]
-    printf "%s %s\n" "${monthname}" "${year}" | makelabel.sh "_cal_MONTH_" $[$xoff / 2] $[$yoff + $ch + 5] 0
+           $[0]                    $[1*$ch + $yoff] \
+           $[(($cw * 7 ) / 2) - 1] $[1*$ch + $yoff] \
+           $[(($cw * 7 ) / 2) - 1] $[1*$ch+($ch/2) + $yoff - 1] \
+           $[0]                    $[1*$ch+($ch/2) + $yoff - 1]
+    printf "%s\n" "${monthname}" | makelabel.sh "_cal_MONTH_" $[$xoff / 3] $[$yoff + $ch + 5] 0
+
+### current year and its "button"
+    printf "_cal_YEAR_ addshape 1 4  %s %s 0  %s %s 0  %s %s 0  %s %s 0\n" \
+           $[($cw * 7 ) / 2 ]      $[1*$ch + $yoff] \
+           $[$cw * 7 - 1]          $[1*$ch + $yoff] \
+           $[$cw * 7 - 1]          $[1*$ch+($ch/2) + $yoff - 1] \
+           $[($cw * 7 ) / 2 ]      $[1*$ch+($ch/2) + $yoff - 1]
+    printf "%s\n" "${year}" | makelabel.sh "_cal_YEAR_" $[$xoff + 5] $[$yoff + $ch + 5] 0
+
+### the <== button
     printf "_cal_prevmonth_ addshape 1 4  %s %s 0  %s %s 0  %s %s 0  %s %s 0\n" \
            $[-$cw] $[1*$ch + $yoff] \
            $[-1]   $[1*$ch + $yoff] \
            $[-1]   $[1*$ch+($ch/2) + $yoff - 1] \
            $[-$cw] $[1*$ch+($ch/2) + $yoff - 1]
     printf "<==\n" | makelabel.sh "_cal_prevmonth_" $[0 - $cw + 1] $[$yoff + $ch + 5] 0
+
+### the ==> button
     printf "_cal_nextmonth_ addshape 1 4  %s %s 0  %s %s 0  %s %s 0  %s %s 0\n" \
            $[$cw * 7]    $[1*$ch + $yoff] \
            $[$cw * 8 -1] $[1*$ch + $yoff] \
@@ -77,7 +98,8 @@ stdbuf -oL grep -v '^#' | while true;do
            $[$cw * 7]    $[1*$ch+($ch/2) + $yoff - 1]
     printf "==>\n" | makelabel.sh "_cal_nextmonth_" $[$cw * 7 + 1] $[$yoff + $ch + 5] 0

-    while [ "$d" -le "$days_in_month" ];do
+    for d in $(cal -d $year-$month | tail -n+3 | tr '\n' ' ' | tr -s ' ');do
+#    while [ "$d" -le "$days_in_month" ];do
 #      printf "%s %s : %s\n" "$row" "$dow" "$d"
       if [ -f ${WORKING_DIR}/${year}_${month}_${d} ];then
         color=$[4+16]
@@ -127,6 +149,10 @@ stdbuf -oL grep -v '^#' | while true;do
       month="$(xmessage -buttons January:1,February:2,March:3,April:4,May:5,June:6,July:7,August:8,September:9,October:10,November:11,December:12 'pick a month';echo $?)"
       refresh="yep"
     fi
+    if [ "$target" = "_cal_YEAR_" ];then
+      year="$(seq $[$year - 5] $[$year + 5] | dmenu -p 'enter a year' | tr -cd '0-9' | sed 's/^$/1970/')"
+      refresh="yep"
+    fi
     if printf "%s\n" "$target" | grep '^_cal_day_' 2>&1 >/dev/null;then
       d="$(printf "%s\n" "$target" | cut -d_ -f4)"
       file=${WORKING_DIR}/${year}_${month}_${d}

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 15:21:06 2024