Rawr!!!

Simply Check if you Have new Gmails

Written by
November 2nd, 2011

After setting up mutt; I figured I’d go the extra mile; and add a notification system so that I know when I have some new emails. Well come to find out; it was easy as pie. And I learned a few new little things in the process.
First of all; gmail has a nifty url that serves a feed for your emails:

https://mail.google.com/mail/feed/atom

The feed will tell you about new emails, unread emails, and stuff like that. But what makes the feed so awesome, is that it’ s well labeled, and easy to parse. So for my script I just need to call the url, pass a username and password, and enjoy the output:

Download Script: https://raw.github.com/fsk141/scripts/master/checkgmail

Or view it below:


#!/bin/sh

## Simple Check Gmail ##
## Jonny Gerold  ##

# User & Password should look like the following:
## set imap_user = me@domain.tld
## set imap_pass = my_pass
### You can hardset USER & PASS here if you would like; I just
### didn't want my user/pass all over the place in conf files

USER=$(grep 'set imap_user' ~/.mutt/muttrc | awk '{ print $4 }')
PASS=$(grep 'set imap_pass' ~/.mutt/muttrc | awk '{ print $4 }')

# Check mail status...
function check () {
curl -s -u $USER:$PASS https://mail.google.com/mail/feed/atom
}

# Find number of messages unread
function fullcount () {
check |  grep '<fullcount>' | sed -e 's/<fullcount>//' -e 's/<\/fullcount>//'
}

# Print result
function print () {
if [[ -n $(fullcount) ]] && [[ $(fullcount) == '1' ]]; then
echo "You have $(fullcount) new email!"
else
echo "You have $(fullcount) new emails!"
fi
}

# notify-send that message!
#notify-send "$(print)"

# output number of new emails
fullcount

# static print 'You have $(fullcount) new email(s)
#print

How to make the script work for you?

  1. Add it to your crontab
    10 * * * * * ~/checkgmail
  2. If you use statnot; add it to your ~/.statusline
    # I have the script set to just output the number of new emails
    function nEmail () {
    if [[ $(~/.scripts/checkgmail) > 0 ]]; then
    echo ">> $(~/.scripts/checkgmail) NEW EMAIL | "
    fi
    }
    # my actual output looks something like this:
    echo "$(nEmail)$(mpd)V: $volume | B: $(bat) | $datetime";
    
  3. Add it to conky
    exec ~/checkgmail

Chapod (Calvin & Hobbes Apod)

Written by
September 6th, 2010

Idea: http://www.reddit.com/r/pics/comments/d9zfg/i_used_to_change_my_desktop_background_every_day

APOD: http://apod.nasa.gov/apod/

Implementation: https://github.com/fsk141/scripts/blob/master/chapod

Download: https://raw.github.com/fsk141/scripts/master/chapod (wget, or right click & save as)

I made this a while ago, and thought some people would like to know that it’s working awesome.

Setup:

Change the RESOLUTION variable to fit your screen size

Usage: (Works on Mac & Linux)


chapod ## without any options will download everything & set your desktop bg

chapod  ## will set to any apod you want!

eg: chapod http://apod.nasa.gov/apod/ap110628.html

don’t forget to chmod +x if thing’s aren’t working out well.

If you would like it to auto-run every day:

 crontab -e # and add the following:
 5 12 * * *	$HOME/.scripts/scripts/chapod  

Requirements:

- Imagemagick

- Mac/Linux

- Curl

- feh (if on linux)

Program below:

#!/bin/bash

#################################################
# Calvin & Hobbes APOD #
# Version 1.2 (stupid convert) #
#################################################

#///////////////////////////////////////////////#
# Author: Jonny Gerold <jonny@fsk141.com> #
#///////////////////////////////////////////////#

#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

# Storage Directory
SDIR="$HOME/.chapod"

# Screen Resolution
RESOLUTION="1280x800"

# Raw Calvin & Hobbes foreground
RAWCH="http://dl.dropbox.com/u/52078/chblank.png"

# Base URL for apod
BURL="http://apod.nasa.gov/apod/"

# OS Check
OS=`uname -s`

# Where is convert
if [[ "$OS" == "Darwin" ]]; then
if [[ -x /usr/local/bin/brew ]]; then
IM="/usr/local/bin/convert"
## prolly should put in an else for macports
fi
else
IM="/usr/bin/convert"
fi

