replace notify.py with dunstify

This commit is contained in:
Sascha Kruse 2013-02-23 04:51:37 +00:00
parent 5827411c64
commit 71d95394fd
3 changed files with 36 additions and 100 deletions

View File

@ -26,7 +26,7 @@ static GOptionEntry entries[] =
{ "appname", 'a', 0, G_OPTION_ARG_STRING, &appname, "Name of your application", "NAME" }, { "appname", 'a', 0, G_OPTION_ARG_STRING, &appname, "Name of your application", "NAME" },
{ "urgency", 'u', 0, G_OPTION_ARG_STRING, &urgency_str, "The urgency of this notification", "URG" }, { "urgency", 'u', 0, G_OPTION_ARG_STRING, &urgency_str, "The urgency of this notification", "URG" },
{ "hints", 'h', 0, G_OPTION_ARG_STRING_ARRAY, &hint_strs, "User specified hints", "HINT" }, { "hints", 'h', 0, G_OPTION_ARG_STRING_ARRAY, &hint_strs, "User specified hints", "HINT" },
{ "actions", 'a', 0, G_OPTION_ARG_STRING_ARRAY, &action_strs, "Actions the user can invoke", "ACTION" }, { "actions", 'A', 0, G_OPTION_ARG_STRING_ARRAY, &action_strs, "Actions the user can invoke", "ACTION" },
{ "timeout", 't', 0, G_OPTION_ARG_INT, &timeout, "The time until the notification expires", "TIMEOUT" }, { "timeout", 't', 0, G_OPTION_ARG_INT, &timeout, "The time until the notification expires", "TIMEOUT" },
{ "icon", 'i', 0, G_OPTION_ARG_STRING, &icon, "An Icon that should be displayed with the notification", "ICON" }, { "icon", 'i', 0, G_OPTION_ARG_STRING, &icon, "An Icon that should be displayed with the notification", "ICON" },
{ "capabilities", 'c', 0, G_OPTION_ARG_NONE, &capabilities, "Print the server capabilities and exit", NULL}, { "capabilities", 'c', 0, G_OPTION_ARG_NONE, &capabilities, "Print the server capabilities and exit", NULL},

View File

@ -1,64 +0,0 @@
#!/usr/bin/env python2
import pynotify
import sys
from optparse import OptionParser
def action_callback(arg):
print "action invoked (%s)" % (arg)
parser = OptionParser()
parser.add_option("-a", "--appname", dest="appname", action="store", default="dunst tester")
parser.add_option("-s", "--summary", dest="summary", action="store", default="summary")
parser.add_option("-b", "--body", dest="body", action="store", default="body")
parser.add_option("-u", "--urgency", dest="urgency", action="store", default="n")
parser.add_option("-A", "--action", dest="action", action="store", default=None)
parser.add_option("-w", "--wait", dest="wait", action="store_true", default=False)
parser.add_option("-t", "--timeout", dest="timeout", action="store", default=-1)
parser.add_option("-H", "--hint", dest="hint", action="store", default=None)
parser.add_option("-r", "--replaces", dest="id", action="store", default=0)
parser.add_option("-c", "--close", dest="close", action="store", default=0)
parser.add_option("-p", "--print_id", dest="print_id", action="store_true", default=False)
(o, args) = parser.parse_args()
pynotify.init(o.appname)
n = pynotify.Notification(o.summary, o.body)
try:
if o.urgency[0] == "l":
n.set_urgency(pynotify.URGENCY_LOW)
if o.urgency[0] == "n":
n.set_urgency(pynotify.URGENCY_NORMAL)
if o.urgency[0] == "c":
n.set_urgency(pynotify.URGENCY_CRITICAL)
except:
pass
if o.action:
n.add_action(o.action.split(":")[0], o.action.split(":")[1], action_callback, None)
if o.id:
n.props.id = int(o.id)
if o.close:
n.props.id = int(o.id)
n.close()
sys.exit(0)
# FIXME hints
n.set_timeout(int(o.timeout))
n.show()
if o.print_id:
nid = n.props.id
print nid
# FIXME wait

View File

