From 05bfcf40ed59d64e81fa97af4b97e4ffedf8840f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Cort=C3=A9z?= Date: Sun, 26 Feb 2017 18:07:47 -0600 Subject: [PATCH] Added setters for system volume --- .../commands/commands/dec_alsa_volume.py | 39 +++++++++++++++++++ .../commands/commands/inc_alsa_volume.py | 39 +++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 src/fenrir/commands/commands/dec_alsa_volume.py create mode 100644 src/fenrir/commands/commands/inc_alsa_volume.py diff --git a/src/fenrir/commands/commands/dec_alsa_volume.py b/src/fenrir/commands/commands/dec_alsa_volume.py new file mode 100644 index 00000000..cd2aee07 --- /dev/null +++ b/src/fenrir/commands/commands/dec_alsa_volume.py @@ -0,0 +1,39 @@ +#!/bin/python +# -*- coding: utf-8 -*- + +# Fenrir TTY screen reader +# By Chrys, Storm Dragon, and contributers. + +initialized = False +try: + import alsaaudio + initialized = True +except: + pass + +from core import debug + +class command(): + def __init__(self): + pass + def initialize(self, environment): + self.env = environment + def shutdown(self): + pass + def getDescription(self): + return _("Decrease system volume") + + def run(self): + if not initialized: + self.env['runtime']['outputManager'].presentText(_('alsaaudio is not installed'), interrupt=True) + return + mixer = alsaaudio.Mixer() + value = mixer.getvolume()[0] + value = value - 5 + if value < 5: + value = 5 + mixer.setvolume(value) + self.env['runtime']['outputManager'].presentText(_("{0} percent system volume").format(value), interrupt=True) + + def setCallback(self, callback): + pass diff --git a/src/fenrir/commands/commands/inc_alsa_volume.py b/src/fenrir/commands/commands/inc_alsa_volume.py new file mode 100644 index 00000000..51f38c79 --- /dev/null +++ b/src/fenrir/commands/commands/inc_alsa_volume.py @@ -0,0 +1,39 @@ +#!/bin/python +# -*- coding: utf-8 -*- + +# Fenrir TTY screen reader +# By Chrys, Storm Dragon, and contributers. + +initialized = False +try: + import alsaaudio + initialized = True +except: + pass + +from core import debug + +class command(): + def __init__(self): + pass + def initialize(self, environment): + self.env = environment + def shutdown(self): + pass + def getDescription(self): + return _("Increase system volume") + + def run(self): + if not initialized: + self.env['runtime']['outputManager'].presentText(_('alsaaudio is not installed'), interrupt=True) + return + mixer = alsaaudio.Mixer() + value = mixer.getvolume()[0] + value = value + 5 + if value > 100: + value = 100 + mixer.setvolume(value) + self.env['runtime']['outputManager'].presentText(_("{0} percent system volume").format(value), interrupt=True) + + def setCallback(self, callback): + pass