module Volumerb::LinuxVolume

Public Class Methods

down(value = 3) click to toggle source
# File lib/volumerb/linux_volume.rb, line 8
def self.down(value = 3)
  `amixer -q sset Master #{value}%-`
  vol
end
mute() click to toggle source
# File lib/volumerb/linux_volume.rb, line 13
def self.mute
  `amixer sset Master toggle`
  vol
end
up(value = 3) click to toggle source
# File lib/volumerb/linux_volume.rb, line 3
def self.up(value = 3)
  `amixer -q sset Master #{value}%+`
  vol
end
value=(value) click to toggle source
# File lib/volumerb/linux_volume.rb, line 18
def self.value=(value)
  `amixer set Master #{value}%`
  vol
end
vol() click to toggle source
# File lib/volumerb/linux_volume.rb, line 23
def self.vol
  vol = `amixer get Master | grep "\[[0-9]*%\]\ \[o[n|f]"`
  number = vol.match(/([0-9]+)%/)[1]
  state = vol.match(/\[([a-z]+)\]/)[1]
  { value: number.to_i, state: state.to_s }
end