So I have been trying to find a script or some other tutorial on how to get my XBOX360 friends list to display in conky. Being unsucessfull, I decided to try my hand at creating one of my own. Now before you go off on me about how messy or bloated this is, or how much MS sucks, please note that I have only been using ubuntu for 6 months in my spare time and 360 is still pretty cool(IMO.) So if you have suggestions on how I can be more efficient, I'd love to hear them. As it stands, there are some flaws. Which is why I'm posting this so that those who are more educated can help me perfect it. And so it goes.
CONKY XBO360 FRIENDS LIST
1.) I use Firefox. I like it. If you use something else, I have no way to help you other than the usual "Google it!" So, we need a way to get the cookies from Firefox. FF has begun using cookies.sqlite instead of cookies.txt (which we need.) So the first step is to download a handy FF extension that does the conversion for us. Clicky.
2.) Once installed, visit xbox.com and sign in making sure to check "Save my Login and Password." After you are signed in, click Tools in FF and you will notice the option "Export Cookies..." Click on it and a dialog box will come up asking you to name it and where you want it to go. The default (at least for me) was cookies.txt and the dir ~/ I left it like that and clicked Export.
3.) The reason for all the cookie business is that wget need them to get past the M$ Javascript Login. We have to use wget to save the html of the Friends page. You do this by entering this into a terminal.
Code:
wget --load-cookies=cookies.txt --keep-session-cookies --ignore-length --no-check-certificate http://live.xbox.com/en-US/profile/Friends.aspx
This will save a file called Friends.aspx to your home directory.
4.) Now comes the part where you vets will shake you head and probably start twitching. Open up gedit, pico or vi and create a script in /usr/bin named xFriends. (You can name it whatever you want really. Just remember to change it in your conky.rc file.) Here it is...
Code:
#!/bin/bash
rm ~/Friends.aspx
wget --load-cookies=cookies.txt --keep-session-cookies --ignore-length --no-check-certificate http://live.xbox.com/en-US/profile/Friends.aspx
cat Friends.aspx | grep 'h3\|Status' | tail -n+2 | tr -s " " " " | grep 'h3\|Xbox' | tr -s '"' "\n" | grep 'h3\|/span' | sed 's#\/span##g' | tr -s ">" " " | tr -s "<" " " | sed 's#\/h3##g' | sed 's#\h3##g' | sed 's/ |* /&|/g' | tr -s " " " " | head -n10
The rm removes the Friends.aspx file so it doesn't create Friends.aspx.1, etc. The wget retrieves the page again. Then the debauchery hacks the html into what I felt was relevant to display in conky. Save the script and chmod 755 it.
5.) In your conky.rc file, type this where you want the list to appear.
Code:
${execi 30 /usr/bin/xFriends | head -n12}
And viola! Your top 5 friend (either on line or top alphabetically) will be displayed on you desktop. And updated every 30 seconds.
Now, I leave it up to you to modify as you see fit. I have noticed, that you need to Export Cookies daily or else it poops the bed and wont work. Formatting has also been an issue for me. Help me with this if you can. If not, oh well, I tried and it suits my needs/wants.
P.S. I tried to type all of this into the New Post form and I believe I failed miserably. So if by some stretch I have double posted, (mods) feel free to banish one or the other to /dev/null. Screen shots follow.
Bookmarks