Class: AMixer2019

Inherits:
Object
  • Object
show all
Defined in:
lib/amixer2019.rb

Instance Method Summary collapse

Constructor Details

#initialize(notch: 5, fade_interval: 0.15, debug: false) ⇒ AMixer2019

Returns a new instance of AMixer2019.



9
10
11
12
13
14
15
16
# File 'lib/amixer2019.rb', line 9

def initialize(notch: 5, fade_interval: 0.15, debug: false)

  @debug = debug
  @notch, @fade_interval = notch, fade_interval
  @control = `amixer scontrols`[/(?<=')[^']+/]
  query(`amixer get '#{@control}'`)

end

Instance Method Details

#fade(raw_val, interval: @fade_interval) ⇒ Object

fades the volume up or down to the volume percentage



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/amixer2019.rb', line 20

def fade(raw_val, interval: @fade_interval)

  val = raw_val.to_i
  return 'volume must be between 0 and 100' if val < 0 or val > 100
 
  @volume.method(val > @volume ? :upto : :downto).call(val.to_i).each do |x|
    sleep interval; setvol(x.to_s + '%')
  end

  @volume

end

#muteObject



33
# File 'lib/amixer2019.rb', line 33

def mute()        sset 'mute'      end

#muted?Boolean

Returns:

  • (Boolean)


34
# File 'lib/amixer2019.rb', line 34

def muted?()      @muted           end

#unmuteObject



35
# File 'lib/amixer2019.rb', line 35

def unmute()      sset 'unmute'    end

#vol_downObject



36
# File 'lib/amixer2019.rb', line 36

def vol_down()    setvol(-@notch)  end

#vol_upObject



37
# File 'lib/amixer2019.rb', line 37

def vol_up()      setvol(+@notch)  end

#volumeObject Also known as: vol



38
# File 'lib/amixer2019.rb', line 38

def volume()      @volume          end

#volume=(val) ⇒ Object Also known as: vol=



39
# File 'lib/amixer2019.rb', line 39

def volume=(val)  setvol(val)      end