Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
only Master volume and ON/OFF / MUTE for now
- Loading branch information
Showing
4 changed files
with
46 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# SoundSet, NewSetting [, ComponentType, ControlType, DeviceNumber] | ||
class Cmd::Misc::SoundSet < Cmd::Base | ||
def self.min_args; 1 end | ||
def self.max_args; 4 end | ||
def self.sets_error_level; true end | ||
def run(thread, args) | ||
value = args[0] | ||
on_off = args[2]? && ["onoff","mute"].includes?(args[2].downcase) | ||
if on_off | ||
if value.starts_with?('+') || value.starts_with?('-') | ||
`amixer sset Master toggle` | ||
else | ||
turn_on = value == "0" | ||
if args[2].downcase == "mute" | ||
turn_on = ! turn_on | ||
end | ||
if turn_on | ||
`amixer sset Master mute` | ||
else | ||
`amixer sset Master unmute` | ||
end | ||
end | ||
else | ||
if value.starts_with?('+') || value.starts_with?('-') | ||
sign = value[0] | ||
rel = value[1..] | ||
`amixer sset Master -- #{rel}%#{sign}` | ||
else | ||
`amixer sset Master -- #{value}%` | ||
end | ||
end | ||
"0" | ||
end | ||
end |