mirror of
https://github.com/caronc/apprise.git
synced 2025-06-21 10:17:46 +02:00
Support -open arg with terminal-notifier (macosx://) (#789)
This commit is contained in:
parent
5e8a2d2f02
commit
48dd88df75
@ -121,9 +121,13 @@ class NotifyMacOSX(NotifyBase):
|
|||||||
'name': _('Sound'),
|
'name': _('Sound'),
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
},
|
},
|
||||||
|
'click': {
|
||||||
|
'name': _('Open/Click URL'),
|
||||||
|
'type': 'string',
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
def __init__(self, sound=None, include_image=True, **kwargs):
|
def __init__(self, sound=None, include_image=True, click=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Initialize MacOSX Object
|
Initialize MacOSX Object
|
||||||
"""
|
"""
|
||||||
@ -137,6 +141,10 @@ class NotifyMacOSX(NotifyBase):
|
|||||||
self.notify_path = next( # pragma: no branch
|
self.notify_path = next( # pragma: no branch
|
||||||
(p for p in self.notify_paths if os.access(p, os.X_OK)), None)
|
(p for p in self.notify_paths if os.access(p, os.X_OK)), None)
|
||||||
|
|
||||||
|
# Click URL
|
||||||
|
# Allow user to provide the `--open` argument on the notify wrapper
|
||||||
|
self.click = click
|
||||||
|
|
||||||
# Set sound object (no q/a for now)
|
# Set sound object (no q/a for now)
|
||||||
self.sound = sound
|
self.sound = sound
|
||||||
|
|
||||||
@ -162,6 +170,9 @@ class NotifyMacOSX(NotifyBase):
|
|||||||
if title:
|
if title:
|
||||||
cmd.extend(['-title', title])
|
cmd.extend(['-title', title])
|
||||||
|
|
||||||
|
if self.click:
|
||||||
|
cmd.extend(['-open', self.click])
|
||||||
|
|
||||||
# The sound to play
|
# The sound to play
|
||||||
if self.sound:
|
if self.sound:
|
||||||
cmd.extend(['-sound', self.sound])
|
cmd.extend(['-sound', self.sound])
|
||||||
@ -203,6 +214,9 @@ class NotifyMacOSX(NotifyBase):
|
|||||||
'image': 'yes' if self.include_image else 'no',
|
'image': 'yes' if self.include_image else 'no',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.click:
|
||||||
|
params['click'] = self.click
|
||||||
|
|
||||||
# Extend our parameters
|
# Extend our parameters
|
||||||
params.update(self.url_parameters(privacy=privacy, *args, **kwargs))
|
params.update(self.url_parameters(privacy=privacy, *args, **kwargs))
|
||||||
|
|
||||||
@ -230,6 +244,10 @@ class NotifyMacOSX(NotifyBase):
|
|||||||
results['include_image'] = \
|
results['include_image'] = \
|
||||||
parse_bool(results['qsd'].get('image', True))
|
parse_bool(results['qsd'].get('image', True))
|
||||||
|
|
||||||
|
# Support 'click'
|
||||||
|
if 'click' in results['qsd'] and len(results['qsd']['click']):
|
||||||
|
results['click'] = NotifyMacOSX.unquote(results['qsd']['click'])
|
||||||
|
|
||||||
# Support 'sound'
|
# Support 'sound'
|
||||||
if 'sound' in results['qsd'] and len(results['qsd']['sound']):
|
if 'sound' in results['qsd'] and len(results['qsd']['sound']):
|
||||||
results['sound'] = NotifyMacOSX.unquote(results['qsd']['sound'])
|
results['sound'] = NotifyMacOSX.unquote(results['qsd']['sound'])
|
||||||
|
@ -126,6 +126,15 @@ def test_plugin_macosx_general_success(macos_notify_environment):
|
|||||||
assert obj.notify(title='title', body='body',
|
assert obj.notify(title='title', body='body',
|
||||||
notify_type=apprise.NotifyType.INFO) is True
|
notify_type=apprise.NotifyType.INFO) is True
|
||||||
|
|
||||||
|
# Test Click (-open support)
|
||||||
|
obj = apprise.Apprise.instantiate(
|
||||||
|
'macosx://_/?click=http://google.com', suppress_exceptions=False)
|
||||||
|
assert isinstance(obj, NotifyMacOSX) is True
|
||||||
|
assert obj.click == 'http://google.com'
|
||||||
|
assert isinstance(obj.url(), str) is True
|
||||||
|
assert obj.notify(title='title', body='body',
|
||||||
|
notify_type=apprise.NotifyType.INFO) is True
|
||||||
|
|
||||||
|
|
||||||
def test_plugin_macosx_terminal_notifier_not_executable(
|
def test_plugin_macosx_terminal_notifier_not_executable(
|
||||||
pretend_macos, terminal_notifier):
|
pretend_macos, terminal_notifier):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user