matryer / xbar-plugins

Plugin repository for xbar (the BitBar reboot)
https://xbarapp.com
2.46k stars 1.04k forks source link

007-CalendarLite.1m.sh: #2045

Closed benhbell closed 1 month ago

benhbell commented 5 months ago

fao @WeibingChen17 -

the () around today's date stopped displaying

Screenshot 2024-06-17 at 10 48 52 AM Screenshot 2024-06-17 at 10 48 39 AM

#!/bin/bash

# <xbar.title>Clock with calendar</xbar.title>
# <xbar.version>v1.0</xbar.version>
# <xbar.author>Weibing Chen</xbar.author>
# <xbar.author.github>WeibingChen17</xbar.author.github>
# <xbar.desc>A clock with a simple calendar</xbar.desc>
# <xbar.image>https://i.ibb.co/Krmg0P8/Screen-Shot-2019-11-08-at-23-04-29.png</xbar.image>
# <xbar.dependencies>bash</xbar.dependencies>
# <xbar.abouturl>https://github.com/WeibingChen17/</xbar.abouturl>

# If using alongside apples default clock, one can uncomment the following - 
#formatted_date=$(date '+%d/%b/%Y')
#printf '\xF0\x9F\x93\x85 %s\n' "$formatted_date"
# don't forget to comment out the following `date ` command:
date "+%l:%M %p"

echo "---"
font="Monaco"
color="red"

#Uncomment the below line and comment out all other following lines to trigger the three-month mode
#cal - 3 |awk 'NF'|sed 's/ $//' |while IFS= read -r i; do echo " $i|trim=false font=$font color=$color"|  perl -pe '$b="\b";s/ _$b(\d)_$b(\d) /(\1\2)/' |perl -pe '$b="\b";s/_$b _$b(\d) /(\1)/'  ; done

#Comment out these lines to remove "last month"
last_month=$(date -v-1m +%m)
last_year=$(date -v-1m +%Y)
last_month_name=$(date -jf %Y-%m-%d "$last_year"-"$last_month"-01 '+%b')
echo "Prev: $last_month_name $last_year|trim=false font=$font"
cal -d "$last_year"-"$last_month" |awk 'NF'|sed 's/ *$//'| while IFS= read -r i; do echo "--$i|trim=false font=$font"; done 
echo "---"

#cal |awk 'NF'|while IFS= read -r i; do echo " $i|trim=false font=$font color=$color"|  perl -pe '$b="\b";s/ _$b(\d)_$b(\d) /(\1\2)/' |perl -pe '$b="\b";s/_$b _$b(\d) /(\1)/' |sed 's/ *$//'; done 
cal |awk 'NF'|while IFS= read -r i; do echo " $i"|perl -pe '$b="\b";s/ _$b(\d)_$b(\d) /(\1\2)/' |perl -pe '$b="\b";s/_$b _$b(\d) /(\1)/' |sed 's/ *$//' |sed "s/$/|trim=false font=$font color=$color/"; done 

#Comment out these lines to remove "next month"
echo "---"
next_month=$(date -v+1m +%m)
next_year=$(date -v+1m +%Y)
next_month_name=$(date -jf %Y-%m-%d "$next_year"-"$next_month"-01 '+%b')
echo "Next: $next_month_name $next_year|trim=false font=$font"
cal -d "$next_year"-"$next_month" | awk 'NF'|sed 's/ *$//' | while IFS= read -r i; do echo "--$i|trim=false font=$font";done
WeibingChen17 commented 5 months ago

I could not reproduce it on my system. https://ibb.co/ScGVvjm (bitbar) or https://ibb.co/ZSJFZb6 (xbar)

My Xbar version is 2.0.33-beta. After upgrading to the latest one, 2.1.7-beta, still the same.

Can you run the script from your terminal?

For Bitbar, it should been $HOME/.bitbar-plugin; for Xbar it is in $HOME/Library/Application Support/xbar/plugins

# Xbar for example
$ cd $HOME/Library/Application Support/xbar/plugins
$ ./CalendarLite.1m.sh

It should be something like this

 8:36 PM
---
Prev: May 2024|trim=false font=Monaco
--      May 2024|trim=false font=Monaco
--Su Mo Tu We Th Fr Sa|trim=false font=Monaco
--          1  2  3  4|trim=false font=Monaco
-- 5  6  7  8  9 10 11|trim=false font=Monaco
--12 13 14 15 16 17 18|trim=false font=Monaco
--19 20 21 22 23 24 25|trim=false font=Monaco
--26 27 28 29 30 31|trim=false font=Monaco
---
      June 2024|trim=false font=Monaco color=red
 Su Mo Tu We Th Fr Sa|trim=false font=Monaco color=red
                    1|trim=false font=Monaco color=red
  2  3  4  5  6  7  8|trim=false font=Monaco color=red
  9 10 11 12 13 14 15|trim=false font=Monaco color=red
 16(17)18 19 20 21 22|trim=false font=Monaco color=red
 23 24 25 26 27 28 29|trim=false font=Monaco color=red
 30|trim=false font=Monaco color=red
---
Next: Jul 2024|trim=false font=Monaco
--     July 2024|trim=false font=Monaco
--Su Mo Tu We Th Fr Sa|trim=false font=Monaco
--    1  2  3  4  5  6|trim=false font=Monaco
-- 7  8  9 10 11 12 13|trim=false font=Monaco
--14 15 16 17 18 19 20|trim=false font=Monaco
--21 22 23 24 25 26 27|trim=false font=Monaco
--28 29 30 31|trim=false font=Monaco
benhbell commented 1 month ago

you can close this, i removed xbar due to issues with silicon chip and returning from sleep