@ -6,20 +6,20 @@ function keypress {
} }
function basic_notifications { function basic_notifications {
./notify.py -a "dunst tester" -s "normal" -b "<i>italic body</i>" -u "n" ../dunstify -a "dunst tester" "normal" "<i>italic body</i>"
./notify.py -a "dunst tester" -s "critical" -b "<b>bold body</b>" -u "c" ../dunstify -a "dunst tester" -u c "critical" "<b>bold body</b>"
./notify.py -a "dunst tester" -s "long body" -b "This is a notification with a very long body" ../dunstify -a "dunst tester" "long body" "This is a notification with a very long body"
./notify.py -a "dunst tester" -s "duplucate" ../dunstify -a "dunst tester" "duplucate"
./notify.py -a "dunst tester" -s "duplucate" ../dunstify -a "dunst tester" "duplucate"
./notify.py -a "dunst tester" -s "duplucate" ../dunstify -a "dunst tester" "duplucate"
./notify.py -a "dunst tester" -s "url" -b "www.google.de" ../dunstify -a "dunst tester" "url" "www.google.de"
} }
function show_age { function show_age {
killall dunst killall dunst
../dunst -config dunstrc.show_age & ../dunst -config dunstrc.show_age &
./notify.py -a "dunst tester" -s "Show Age" -b "These should print their age after 2 seconds" -u "c" ../dunstify -a "dunst tester" -u c "Show Age" "These should print their age after 2 seconds"
basic_notifications basic_notifications
keypress keypress
} }
@ -27,24 +27,26 @@ function show_age {
function run_script { function run_script {
killall dunst killall dunst
PATH=".:$PATH" ../dunst -config dunstrc.run_script & PATH=".:$PATH" ../dunst -config dunstrc.run_script &
./notify.py -a "dunst tester" -s "Run Script" -b "After Keypress, 2 other notification should pop up. THis needs notify-send installed" -u "c" ../dunstify -a "dunst tester" -u c \
"Run Script" "After Keypress, 2 other notification should pop up. THis needs notify-send installed"
keypress keypress
./notify.py -a "dunst tester" -s "trigger" -b "this should trigger a notification" -u "c" ../dunstify -a "dunst tester" -u c "trigger" "this should trigger a notification"
keypress keypress
} }
function ignore_newline { function ignore_newline {
killall dunst killall dunst
../dunst -config dunstrc.ignore_newline_no_wrap & ../dunst -config dunstrc.ignore_newline_no_wrap &
./notify.py -a "dunst tester" -s "Ignore Newline No Wrap" -b "There should be no newline anywhere" -u "c" ../.dunstify -a "dunst tester" -u c "Ignore Newline No Wrap" "There should be no newline anywhere"
./notify.py -a "dunst tester" -s "Th\nis\n\n\n is\n fu\nll of \n" -s "\nnew\nlines" -u "c" ../.dunstify -a "dunst tester" -u c "Th\nis\n\n\n is\n fu\nll of \n" "\nnew\nlines"
basic_notifications basic_notifications
keypress keypress
killall dunst killall dunst
../dunst -config dunstrc.ignore_newline & ../dunst -config dunstrc.ignore_newline &
./notify.py -a "dunst tester" -s "Ignore Newline" -b "The only newlines you should encounter here are wordwraps. That's why I'm so long." -u "c" ../dunstify -a "dunst tester" -u c "Ignore Newline" \
./notify.py -a "dunst tester" -s "Th\nis\n\n\n is\n fu\nll of \n" -b "\nnew\nlines" -u "c" "The only newlines you should encounter here are wordwraps. That's why I'm so long."
../dunstify -a "dunst tester" -u c "Th\nis\n\n\n is\n fu\nll of \n" "\nnew\nlines"
basic_notifications basic_notifications
keypress keypress
} }
@ -52,9 +54,9 @@ function ignore_newline {
function replace { function replace {
killall dunst killall dunst
../dunst -config dunstrc.default & ../dunst -config dunstrc.default &
id=$(./notify.py -a "dunst tester" -s "Replace" -b "this should get replaces after keypress" -p) id=$(../dunstify -a "dunst tester" -p "Replace" "this should get replaces after keypress")
keypress keypress
id=$(./notify.py -a "dunst tester" -s "Success?" -b "I hope this is not a new notification" -r $id) ../dunstify -a "dunst tester" -r $id "Success?" "I hope this is not a new notification"
keypress keypress
} }
@ -62,16 +64,16 @@ function replace {
function markup { function markup {
killall dunst killall dunst
../dunst -config dunstrc.markup "200x0+10+10" & ../dunst -config dunstrc.markup "200x0+10+10" &
./notify.py -a "dunst tester" -s "Markup Tests" -u "c" ../dunstify -a "dunst tester" "Markup Tests" -u "c"
./notify.py -a "dunst tester" -s "<b>bold</b> <i>italic</i>" ../dunstify -a "dunst tester" "<b>bold</b> <i>italic</i>"
./notify.py -a "dunst tester" -s "<b>broken markup</i>" ../dunstify -a "dunst tester" "<b>broken markup</i>"
keypress keypress
killall dunst killall dunst
../dunst -config dunstrc.nomarkup "200x0+10+10" & ../dunst -config dunstrc.nomarkup "200x0+10+10" &
./notify.py -a "dunst tester" -s "NO Markup Tests" -u "c" ../dunstify -a "dunst tester" -u c "NO Markup Tests"
./notify.py -a "dunst tester" -s "<b>bold</b><i>italic</i>" ../dunstify -a "dunst tester" "<b>bold</b><i>italic</i>"
./notify.py -a "dunst tester" -s "<b>broken markup</i>" ../dunstify -a "dunst tester" "<b>broken markup</i>"
keypress keypress
} }
@ -79,25 +81,25 @@ function markup {
function corners { function corners {
killall dunst killall dunst
../dunst -config dunstrc.default -geom "200x0+10+10" & ../dunst -config dunstrc.default -geom "200x0+10+10" &
./notify.py -a "dunst tester" -s "upper left" -u "c" ../dunstify -a "dunst tester" -u c "upper left"
basic_notifications basic_notifications
keypress keypress
killall dunst killall dunst
../dunst -config dunstrc.default -geom "200x0-10+10" & ../dunst -config dunstrc.default -geom "200x0-10+10" &
./notify.py -a "dunst tester" -s "upper right" -u "c" ../dunstify -a "dunst tester" -u c "upper right"
basic_notifications basic_notifications
keypress keypress
killall dunst killall dunst
../dunst -config dunstrc.default -geom "200x0-10-10" & ../dunst -config dunstrc.default -geom "200x0-10-10" &
./notify.py -a "dunst tester" -s "lower right" -u "c" ../dunstify -a "dunst tester" -u c "lower right"
basic_notifications basic_notifications
keypress keypress
killall dunst killall dunst
../dunst -config dunstrc.default -geom "200x0+10-10" & ../dunst -config dunstrc.default -geom "200x0+10-10" &
./notify.py -a "dunst tester" -s "lower left" -u "c" ../dunstify -a "dunst tester" -u c "lower left"
basic_notifications basic_notifications
keypress keypress
@ -106,44 +108,44 @@ function corners {
function geometry { function geometry {
killall dunst killall dunst
../dunst -config dunstrc.default -geom "0x0" & ../dunst -config dunstrc.default -geom "0x0" &
./notify.py -a "dunst tester" -s "0x0" -u "c" ../dunstify -a "dunst tester" -u c "0x0"
basic_notifications basic_notifications
keypress keypress
killall dunst killall dunst
../dunst -config dunstrc.default -geom "200x0" & ../dunst -config dunstrc.default -geom "200x0" &
./notify.py -a "dunst tester" -s "200x0" -u "c" ../dunstify -a "dunst tester" -u c "200x0"
basic_notifications basic_notifications
keypress keypress
killall dunst killall dunst
../dunst -config dunstrc.default -geom "200x2" & ../dunst -config dunstrc.default -geom "200x2" &
./notify.py -a "dunst tester" -s "200x2" -u "c" ../dunstify -a "dunst tester" -u c "200x2"
basic_notifications basic_notifications
keypress keypress
killall dunst killall dunst
../dunst -config dunstrc.default -geom "200x1" & ../dunst -config dunstrc.default -geom "200x1" &
./notify.py -a "dunst tester" -s "200x1" -u "c" ../dunstify -a "dunst tester" -u c "200x1"
basic_notifications basic_notifications
keypress keypress
killall dunst killall dunst
../dunst -config dunstrc.default -geom "0x1" & ../dunst -config dunstrc.default -geom "0x1" &
./notify.py -a "dunst tester" -s "0x1" -u "c" ../dunstify -a "dunst tester" -u c "0x1"
basic_notifications basic_notifications
keypress keypress
killall dunst killall dunst
../dunst -config dunstrc.default -geom "-300x1" & ../dunst -config dunstrc.default -geom "-300x1" &
./notify.py -a "dunst tester" -s "-300x1" -u "c" ../dunstify -a "dunst tester" -u c "-300x1"
basic_notifications basic_notifications
keypress keypress
killall dunst killall dunst
../dunst -config dunstrc.default -geom "-300x1-20-20" & ../dunst -config dunstrc.default -geom "-300x1-20-20" &
./notify.py -a "dunst tester" -s "-300x1-20-20" -u "c" ../dunstify -a "dunst tester" -u c "-300x1-20-20"
basic_notifications basic_notifications
keypress keypress
} }
@ -161,8 +163,6 @@ else
ignore_newline ignore_newline
replace replace
markup markup
corners
geometry
fi fi
killall dunst killall dunst