Class: Notiffany::Notifier::Tmux

Inherits:
Base
  • Object
show all
Defined in:
lib/notiffany/notifier/tmux.rb,
lib/notiffany/notifier/tmux/client.rb,
lib/notiffany/notifier/tmux/session.rb,
lib/notiffany/notifier/tmux/notification.rb

Overview

Changes the color of the Tmux status bar and optionally shows messages in the status bar.

Defined Under Namespace

Classes: Client, Error, Notification, Session

Constant Summary collapse

DEFAULTS =
{
  tmux_environment:       "TMUX",
  success:                "green",
  failed:                 "red",
  pending:                "yellow",
  default:                "green",
  timeout:                5,
  display_message:        false,
  default_message_format: "%s - %s",
  default_message_color:  "white",
  display_on_all_clients: false,
  display_title:          false,
  default_title_format:   "%s - %s",
  line_separator:         " - ",
  change_color:           true,
  color_location:         "status-left-bg"
}
ERROR_NOT_INSIDE_TMUX =
":tmux notifier is only available inside a "\
"TMux session."
ERROR_ANCIENT_TMUX =
"Your tmux version is way too old (%s)!"

Constants inherited from Base

Base::ERROR_ADD_GEM_AND_RUN_BUNDLE, Base::HOSTS

Instance Attribute Summary

Attributes inherited from Base

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#_image_path, #initialize, #name, #notify, #title

Constructor Details

This class inherits a constructor from Notiffany::Notifier::Base

Class Method Details

._end_sessionObject


120
121
122
123
124
# File 'lib/notiffany/notifier/tmux.rb', line 120

def _end_session
  fail "Already turned off!" unless @session
  @session.close
  @session = nil
end

._sessionObject


126
127
128
# File 'lib/notiffany/notifier/tmux.rb', line 126

def _session
  @session
end

._start_sessionObject


115
116
117
118
# File 'lib/notiffany/notifier/tmux.rb', line 115

def _start_session
  fail "Already turned on!" if @session
  @session = Session.new
end

Instance Method Details

#turn_offObject

Notification stopping. Restore the previous Tmux state if available (existing options are restored, new options are unset) and unquiet the Tmux output.


52
53
54
# File 'lib/notiffany/notifier/tmux.rb', line 52

def turn_off
  self.class._end_session
end

#turn_onObject

Notification starting, save the current Tmux settings and quiet the Tmux output.


44
45
46
# File 'lib/notiffany/notifier/tmux.rb', line 44

def turn_on
  self.class._start_session
end