# If a url is specified use that, otherwise use apod
if [[ -n "$1" ]]; then

# Entered URL
EURL="$1"
IMAGEPATH=`curl $EURL 2>/dev/null | grep 'href="image' | cut -d\" -f2`
APOD="$BURL$IMAGEPATH"
else
IMAGEPATH=`curl $BURL 2>/dev/null | grep 'href="image' | cut -d\" -f2`
APOD="$BURL$IMAGEPATH"
fi

# Make SDIR
if [[ ! -d $SDIR ]]; then
mkdir $SDIR
fi

# Get the raw Calvin & Hobbes image
if [[ ! -e $SDIR/chblank.png ]]; then
curl $RAWCH -o $SDIR/chblank.png 2>/dev/null
fi

# Get the apod
if [[ -e $SDIR/apod.jpg ]]; then
rm $SDIR/apod.jpg
fi
curl $APOD -o $SDIR/apod.jpg 2>/dev/null

# Resize raw C&H image & apod
for image in apod.jpg chblank.png
do $IM $SDIR/$image -background transparent -resize $RESOLUTION^ -gravity south -extent $RESOLUTION $SDIR/tmp.$image
done

# Lets join them together
$IM $SDIR/{tmp.apod.jpg,tmp.chblank.png} -mosaic $SDIR/chapod.jpg

rm $SDIR/tmp.*

# Now lets set the background
if [[ $OS == "Darwin" ]]; then
osascript -e "tell application \"System Events\" to set picture of every desktop to \"$SDIR/$CHA\""
else
feh --bg-scale $SDIR/chapod.jpg &
fi

Cliard | Command Line Arduino FTW

Written by
November 28th, 2009

Well, Cliard 0.1.0017 is… working :) It’s almost a direct descendant of Kimmo Kulovesi’s arduino_make.sh. I stripped out a lot of flac (placed it into ‘docs’ for now), changed a few things, and gave arduino libraries a much deserved home in ~/.cliard/arduino. The program itself is comprised of ~/.cliard/arduino/{examples,hardware,libraries} & ‘cliard’ executable & a perl serial interface (to restart arduino via software)…

To install you have a couple options:

1) PKGBUILD (If you’re on Arch Linux)

2) http://github.com/fsk141/Cliard (If you’re on something else)

  • Just install avr-gcc, avrdude, wget, perl-devices-serial (http://search.cpan.org/~COOK/Device-SerialPort), & run ‘./install.sh’

How to use:

1) make a directory containing you .pde file (with the same name)

Example: ~/LED/LED.pde


#define LED 11

void setup () {
 pinMode(LED,OUTPUT);
}

void loop () {
 digitalWrite(LED,HIGH); // turn led on
 delay(1000); // delay
 digitalWrite(LED,LOW); // turn led off
 delay(100); // delay
}

Inside the ~/LED directory execute ‘cliard’

If everything goes well, then you should be able to plug in your arduino and type ‘cliard upload’, and enjoy your new .pde running on your arduino.

There is a lot that needs to be worked on, but *all* of these things should get done in good time. I hope you enjoy cliard as much as I do. And happy hacking with your arduino. Oh and I’m thinking of making a dedicated page for cliard, but aren’t sure as of yet, so for now just check the gitlog for updates.

First Arch Linux Post & some other little tidbits

Written by
March 18th, 2009

Well, as you probably don’t know (since I have yet to advertise on my *new* blog) I’m an avid Arch Linux User. I just love it to pieces. I use it on my personal servers & clients. I recently have been dumping some time into updating my packages: Link to my AUR Packages

I recently acquired the rtorrent-svn / libtorrent-svn / xmlrpc-c-svn packages. I deleted the *-wt packages and merged them with the standard -svn packages. Hooray!

I have also been working on the OpenVZ package (updating the hell out of it). I updated it using the theory behind this wiki link : Kernel_Compilation_with_ABS I have compiled the darn thing about 10 times as of now, and atm I’m hoping that I’m on the last compile (crossing my fingers that it will work) :)

I have started using subversion a little more in depth, and have been trying out branches:

git-wiki

I’ll make sure to post my results…