diff options
author | epoch <epoch@hacking.allowed.org> | 2020-03-28 03:53:08 -0500 |
---|---|---|
committer | epoch <epoch@hacking.allowed.org> | 2020-03-28 03:53:08 -0500 |
commit | 7dd38f1219b4dd473807aa4c4f779919853997b4 (patch) | |
tree | 2f0cc95fd0e668064ef1fdf8bc1ffbc832625e63 /share/hackvr/examples/calendar/calvr | |
parent | 06a05302b9b4b937cff46ad2618f771e8579db0d (diff) | |
download | hackvr-7dd38f1219b4dd473807aa4c4f779919853997b4.tar.gz hackvr-7dd38f1219b4dd473807aa4c4f779919853997b4.zip |
added a clock to the calendar
Diffstat (limited to 'share/hackvr/examples/calendar/calvr')
-rwxr-xr-x | share/hackvr/examples/calendar/calvr | 80 |
1 files changed, 55 insertions, 25 deletions
diff --git a/share/hackvr/examples/calendar/calvr b/share/hackvr/examples/calendar/calvr index dd7f6cd..e1df146 100755 --- a/share/hackvr/examples/calendar/calvr +++ b/share/hackvr/examples/calendar/calvr @@ -1,4 +1,4 @@ -#!/usr/bin/env -S hackvr_coproc /bin/bash +#!/usr/bin/env bash #draw a 7x7 grid #top row gets the day names #figure out what the first day of the week for that month is @@ -11,9 +11,13 @@ # order: queue, job number, time / 60 set -eo pipefail -year=2020 -month=2 -day=1 +current_year=$(date +%Y) +current_month=$(date +%m | sed 's/^0//') +current_day=$(date +%d | sed 's/^0//') + +year=$current_year +month=$current_month +day=$current_day cw=30 ch=30 @@ -22,6 +26,24 @@ yoff=51 xoff=105 backup=238 +WORKING_DIR=~/.local/var/cal + +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' +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 + sleep 1 +done & +### + printf "%s move %s 0 -%s\n" "$USER" "$xoff" "$backup" refresh="yep" @@ -35,39 +57,39 @@ stdbuf -oL grep -v '^#' | while true;do row=0 d=1 days_in_month=$(cal -d "$year-$month" | tr ' ' '\n' | grep . | tail -n1) - printf "_MONTH_ addshape 1 4 %s %s 0 %s %s 0 %s %s 0 %s %s 0\n" \ + 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 "_MONTH_" $[$xoff / 2] $[$yoff + $ch + 5] 0 - printf "_prevmonth_ addshape 1 4 %s %s 0 %s %s 0 %s %s 0 %s %s 0\n" \ + printf "%s %s\n" "${monthname}" "${year}" | makelabel.sh "_cal_MONTH_" $[$xoff / 2] $[$yoff + $ch + 5] 0 + 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 "_prevmonth_" $[0 - $cw + 1] $[$yoff + $ch + 5] 0 - printf "_nextmonth_ addshape 1 4 %s %s 0 %s %s 0 %s %s 0 %s %s 0\n" \ + printf "<==\n" | makelabel.sh "_cal_prevmonth_" $[0 - $cw + 1] $[$yoff + $ch + 5] 0 + 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] \ $[$cw * 8 -1] $[1*$ch+($ch/2) + $yoff - 1] \ $[$cw * 7] $[1*$ch+($ch/2) + $yoff - 1] - printf "==>\n" | makelabel.sh "_nextmonth_" $[$cw * 7 + 1] $[$yoff + $ch + 5] 0 + printf "==>\n" | makelabel.sh "_cal_nextmonth_" $[$cw * 7 + 1] $[$yoff + $ch + 5] 0 while [ "$d" -le "$days_in_month" ];do # printf "%s %s : %s\n" "$row" "$dow" "$d" - if [ -f ~/.local/var/cal/${year}_${month}_${d} ];then + if [ -f ${WORKING_DIR}/${year}_${month}_${d} ];then color=$[4+16] else color=$[5+16] fi printf "%s addshape %s 4 %s %s 0 %s %s 0 %s %s 0 %s %s 0\n" \ - "_day_${d}_" "${color}" \ + "_cal_day_${d}_" "${color}" \ "$[$dow*$cw]" "$[-1*$row*$ch + $yoff]" \ "$[$dow*$cw+$cw-1]" "$[-1*$row*$ch + $yoff]" \ "$[$dow*$cw+$cw-1]" "$[-1*$row*$ch+$ch-1 + $yoff]" \ "$[$dow*$cw]" "$[-1*$row*$ch+$ch-1 + $yoff]" - printf "%s\n" "${d}" | makelabel.sh "_day_${d}_" "$[$dow*$cw + 1]" "$[-1*$row*$ch + $yoff + 1]" 0 + printf "%s\n" "${d}" | makelabel.sh "_cal_day_${d}_" "$[$dow*$cw + 1]" "$[-1*$row*$ch + $yoff + 1]" 0 d=$[$d+1] dow=$[$dow + 1] if [ $dow = 7 ];then @@ -75,15 +97,16 @@ stdbuf -oL grep -v '^#' | while true;do row=$[$row + 1] fi done - day="$(date +%e | tr -d ' ')" -# printf "%s move 0 0 3\n" "_${day}_" + if [ $month = $current_month -a $year = $current_year ];then + printf "_cal_day_%s_ move 0 0 -2\n" "${current_day}" + fi fi if ! read group action target;then exit fi #xmessage "$group $action $target" if [ "$action" = "action" ];then - if [ "$target" = "_nextmonth_" ];then + if [ "$target" = "_cal_nextmonth_" ];then month=$[month + 1] if [ $month = 13 ];then month=1 @@ -91,7 +114,7 @@ stdbuf -oL grep -v '^#' | while true;do fi refresh="yep" fi - if [ "$target" = "_prevmonth_" ];then + if [ "$target" = "_cal_prevmonth_" ];then month=$[month - 1] if [ $month = 0 ];then month=12 @@ -99,22 +122,29 @@ stdbuf -oL grep -v '^#' | while true;do fi refresh="yep" fi - if [ "$target" = "_MONTH_" ];then + if [ "$target" = "_cal_MONTH_" ];then 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 printf "%s\n" "$target" | grep '^_day_' 2>&1 >/dev/null;then - d="$(printf "%s\n" "$target" | cut -d_ -f3)" - file=~/.local/var/cal/${year}_${month}_${d} + 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} if [ -e "${file}" ];then derp=exists else derp=notexists fi x-terminal-emulator -e nano "${file}" - if [ -e "${file}" ];then - if [ ! -s "${file}" ];then - rm "${file}" + if [ -e "${file}" ];then #if the file exists + if [ ! -s "${file}" ];then #but the file is empty + rm "${file}" >&2 + #git rm "${file}" >&2 + #git commit -m '[calvr] removed: ${file}' >&2 + else #the file is NOT empty, so it was changed, or not, might as well try to add and commit. + echo "# lol wat?" + #git add "${file}" >&2 + #git commit -m '[calvr] maybe changed: ${file}' >&2 # if nothing changed it won't bother to commit + #git push # just to make it more magical fi fi if [ -e "${file}" ];then @@ -134,6 +164,6 @@ stdbuf -oL grep -v '^#' | while true;do ### I /might/ want to just make all of the calendar parts ### start with _cal_* so I can deletegroup _cal_* ### instead of nuking the world except the user. - printf "%s deleteallexcept %s\n" "$USER" "$USER" + printf '%s deletegroup _cal_*\n' "$USER" fi done |