Last active
August 29, 2015 14:22
-
-
Save DavidLudwig/6afd3053842bcb9b15da to your computer and use it in GitHub Desktop.
SDL 2.0.4 bug tracker for OS X or KDE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# SDL 2.0.4 Bug-"Count" Checker for Mac OS X or KDE | |
# Version 1.6 | |
# | |
# Requirements: | |
# - any one of the following command-line notification tools: | |
# - Growl and growlnotify, for Mac OS X, available at http://growl.info | |
# - kdialog, for KDE | |
# - notify-send, for generic Linux notifications | |
# - curl | |
# | |
# Tech notes: | |
# - temporary files are placed directly in /tmp. According to the interwebs, | |
# OS X deletes these files every few days, if left unused... probably. To | |
# clear these files manually, run: | |
# rm "/tmp/SDLBugCount*" | |
# | |
# History: | |
# 1.0: first release, ha ha ha! | |
# 1.1: better messages, ha ha ha! | |
# 1.1.1: code cleanups, ha ha ha! | |
# 1.2: fixed number parsing bugs, ha ha ha! | |
# 1.3: one, one notification window, ha ha ha! | |
# 1.4: click to show info, ha ha ha! | |
# 1.5: KDE support, ha ha ha! (Thanks @thothonegan !) | |
# 1.6: Conjugation, ha ha ha! | |
# 1.7: notify-send support, ha ha ha! (Thanks @icculus !) | |
# | |
ICON_FILE="/tmp/SDLBugCountIcon.png" | |
ICON_URL="http://icons.iconarchive.com/icons/pino/sesame-street/32/The-Count-icon.png" | |
INFO_URL="https://bugzilla.libsdl.org/buglist.cgi?bug_status=UNCONFIRMED&bug_status=NEW&bug_status=WAITING&bug_status=RESPONDED&bug_status=ASSIGNED&bug_status=REOPENED&keywords=target-2.0.4&keywords_type=allwords&list_id=12321&query_format=advanced" | |
REFRESH_IN_SECONDS=600 | |
MESSAGE_FORMAT_SINGULAR="%s bug left in SDL 2.0.4, ha ha ha!" | |
MESSAGE_FORMAT_PLURAL="%s bugs left in SDL 2.0.4, ha ha ha!" | |
NOTIFICATION_ID=$(basename "$0") | |
do_notify () { | |
if type -P growlnotify > /dev/null; then | |
growlnotify -m "$1" --image "$ICON_FILE" -d "$NOTIFICATION_ID" --url "$INFO_URL" -s | |
elif type -P notify-send > /dev/null; then | |
# Notifications don't come up on Ubuntu 14.04 unless they are critical, wtf? | |
notify-send -u "critical" -i "$ICON_FILE" "SDLBugCount" "$1" 2>/dev/null | |
elif type -P kdialog > /dev/null; then | |
kdialog --passivepopup "$1" 5 --icon "$ICON_FILE" --title "SDLBugCount" | |
fi | |
} | |
# Detect notify program | |
if type -P growlnotify > /dev/null; then | |
: | |
elif type -P notify-send > /dev/null; then | |
: | |
elif type -P kdialog > /dev/null; then | |
: | |
else | |
echo "Please install a notify program, such as:" | |
echo "- growlnotify: for Mac OS X; can be found at http://growl.info/downloads" | |
echo "- notify-send: generic Linux notifier" | |
echo "- kdialog: part of KDE" | |
exit 1 | |
fi | |
# Detect curl | |
if ! type -P curl > /dev/null; then | |
echo "Please install 'curl'" | |
exit 1 | |
fi | |
# Download icon | |
if [ ! -f "$ICON_FILE" ]; then | |
echo "Setting up 1 icon, ha ha ha!" | |
curl "$ICON_URL" -o "$ICON_FILE" | |
fi | |
# Check for status, display as appropriate, rinse-and-repeat | |
COUNT="" | |
while true; do | |
NEW_COUNT=`curl -s "$INFO_URL" | grep "bugs found" | head -1 | perl -pne 's/^.*[^\d](\d+) bugs found.*/$1/'` | |
if [ "$NEW_COUNT" != "" ] && [ "$NEW_COUNT" != "$COUNT" ]; then | |
COUNT="$NEW_COUNT" | |
if [ "$COUNT" == "1" ]; then | |
MESSAGE=`printf "$MESSAGE_FORMAT_SINGULAR" "$COUNT"` | |
else | |
MESSAGE=`printf "$MESSAGE_FORMAT_PLURAL" "$COUNT"` | |
fi | |
echo "$MESSAGE" | |
do_notify "$MESSAGE" | |
fi | |
sleep "$REFRESH_IN_SECONDS" | |
done |
Sort of. gists can be forked, but there aren't pull requests, although that would be pretty cool.
Regardless, your changes are merged-in now. Thanks! 😃
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Apparently you can do pull requests on gists?!
Here's notify-send support, for the non-KDE Linux users:
https://gist.github.com/rcgordon/f343008f69c2126dd51c/revisions
--ryan.