Advertisement
HiImTye

Launchers/.tconk-scripts-timeCheckFB.sh

Apr 8th, 2014
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.42 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. settings=$HOME/Launchers/.tconk-settings-general
  4. # set cookies file
  5. . $settings
  6.  
  7. # make sure that the above file location contains your facebook cookies. I used the firefox extension 'Export Cookies' available at:
  8.  # https://addons.mozilla.org/en-us/firefox/addon/export-cookies/
  9.  # save the cookies file somewhere, then extract your facebook cookies. this is what I did (inside my Launchers folder, where all of my conky files are):
  10.  # grep ^.facebook.com cookies.txt > .tconk-settings-fbCookies; rm cookies.txt
  11. fbFullString=$(wget --load-cookies="$cookiesFile" -O - m.facebook.com)
  12. fbLoggedIn=$(echo "$fbFullString" | grep -iE 'accesskey="4">' | grep -i notifications | grep -o '4')
  13. fbMessageCount=$(echo "$fbFullString" | grep -ioE 'messages\([0-9]+\)' | grep -oE '[0-9]+' | uniq)
  14. fbFriendRequestCount=$(echo "$fbFullString" | grep -ioE 'find friends\([0-9]+\)' | grep -oE '[0-9]+')
  15. fbNotificationsCount=$(echo "$fbFullString" | grep -ioE 'notifications\([0-9]+\)' | grep -oE '[0-9]+')
  16.  
  17. if [ -n "$fbLoggedIn" ]; then
  18.  if [ -n "$fbMessageCount" ] && [ "$fbMessageCount" -gt 0 ]; then
  19.   echo "M$fbMessageCount" > "$tmpfolder"/time-fb
  20.  elif [ -n "$fbNotificationsCount" ]; then
  21.   echo "$fbNotificationsCount" > "$tmpfolder"/time-fb
  22.  elif [ -n "$fbFriendRequestCount" ]; then
  23.   echo "F$fbFriendRequestCount" > "$tmpfolder"/time-fb
  24.  else
  25.   echo 0 > "$tmpfolder"/time-fb
  26.  fi
  27. else
  28.  echo > "$tmpfolder"/time-fb
  29. fi
  30. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement