Revert "Merge branch '917-event-based-pulseaudio'"
This reverts commit72a888748e
, reversing changes made tod57ef9364a
. This merge causes really high CPU load if using both pasink and pasource, because those two modules trigger each other, and there's not a terrible lot I can do about that, unfortunately.
This commit is contained in:
parent
72a888748e
commit
28601cf2b7
3 changed files with 9 additions and 59 deletions
|
@ -75,7 +75,6 @@ def handle_events(config, update_lock):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global started
|
|
||||||
config = core.config.Config(sys.argv[1:])
|
config = core.config.Config(sys.argv[1:])
|
||||||
level = logging.DEBUG if config.debug() else logging.ERROR
|
level = logging.DEBUG if config.debug() else logging.ERROR
|
||||||
if config.logfile():
|
if config.logfile():
|
||||||
|
@ -98,8 +97,6 @@ def main():
|
||||||
core.input.register(None, core.input.WHEEL_UP, "i3-msg workspace prev_on_output")
|
core.input.register(None, core.input.WHEEL_UP, "i3-msg workspace prev_on_output")
|
||||||
core.input.register(None, core.input.WHEEL_DOWN, "i3-msg workspace next_on_output")
|
core.input.register(None, core.input.WHEEL_DOWN, "i3-msg workspace next_on_output")
|
||||||
|
|
||||||
core.event.trigger("start")
|
|
||||||
|
|
||||||
update_lock = threading.Lock()
|
update_lock = threading.Lock()
|
||||||
event_thread = threading.Thread(target=handle_events, args=(config, update_lock, ))
|
event_thread = threading.Thread(target=handle_events, args=(config, update_lock, ))
|
||||||
event_thread.daemon = True
|
event_thread.daemon = True
|
||||||
|
@ -130,6 +127,7 @@ def main():
|
||||||
if util.format.asbool(config.get("engine.collapsible", True)) == True:
|
if util.format.asbool(config.get("engine.collapsible", True)) == True:
|
||||||
core.input.register(None, core.input.MIDDLE_MOUSE, output.toggle_minimize)
|
core.input.register(None, core.input.MIDDLE_MOUSE, output.toggle_minimize)
|
||||||
|
|
||||||
|
core.event.trigger("start")
|
||||||
started = True
|
started = True
|
||||||
signal.signal(10, sig_USR1_handler)
|
signal.signal(10, sig_USR1_handler)
|
||||||
while True:
|
while True:
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
import threading
|
|
||||||
|
|
||||||
import core.theme
|
import core.theme
|
||||||
import core.event
|
import core.event
|
||||||
|
@ -146,7 +145,6 @@ class i3(object):
|
||||||
self.__content = {}
|
self.__content = {}
|
||||||
self.__theme = theme
|
self.__theme = theme
|
||||||
self.__config = config
|
self.__config = config
|
||||||
self.__lock = threading.Lock()
|
|
||||||
core.event.register("update", self.update)
|
core.event.register("update", self.update)
|
||||||
core.event.register("start", self.draw, "start")
|
core.event.register("start", self.draw, "start")
|
||||||
core.event.register("draw", self.draw, "statusline")
|
core.event.register("draw", self.draw, "statusline")
|
||||||
|
@ -178,7 +176,6 @@ class i3(object):
|
||||||
self.__content[widget_id]["minimized"] = not self.__content[widget_id]["minimized"]
|
self.__content[widget_id]["minimized"] = not self.__content[widget_id]["minimized"]
|
||||||
|
|
||||||
def draw(self, what, args=None):
|
def draw(self, what, args=None):
|
||||||
with self.__lock:
|
|
||||||
cb = getattr(self, what)
|
cb = getattr(self, what)
|
||||||
data = cb(args) if args else cb()
|
data = cb(args) if args else cb()
|
||||||
if "blocks" in data:
|
if "blocks" in data:
|
||||||
|
@ -247,10 +244,6 @@ class i3(object):
|
||||||
return blocks
|
return blocks
|
||||||
|
|
||||||
def update(self, affected_modules=None, redraw_only=False, force=False):
|
def update(self, affected_modules=None, redraw_only=False, force=False):
|
||||||
with self.__lock:
|
|
||||||
self.update2(affected_modules, redraw_only, force)
|
|
||||||
|
|
||||||
def update2(self, affected_modules=None, redraw_only=False, force=False):
|
|
||||||
now = time.time()
|
now = time.time()
|
||||||
for module in self.__modules:
|
for module in self.__modules:
|
||||||
if affected_modules and not module.id in affected_modules:
|
if affected_modules and not module.id in affected_modules:
|
||||||
|
|
|
@ -33,18 +33,12 @@ Requires the following executable:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import os
|
|
||||||
import time
|
|
||||||
import logging
|
import logging
|
||||||
import functools
|
import functools
|
||||||
import threading
|
|
||||||
import subprocess
|
|
||||||
import select
|
|
||||||
|
|
||||||
import core.module
|
import core.module
|
||||||
import core.widget
|
import core.widget
|
||||||
import core.input
|
import core.input
|
||||||
import core.event
|
|
||||||
|
|
||||||
import util.cli
|
import util.cli
|
||||||
import util.graph
|
import util.graph
|
||||||
|
@ -109,36 +103,6 @@ class Module(core.module.Module):
|
||||||
for event in events:
|
for event in events:
|
||||||
core.input.register(self, button=event["button"], cmd=event["action"])
|
core.input.register(self, button=event["button"], cmd=event["action"])
|
||||||
|
|
||||||
self.__monitor = threading.Thread(target=self.__subscribe, args=())
|
|
||||||
self.__monitor.start()
|
|
||||||
|
|
||||||
def __subscribe(self):
|
|
||||||
self.update2()
|
|
||||||
core.event.trigger("update", [self.id], redraw_only=True)
|
|
||||||
try:
|
|
||||||
proc = subprocess.Popen("pactl subscribe",
|
|
||||||
stdout = subprocess.PIPE,
|
|
||||||
stderr = subprocess.STDOUT,
|
|
||||||
shell = True
|
|
||||||
)
|
|
||||||
except:
|
|
||||||
return
|
|
||||||
while threading.main_thread().is_alive():
|
|
||||||
r, w, e = select.select([proc.stdout], [], [], 1)
|
|
||||||
|
|
||||||
if not (r or w or e):
|
|
||||||
self.update2()
|
|
||||||
core.event.trigger("update", [self.id], redraw_only=True)
|
|
||||||
core.event.trigger("draw")
|
|
||||||
continue # timeout
|
|
||||||
# whateve we got, use it
|
|
||||||
self.update2()
|
|
||||||
core.event.trigger("update", [self.id], redraw_only=True)
|
|
||||||
core.event.trigger("draw")
|
|
||||||
os.set_blocking(proc.stdout.fileno(), False)
|
|
||||||
proc.stdout.read()
|
|
||||||
os.set_blocking(proc.stdout.fileno(), True)
|
|
||||||
|
|
||||||
def set_volume(self, amount):
|
def set_volume(self, amount):
|
||||||
util.cli.execute(
|
util.cli.execute(
|
||||||
"pactl set-{}-{} @DEFAULT_{}@ {}".format(
|
"pactl set-{}-{} @DEFAULT_{}@ {}".format(
|
||||||
|
@ -236,11 +200,6 @@ class Module(core.module.Module):
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
if self.__monitor.is_alive():
|
|
||||||
return
|
|
||||||
self.update2()
|
|
||||||
|
|
||||||
def update2(self):
|
|
||||||
try:
|
try:
|
||||||
self._failed = False
|
self._failed = False
|
||||||
channel = "sinks" if self._channel == "sink" else "sources"
|
channel = "sinks" if self._channel == "sink" else "sources"
|
||||||
|
|
Loading…
Reference in a new issue