CLI config/dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.2 KiB

  1. #!/usr/bin/env sh
  2. #source $HOME/.cache/wal/colors.sh
  3. color0="#000000"
  4. color5="#FFFFFF"
  5. pkill -f "dzen2 -title-name calendar"
  6. ORIG_IFS=$IFS
  7. IFS=" " read current_month current_year <<< $(date +"%m %Y")
  8. IFS=$ORIG_IFS
  9. screen=1
  10. OPTS=`getopt -o m:y:s: -- "$@"`
  11. eval set -- "$OPTS"
  12. # <<<
  13. while true; do
  14. case "$1" in
  15. -m ) month="$2"; shift 2 ;;
  16. -y ) year="$2"; shift 2 ;;
  17. -s ) screen="$2"; shift 2 ;;
  18. -- ) shift; break ;;
  19. * ) break ;;
  20. esac
  21. done
  22. month=${month:-$current_month}
  23. year=${year:-$current_year}
  24. if (( month > 12)); then
  25. month=1
  26. ((year++))
  27. fi
  28. if ((month < 1)); then
  29. month=12
  30. ((year--))
  31. fi
  32. back="^ca(1, calendar -m $((month-1)) -y $year)<^ca()"
  33. next="^ca(1, calendar -m $((month+1)) -y $year)>^ca()"
  34. out=$(cal $month $year | sed "1s/^ /$back/; 1s/ $/$next/")
  35. lines=$(echo "$out" | wc -l)
  36. if test "$month" -eq "$current_month" && test "$year" -eq "$current_year"; then
  37. out=$(echo "$out" | sed "2,$ s/$(date +%e)/^fg($color0)^bg($color5)\0^fg()^bg()/")
  38. fi
  39. echo "$out" | dzen2 \
  40. -title-name "calendar" \
  41. -bg "$color0" \
  42. -fg "$color5" \
  43. -x "-242" \
  44. -y "20" \
  45. -h 30 \
  46. -l $((lines-1)) \
  47. -w 240 \
  48. -fn "Source Code Pro" \
  49. -e "onstart=uncollapse;button3=exit" \
  50. -ta c \
  51. -sa c \
  52. -xs $screen \
  53. -p &