class Notiffany::Notifier::Tmux
Changes the color of the Tmux
status bar and optionally shows messages in the status bar.
Constants
- DEFAULTS
- ERROR_ANCIENT_TMUX
- ERROR_NOT_INSIDE_TMUX
Private Class Methods
# File lib/notiffany/notifier/tmux.rb, line 120 def _end_session fail "Already turned off!" unless @session @session.close @session = nil end
# File lib/notiffany/notifier/tmux.rb, line 126 def _session @session end
# File lib/notiffany/notifier/tmux.rb, line 115 def _start_session fail "Already turned on!" if @session @session = Session.new end
Public Instance Methods
Notification
stopping. Restore the previous Tmux
state if available (existing options are restored, new options are unset) and unquiet the Tmux
output.
# File lib/notiffany/notifier/tmux.rb, line 52 def turn_off self.class._end_session end
Notification
starting, save the current Tmux
settings and quiet the Tmux
output.
# File lib/notiffany/notifier/tmux.rb, line 44 def turn_on self.class._start_session end
Private Instance Methods
# File lib/notiffany/notifier/tmux.rb, line 62 def _check_available(opts = {}) @session ||= nil # to avoid unitialized error fail "PREVIOUS TMUX SESSION NOT CLEARED!" if @session var_name = opts[:tmux_environment] fail Error, ERROR_NOT_INSIDE_TMUX unless ENV.key?(var_name) version = Client.version fail Error, format(ERROR_ANCIENT_TMUX, version) if version < 1.7 true rescue Error => e fail UnavailableError, e.message end
# File lib/notiffany/notifier/tmux.rb, line 58 def _gem_name nil end
Shows a system notification.
By default, the Tmux
notifier only makes use of a color based notification, changing the background color of the ‘color_location` to the color defined in either the `success`, `failed`, `pending` or `default`, depending on the notification type.
You may enable an extra explicit message by setting ‘display_message` to true, and may further disable the colorization by setting `change_color` to false.
@param [String] message the notification message @param [Hash] options additional notification library options @option options [String] type the notification type. Either ‘success’,
'pending', 'failed' or 'notify'
@option options [String] message the notification message body @option options [String] image the path to the notification image @option options [Boolean] change_color whether to show a color
notification
@option options [String,Array] color_location the location where to draw
the color notification
@option options [Boolean] display_message whether to display a message
or not
@option options [Boolean] display_on_all_clients whether to display a
message on all tmux clients or not
# File lib/notiffany/notifier/tmux.rb, line 103 def _perform_notify(message, options = {}) locations = Array(options[:color_location]) type = options[:type].to_s title = options[:title] tmux = Notification.new(type, options) tmux.colorize(locations) if options[:change_color] tmux.display_title(title, message) if options[:display_title] tmux.display_message(title, message) if options[:display_message] end