Advertisement
plusDm

Horizontal Line Calendar

Aug 21st, 2015
1,862
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.23 KB | None | 0 0
  1. #!/bin/bash
  2. # a script to display a horizontal calendar on conky (hence the name horical :D)
  3. # if you need to ask something, contact me via email [email protected]
  4. TODAY=`date +%d`
  5. TOPLINE=" "
  6. OVER=" "
  7. REST=" "
  8. # -------- This part is to find out the number of days in a month to display-----------#
  9. a=`date +%-Y`
  10. e1=`expr $a % 400`
  11. e2=`expr $a % 100`
  12. e3=`expr $a % 4`
  13. if [ $e1 == 0 ]
  14.   then c=1
  15.   elif [ $e2 == 0 ]
  16.   then c=0
  17.   elif [ $e3 == 0 ]
  18.   then c=1
  19.   else c=0
  20. fi
  21. p=`date +%-m`
  22. # if the current year is not a leap one, c = 0
  23. if [ $c == 0 ]
  24.   then
  25.     if [ $p == 2 ]
  26.     then b=28 # this is the number of days in Febuary
  27.     elif [ $p == 11 ] || [ $p == 4 ] || [ $p == 6 ] ||  [ $p == 9 ]
  28.     then b=30
  29.     else b=31
  30.     fi
  31.   else
  32.     if [ $p == 2 ]
  33.     then b=29 # the number of days in Febuary in a leap year
  34.     elif [ $p == 11 ] || [ $p == 4 ] || [ $p == 6 ] ||  [ $p == 9 ]
  35.     then b=30
  36.     else b=31
  37.     fi
  38. fi
  39. #--------------------- The bottom line which displays the days of month ----------#
  40. i=1
  41. if [ $TODAY -ne 1 ]
  42. then
  43.     while [ $i -lt $TODAY ]; do
  44.         if [ $i -lt 10 ]
  45.         then
  46.             OVER="$OVER 0$i"
  47.         else
  48.             OVER="$OVER $i"
  49.         fi
  50.         i=$[$i+1]
  51.     done
  52. fi
  53. i=$[$i+1]
  54. if [ $TODAY -ne $b ]
  55. then
  56.     while [ $i -ne $[$b] ]; do
  57.         if [ $i -lt 10 ]
  58.         then
  59.             REST="$REST 0$i"
  60.         else
  61.             REST="$REST $i"
  62.         fi
  63.         i=$[$i+1]
  64.     done
  65.     REST="$REST $b"
  66. fi
  67. #------------- the top line which displays the abbreviated weekday names-------#
  68. k=`date +%u`
  69. j=`date +%e`
  70. f=`expr $j % 7`
  71. if [ $k -lt $f ]
  72. then
  73.     y=$[$k+8-$f]
  74. else
  75.     y=$[$k-$f+1]
  76. fi
  77. while [ $b -gt 0 ]; do
  78.     case "$y" in
  79.     1) TOPLINE="$TOPLINE Pn";;
  80.     2) TOPLINE="$TOPLINE Wt";;
  81.     3) TOPLINE="$TOPLINE Śr";;
  82.     4) TOPLINE="$TOPLINE Cz";;
  83.     5) TOPLINE="$TOPLINE Pi";;
  84.     6) TOPLINE="$TOPLINE So";;
  85.     7) TOPLINE="$TOPLINE Ni";;
  86.     esac
  87.     b=$[$b-1]
  88.     y=$[$y+1]
  89.     if [ $y -eq 8 ]
  90.     then
  91.         y=1
  92.     fi
  93. done
  94. echo '${goto 270}''${font mono:size=8}'$TOPLINE | sed 's/Su/${color 383333}Su${color}/g' | sed 's/Ni/${color cf5160}Ni${color}/g'
  95. echo '${goto 270}''${font mono:bold:size=7}''${color 527151}'$OVER '${color 985d50}'$TODAY'${color}'$REST
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement