Skip to content

Commit

Permalink
Use icon with send-notify and terminal-notifier
Browse files Browse the repository at this point in the history
  • Loading branch information
ku1ik committed Sep 8, 2019
1 parent 9875622 commit cf2f840
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Binary file added asciinema/data/icon-256x256.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 19 additions & 2 deletions asciinema/notifier.py
@@ -1,3 +1,4 @@
import os.path
import shutil
import subprocess

Expand All @@ -11,6 +12,12 @@ def notify(self, text):
# we don't want to print *ANYTHING* to the terminal
# so we capture and ignore all output

def get_icon_path(self):
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data/icon-256x256.png")

if os.path.exists(path):
return path


class AppleScriptNotifier(Notifier):
cmd = "osascript"
Expand All @@ -24,14 +31,24 @@ class LibNotifyNotifier(Notifier):
cmd = "notify-send"

def args(self, text):
return ['notify-send', 'asciinema', text]
icon_path = self.get_icon_path()

if icon_path is not None:
return ['notify-send', '-i', icon_path, 'asciinema', text]
else:
return ['notify-send', 'asciinema', text]


class TerminalNotifier(Notifier):
cmd = "terminal-notifier"

def args(self, text):
return ['terminal-notifier', '-title', 'asciinema', '-message', text]
icon_path = self.get_icon_path()

if icon_path is not None:
return ['terminal-notifier', '-title', 'asciinema', '-message', text, '-appIcon', icon_path]
else:
return ['terminal-notifier', '-title', 'asciinema', '-message', text]


class NoopNotifier():
Expand Down
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -29,6 +29,7 @@
'asciinema = asciinema.__main__:main',
],
},
package_data={'asciinema': ['data/*.png']},
data_files=[('share/doc/asciinema', ['CHANGELOG.md',
'CODE_OF_CONDUCT.md',
'CONTRIBUTING.md',
Expand Down

0 comments on commit cf2f840

Please sign in to comment.