Class: AMixer2019
- Inherits:
-
Object
- Object
- AMixer2019
- Defined in:
- lib/amixer2019.rb
Instance Method Summary collapse
-
#fade(raw_val, interval: @fade_interval) ⇒ Object
fades the volume up or down to the volume percentage.
-
#initialize(notch: 5, fade_interval: 0.15, debug: false) ⇒ AMixer2019
constructor
A new instance of AMixer2019.
- #mute ⇒ Object
- #muted? ⇒ Boolean
- #unmute ⇒ Object
- #vol_down ⇒ Object
- #vol_up ⇒ Object
- #volume ⇒ Object (also: #vol)
- #volume=(val) ⇒ Object (also: #vol=)
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 |
#mute ⇒ Object
33 |
# File 'lib/amixer2019.rb', line 33 def mute() sset 'mute' end |
#muted? ⇒ Boolean
34 |
# File 'lib/amixer2019.rb', line 34 def muted?() @muted end |
#unmute ⇒ Object
35 |
# File 'lib/amixer2019.rb', line 35 def unmute() sset 'unmute' end |
#vol_down ⇒ Object
36 |
# File 'lib/amixer2019.rb', line 36 def vol_down() setvol(-@notch) end |
#vol_up ⇒ Object
37 |
# File 'lib/amixer2019.rb', line 37 def vol_up() setvol(+@notch) end |
#volume ⇒ Object 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 |