Skip to content

Instantly share code, notes, and snippets.

@mikroskeem
Created March 11, 2015 12:38
Show Gist options
  • Save mikroskeem/368eaccccc7ea4819fb9 to your computer and use it in GitHub Desktop.
Save mikroskeem/368eaccccc7ea4819fb9 to your computer and use it in GitHub Desktop.
Displays fortune on login
[Desktop Entry]
Type=Application
Name=Fortune notification
Comment=Fortune in notification
Exec=/home/mark/bin/fortune.py
OnlyShowIn=GNOME;
X-GNOME-Autostart-Phase=Application
#!/usr/bin/env python3
import requests, json
from bs4 import BeautifulSoup
from gi.repository import Notify
Notify.init("Today's fortune")
headers = {"User-Agent": "curl/7.41.0", "Referer": "http://www.myfortunecookie.co.uk/"}
r = requests.post("http://www.myfortunecookie.co.uk/starsol.php", data={'t': 'fortune'}, headers=headers)
soup = BeautifulSoup(r.text)
FortuneNotif=Notify.Notification.new("Today's fortune", soup.body.h1.div.text, "dialog-information")
FortuneNotif.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment