[modules/pulseaudio] Only start daemon if not running
Before starting the pulseaudio daemon, ensure that it is not running by using pulseaudio --check. fixes #542
This commit is contained in:
parent
3431129536
commit
1ddcbc454b
1 changed files with 13 additions and 10 deletions
|
@ -25,16 +25,22 @@ import bumblebee.input
|
||||||
import bumblebee.output
|
import bumblebee.output
|
||||||
import bumblebee.engine
|
import bumblebee.engine
|
||||||
|
|
||||||
|
def autostart_daemon():
|
||||||
|
try:
|
||||||
|
bumblebee.util.execute("pulseaudio --check")
|
||||||
|
except Exception:
|
||||||
|
try:
|
||||||
|
bumblebee.util.execute("pulseaudio --start")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
class Module(bumblebee.engine.Module):
|
class Module(bumblebee.engine.Module):
|
||||||
def __init__(self, engine, config):
|
def __init__(self, engine, config):
|
||||||
super(Module, self).__init__(engine, config,
|
super(Module, self).__init__(engine, config,
|
||||||
bumblebee.output.Widget(full_text=self.volume)
|
bumblebee.output.Widget(full_text=self.volume)
|
||||||
)
|
)
|
||||||
try:
|
|
||||||
if bumblebee.util.asbool(self.parameter("autostart", False)):
|
if bumblebee.util.asbool(self.parameter("autostart", False)):
|
||||||
bumblebee.util.execute("pulseaudio --start")
|
autostart_daemon()
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
self._change = 2
|
self._change = 2
|
||||||
self._change = int(self.parameter("percent_change", "2%").strip("%"))
|
self._change = int(self.parameter("percent_change", "2%").strip("%"))
|
||||||
|
@ -167,11 +173,8 @@ class Module(bumblebee.engine.Module):
|
||||||
except Exception:
|
except Exception:
|
||||||
self._failed = True
|
self._failed = True
|
||||||
if bumblebee.util.asbool(self.parameter("autostart", False)):
|
if bumblebee.util.asbool(self.parameter("autostart", False)):
|
||||||
try:
|
autostart_daemon()
|
||||||
bumblebee.util.execute("pulseaudio --start")
|
|
||||||
self.update(widgets)
|
self.update(widgets)
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def state(self, widget):
|
def state(self, widget):
|
||||||
if self._mute:
|
if self._mute:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue