Class: Cejo::Ops::SoundManager

Inherits:
Object
  • Object
show all
Defined in:
lib/cejo/ops/volume/sound_manager.rb

Overview

Sound manager information

Defined Under Namespace

Classes: ALL

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(utils) ⇒ SoundManager

Returns a new instance of SoundManager.



9
10
11
# File 'lib/cejo/ops/volume/sound_manager.rb', line 9

def initialize(utils)
  @utils = utils
end

Instance Attribute Details

#utilsObject (readonly)

Returns the value of attribute utils.



7
8
9
# File 'lib/cejo/ops/volume/sound_manager.rb', line 7

def utils
  @utils
end

Instance Method Details

#infoObject



36
37
38
# File 'lib/cejo/ops/volume/sound_manager.rb', line 36

def info
  ALL.new(sound_manager, sink[sound_manager])
end

#pactl_sinkObject

Find the running Pactl sink



14
15
16
17
18
19
# File 'lib/cejo/ops/volume/sound_manager.rb', line 14

def pactl_sink
  `pactl list sinks`.split('Sink #').each do |sink|
    sink_id = sink[0]
    return sink_id if sink.include? 'State: RUNNING'
  end
end

#sinkObject



21
22
23
24
25
# File 'lib/cejo/ops/volume/sound_manager.rb', line 21

def sink
  {
    pactl: pactl_sink
  }
end

#sound_managerObject



31
32
33
# File 'lib/cejo/ops/volume/sound_manager.rb', line 31

def sound_manager
  sound_managers.first { |manager| utils.which?(manager) }.to_sym
end

#sound_managersObject



27
28
29
# File 'lib/cejo/ops/volume/sound_manager.rb', line 27

def sound_managers
  %w[pactl amixer mixer]
end

#to_sObject



40
41
42
# File 'lib/cejo/ops/volume/sound_manager.rb', line 40

def to_s
  "#{sound_manager} #{sink}"
end