Advertisement
HiImTye

Launchers/.tconk-scripts-time.sh-i3

Apr 8th, 2014
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.87 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. settings=$HOME/Launchers/.tconk-settings-general
  4. # load variables from file
  5. . $settings
  6.  
  7. imgtmp=$tmpfolder/.time-icon.png
  8. imgout=$tmpfolder/time-icon.png
  9. updatestmp=$tmpfolder/time-updates
  10. mailtmp=$tmpfolder/time-mail
  11. fbtmp=$tmpfolder/time-fb
  12. updateCount=$(cat $updatestmp)
  13. mailCount=$(cat $mailtmp)
  14. fbCount=$(cat $fbtmp)
  15.  
  16. # check if our facebook count contains our message indicator
  17. if [[ "$fbCount" =~ M ]]; then
  18.   # our count is a message count
  19.   fbIsMessage="yes"
  20.   # clean our message indicator from our count
  21.   fbCount=$(echo "$fbCount" | sed 's|M||')
  22. elif [[ "$fbCount" =~ F ]]; then
  23.   # our count is a friend request count
  24.   fbIsFriendRequest="yes"
  25.   # clean our friend request indicator from our count
  26.   fbCount=$(echo "$fbCount" | sed 's|F||')
  27. fi
  28.  
  29.  
  30. # check if there are facebook notifications
  31. if [ "$fbCount" = 0 ] ; then
  32.  # no notifications, report to conky
  33.  echo "\${alignr}\${color7}No new Facebook activity."
  34. elif [ "$fbCount" = 1 ] ; then
  35.  if [ -n "$fbIsMessage" ]; then
  36.   # message, report to conky
  37.   echo "\${alignr}\${color5}$fbCount \${color6}Facebook message\${color5}!"
  38.  elif [ -n "$fbIsFriendRequest" ]; then
  39.   # friend request, report to conky
  40.   echo "\${alignr}\${color5}$fbCount \${color6}Facebook friend request\${color5}!"
  41.  else
  42.   # notification, report to conky
  43.   echo "\${alignr}\${color5}$fbCount \${color6}Facebook notification\${color5}!"
  44.  fi
  45.  # set our strings variable
  46.  strings="$timeIconFB"
  47. elif [ "$fbCount" -gt 1 ] ;  then
  48.  if [ -n "$fbIsMessage" ]; then
  49.   # message, report to conky
  50.   echo "\${alignr}\${color5}$fbCount \${color6}Facebook messages\${color5}!"
  51.  elif [ -n "$fbIsFriendRequest" ]; then
  52.   # friend request, report to conky
  53.   echo "\${alignr}\${color5}$fbCount \${color6}Facebook friend requests\${color5}!"
  54.  else
  55.   # notifications, report to conky
  56.   echo "\${alignr}\${color5}$fbCount \${color6}Facebook notifications\${color5}!"
  57.  fi
  58.  # set our strings variable
  59.  strings="$timeIconFB"
  60. else
  61.  # error checking, report to conky
  62.  echo "\${alignr}\${color7}Error checking Facebook."
  63. fi
  64. # check if there is new mail
  65. if [ "$mailCount" = 0 ] ; then
  66.  # no new mail, report to conky
  67.  echo "\${alignr}\${color7}No new Gmail activity."
  68. elif [ "$mailCount" = 1 ] ; then
  69.  # new mail, report to conky
  70.  echo "\${alignr}\${color5}$mailCount \${color6}Unread Gmail message\${color5}!"
  71.  # set our strings variable
  72.  strings=$(echo -e "$strings"'\n'"$timeIconGmail")
  73. elif [ "$mailCount" -gt 1 ] ;  then
  74.  # new mail, report to conky
  75.  echo "\${alignr}\${color5}$mailCount \${color6}Unread Gmail messages\${color5}!"
  76.  # set our strings variable
  77.  strings=$(echo -e "$strings"'\n'"$timeIconGmail")
  78. else
  79.  # error checking, report to conky
  80.  echo "\${alignr}\${color7}Error checking mail."
  81. fi
  82. # check if there are updates
  83. if [ -f /var/run/reboot-required ]; then
  84.  # we need to reboot, report to conky
  85.  echo "\${alignr}\${color6}Restart required."
  86. elif [ "$updateCount" = 0 ] ; then
  87.  # no updates, report to conky
  88.  echo "\${alignr}\${color7}System up to date."
  89. elif [[ "$updateCount" =~ A1$ ]]; then
  90.  echo "\${alignr}\${color5}${updateCount#A*} \${color6}New AUR Update Available\${color5}!"
  91. elif [[ "$updateCount" =~ A ]]; then
  92.  echo "\${alignr}\${color5}${updateCount#A*} \${color6}New AUR Updates Available\${color5}!"
  93. elif [ "$updateCount" = 1 ] ; then
  94.  # updates, report to conky
  95.  echo "\${alignr}\${color5}$updateCount \${color6}New Update Available\${color5}!"
  96. else
  97.  # updates, report to conky
  98.  echo "\${alignr}\${color5}$updateCount \${color6}New Updates Available\${color5}!"
  99. fi
  100. # set our updates and restart strings separately, so that
  101.  # one doesn't prevent the other
  102. if [ "${updateCount#A*}" -gt 0 ]; then
  103.  strings=$(echo -e "$strings"'\n'"$timeIconUpdate")
  104. fi
  105. if [ -f /var/run/reboot-required ]; then
  106.  strings=$(echo -e "$strings"'\n'"$timeIconRestart")
  107. fi
  108.  
  109.  
  110. # define our reference
  111. while read f; do
  112.  if [ "$f" = "$timeIconFB" ]; then
  113.   # just a number because KISS
  114.   ref=1
  115.  elif [ "$f" = "$timeIconGmail" ]; then
  116.   ref=2
  117.  elif [ "$f" = "$timeIconUpdate" ]; then
  118.   ref=3
  119.  elif [ "$f" = "$timeIconRestart" ]; then
  120.   ref=4
  121.  fi
  122.  # append our number to the end of any existing references
  123.  reference=$(echo "$reference""$ref")
  124. done < <(echo "$strings" | grep [\da-zA-Z])
  125. # add our reference path to the beginning of our reference filename
  126. reference="$tmpfolder/time=$reference"
  127. # define our background image
  128. bg=$timeBottomImage
  129. # make our picture
  130. if [ ! -f "$reference" ]; then
  131.  while read fg; do
  132.   # incriment our count by 1
  133.   count=$(( $count + 1 ))
  134.   # make our offset, using our count
  135.   pos=+$(( 46 + ( ( $count - 1 ) * 35 ) ))+15
  136.   # do the actual work of creating the image
  137.   composite -geometry "$pos" "$fg" "$bg" "$imgtmp"
  138.   bg="$imgtmp"
  139.  done < <(echo "$strings" | grep [\da-zA-Z])
  140. composite "$timeTopImage" "$bg" "$imgout"
  141. rm "$imgtmp"
  142. rm "$tmpfolder"/time=*
  143. touch "$reference"
  144. fi
  145. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement