Sha256: f2413c7517a32058d2e445e7cf907a083ee432ced2b289d5bab07aa7ba7d26d5
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
# coding: utf-8 module Volume def current_volumes_on_inputs info = `pactl list sink-inputs` inputs = info.scan(/\A#|№(\d+)/).flatten volumes = info.scan(/\W+:\s\w+\W+\w+:\s\d+\s\/\s+(\d+)%/).flatten @current_volumes = inputs.zip(volumes.map(&:to_i)).to_h end def volumes_for_inputs @volumes = {} @current_volumes.each do |input, volume| @volumes.merge!({ input => (volume - volume / 10 * @step) }) end @volumes end def optimize_volume case @flat_volumes when 'yes' if @common_volume > @max_volume @max_volume elsif @common_volume < @min_volume @min_volume else @common_volume end else if @common_volume > @max_volume @max_volume elsif @common_volume < @min_volume @min_volume else 100 end end end def change_volumes(volumes, break_volumes, step) volumes.each do |input, volume| change = volume > break_volumes[input] ? 'down' : 'up' loop do system("pactl set-sink-input-volume #{input} '#{volume * 655}'") change == 'up' ? volume += step : volume -= step break if change == 'up' ? volume > break_volumes[input] : volume < break_volumes[input] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fest-1.4.14 | lib/fest/volume.rb |