File: session.rb

package info (click to toggle)
ruby-notiffany 0.1.3-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 580 kB
  • sloc: ruby: 3,094; makefile: 10; sh: 4
file content (40 lines) | stat: -rw-r--r-- 1,288 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
module Notiffany
  class Notifier
    class Tmux < Base
      # Preserves TMux settings for all tmux sessions
      class Session
        def initialize
          @options_store = {}

          # NOTE: we are reading the settings of all clients
          # - regardless of the :display_on_all_clients option

          # Ideally, this should be done incrementally (e.g. if we start with
          # "current" client and then override the :display_on_all_clients to
          # true, only then the option store should be updated to contain
          # settings of all clients
          Client.new(:all).clients.each do |client|
            @options_store[client] = {
              "status-left-bg"  => nil,
              "status-right-bg" => nil,
              "status-left-fg"  => nil,
              "status-right-fg" => nil,
              "message-bg"      => nil,
              "message-fg"      => nil,
              "display-time"    => nil
            }.merge(Client.new(client).parse_options)
          end
        end

        def close
          @options_store.each do |client, options|
            options.each do |key, value|
              Client.new(client).unset(key, value)
            end
          end
          @options_store = nil
        end
      end
    end
  end
end