Documentation
¶
Index ¶
- Constants
- func FindFocusHelper(candidates ...string) (string, error)
- func FocusActivationArguments(pid int, protocols ...string) string
- func Push(message string, opts ...NotificationOption) error
- func RegisterFocusProtocol(helperPath string, protocols ...string) error
- type Action
- type Audio
- type FocusActivation
- type NotificationDuration
- type NotificationOption
- func WithActivationArguments(activationArguments string) NotificationOption
- func WithActivationType(activationType string) NotificationOption
- func WithAppID(appID string) NotificationOption
- func WithAudio(audio Audio) NotificationOption
- func WithAudioLoop(b bool) NotificationOption
- func WithDuration(nd NotificationDuration) NotificationOption
- func WithIcon(pathIcon string) NotificationOption
- func WithIconRaw(raw []byte) NotificationOption
- func WithLongDuration() NotificationOption
- func WithMessage(msg string) NotificationOption
- func WithProtocolAction(label string, arguments ...string) NotificationOption
- func WithShortDuration() NotificationOption
- func WithTitle(title string) NotificationOption
Constants ¶
const (
// DefaultFocusProtocol is the protocol used by the bundled focus helper.
DefaultFocusProtocol = "anfocus"
)
Variables ¶
This section is empty.
Functions ¶
func FindFocusHelper ¶
FindFocusHelper locates the helper executable used for toast click-to-focus. Explicit candidates are checked first, followed by conventional helper names next to the current executable.
func FocusActivationArguments ¶
FocusActivationArguments formats the URI passed to WithActivationArguments.
func Push ¶
func Push(message string, opts ...NotificationOption) error
func RegisterFocusProtocol ¶
RegisterFocusProtocol registers protocol as a user-local URL protocol that launches helperPath with the clicked toast URI.
Types ¶
type Action ¶
Action
Defines an actionable button. See https://msdn.microsoft.com/en-us/windows/uwp/controls-and-patterns/tiles-and-notifications-adaptive-interactive-toasts for more info.
Only protocol type action buttons are actually useful, as there's no way of receiving feedback from the user's choice. Examples of protocol type action buttons include: "bingmaps:?q=sushi" to open up Windows 10's maps app with a pre-populated search field set to "sushi".
Action{"protocol", "Open Maps", "bingmaps:?q=sushi"}
type Audio ¶
type Audio string
const ( Silent Audio = "silent" Default Audio = "ms-winsoundevent:Notification.Default" IM Audio = "ms-winsoundevent:Notification.IM" Mail Audio = "ms-winsoundevent:Notification.Mail" Reminder Audio = "ms-winsoundevent:Notification.Reminder" SMS Audio = "ms-winsoundevent:Notification.SMS" LoopingAlarm Audio = "ms-winsoundevent:Notification.Looping.Alarm" LoopingAlarm2 Audio = "ms-winsoundevent:Notification.Looping.Alarm2" LoopingAlarm3 Audio = "ms-winsoundevent:Notification.Looping.Alarm3" LoopingAlarm4 Audio = "ms-winsoundevent:Notification.Looping.Alarm4" LoopingAlarm5 Audio = "ms-winsoundevent:Notification.Looping.Alarm5" LoopingAlarm6 Audio = "ms-winsoundevent:Notification.Looping.Alarm6" LoopingAlarm7 Audio = "ms-winsoundevent:Notification.Looping.Alarm7" LoopingAlarm8 Audio = "ms-winsoundevent:Notification.Looping.Alarm8" LoopingAlarm9 Audio = "ms-winsoundevent:Notification.Looping.Alarm9" LoopingAlarm10 Audio = "ms-winsoundevent:Notification.Looping.Alarm10" LoopingCall Audio = "ms-winsoundevent:Notification.Looping.Call" LoopingCall2 Audio = "ms-winsoundevent:Notification.Looping.Call2" LoopingCall3 Audio = "ms-winsoundevent:Notification.Looping.Call3" LoopingCall4 Audio = "ms-winsoundevent:Notification.Looping.Call4" LoopingCall5 Audio = "ms-winsoundevent:Notification.Looping.Call5" LoopingCall6 Audio = "ms-winsoundevent:Notification.Looping.Call6" LoopingCall7 Audio = "ms-winsoundevent:Notification.Looping.Call7" LoopingCall8 Audio = "ms-winsoundevent:Notification.Looping.Call8" LoopingCall9 Audio = "ms-winsoundevent:Notification.Looping.Call9" LoopingCall10 Audio = "ms-winsoundevent:Notification.Looping.Call10" )
type FocusActivation ¶
FocusActivation describes the protocol activation data used to focus the source window when a Windows toast is clicked.
func PrepareFocusActivation ¶
func PrepareFocusActivation(pid int, helperCandidates ...string) (FocusActivation, error)
PrepareFocusActivation finds the helper, registers the default focus protocol, and returns the URI that should be passed to WithActivationArguments.
type NotificationDuration ¶
type NotificationDuration string
const ( Short NotificationDuration = "short" Long NotificationDuration = "long" )
type NotificationOption ¶
type NotificationOption func(*notification)
func WithActivationArguments ¶
func WithActivationArguments(activationArguments string) NotificationOption
WithActivationArguments
// The activation/action arguments (invoked when the user clicks the notification)
func WithActivationType ¶
func WithActivationType(activationType string) NotificationOption
WithActivationType
The type of notification level action (like Action)
func WithAppID ¶
func WithAppID(appID string) NotificationOption
WithAppID
The name of your app. This value shows up in Windows 10's Action Centre, so make it something readable for your users. It can contain spaces, however special characters (eg. é) are not supported.
func WithAudio ¶
func WithAudio(audio Audio) NotificationOption
WithAudio
The audio to play when displaying the notification
func WithAudioLoop ¶
func WithAudioLoop(b bool) NotificationOption
WithAudioLoop
Whether to loop the audio (default false)
func WithDuration ¶
func WithDuration(nd NotificationDuration) NotificationOption
WithDuration
How long the notification should show up for (short/long)
func WithIcon ¶
func WithIcon(pathIcon string) NotificationOption
WithIcon
An optional path to an image on the OS to display to the left of the title & message.
func WithIconRaw ¶
func WithIconRaw(raw []byte) NotificationOption
func WithLongDuration ¶
func WithLongDuration() NotificationOption
func WithMessage ¶
func WithMessage(msg string) NotificationOption
WithMessage
The single/multi line message to display for the notification.
func WithProtocolAction ¶
func WithProtocolAction(label string, arguments ...string) NotificationOption
WithProtocolAction
Defines an actionable button. See https://msdn.microsoft.com/en-us/windows/uwp/controls-and-patterns/tiles-and-notifications-adaptive-interactive-toasts for more info.
Only protocol type action buttons are actually useful, as there's no way of receiving feedback from the user's choice. Examples of protocol type action buttons include: "bingmaps:?q=sushi" to open up Windows 10's maps app with a pre-populated search field set to "sushi".
Action{"protocol", "Open Maps", "bingmaps:?q=sushi"}
func WithShortDuration ¶
func WithShortDuration() NotificationOption
func WithTitle ¶
func WithTitle(title string) NotificationOption
WithTitle
The main title/heading for the notification.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
toast-focus
command
toast-focus sends a Windows toast notification whose click action focuses the terminal window that launched this process.
|
toast-focus sends a Windows toast notification whose click action focuses the terminal window that launched this process. |
|
toast-focus-helper
command
toast-focus-helper is launched by the anfocus: protocol.
|
toast-focus-helper is launched by the anfocus: protocol. |