Permalink
Browse files

Add timestamps to notification history (fixes #5)

  • Loading branch information...
1 parent 15c672f commit 7a9f2febe38bdd39c98469d7ac9db7bfcc3f8431 @mivok committed Mar 18, 2012
Showing with 9 additions and 1 deletion.
  1. +4 −0 README.md
  2. +5 −1 simplenotify.py
View
@@ -25,6 +25,10 @@ Some of the values you can configure:
~/.simplenotify)
* dzen_args - Arguments to pass to the dzen command. See below for
information on changing this.
+ * timestamp_format - Prefix notifications in the history with a timestamp.
+ The format is the same as that given to strftime, but you need to escape
+ any percent signs. Example: `timestamp_format=(%%H:%%M:%%S)`. Set to
+ blank (`timestamp_format=`) to disable timestamping.
### Changing dzen args
View
@@ -48,7 +48,10 @@ def notify(self, text):
# Main window
self.fh.write("^tw()%s%s\n" % (messages_waiting, text))
# Slave window
- self.fh.write("%s\n" % text)
+ timestamp_format = self.config.get('general', 'timestamp_format')
+ if timestamp_format != '':
+ timestamp_format = "%s " % time.strftime(timestamp_format)
+ self.fh.write("%s%s\n" % (timestamp_format, text))
self.last_updated = time.time()
self.message_count += 1
@@ -79,6 +82,7 @@ def load_configuration():
c.set('general', 'dzen_args', '-l %(dzen_lines)s'
' -tw %(dzen_title_width)s -w %(dzen_slave_width)s'
' -y %(dzen_y)s -x %(dzen_x)s -ta %(dzen_align)s -e %(dzen_events)s')
+ c.set('general', 'timestamp_format', '%%Y-%%m-%%d %%H:%%M:%%S:')
# Load user configuration
c.read(os.path.expanduser('~/.simplenotifyrc'))
return c

0 comments on commit 7a9f2fe

Please sign in to comment.