avoid crashed on dpms off; restart on output # changed
This commit is contained in:
@@ -8,6 +8,7 @@ i3 = Connection()
|
||||
ipc_data = None
|
||||
|
||||
outputs = {}
|
||||
windows_list = []
|
||||
taskbars_list = []
|
||||
controls_list = []
|
||||
config_dir = ""
|
||||
|
@@ -40,13 +40,26 @@ try:
|
||||
except:
|
||||
print("pylsa module not found, will try amixer")
|
||||
|
||||
restart_cmd = ""
|
||||
|
||||
|
||||
def signal_handler(sig, frame):
|
||||
print("SIGINT received, terminating")
|
||||
Gtk.main_quit()
|
||||
|
||||
|
||||
def restart():
|
||||
subprocess.Popen(restart_cmd, shell=True)
|
||||
|
||||
|
||||
def check_tree():
|
||||
old = len(common.outputs)
|
||||
common.outputs = list_outputs(silent=True)
|
||||
new = len(common.outputs)
|
||||
if old != 0 and old != new:
|
||||
print("Number of outputs changed")
|
||||
restart()
|
||||
|
||||
# Do if tree changed
|
||||
tree = common.i3.get_tree()
|
||||
if tree.ipc_data != common.ipc_data:
|
||||
@@ -148,6 +161,8 @@ def main():
|
||||
help="css filename (in {}/)".format(common.config_dir))
|
||||
|
||||
args = parser.parse_args()
|
||||
global restart_cmd
|
||||
restart_cmd = "nwg-panel -c {} -s {}".format(args.config, args.style)
|
||||
|
||||
# Try and kill already running instance if any
|
||||
pid_file = os.path.join(temp_dir(), "nwg-panel.pid")
|
||||
@@ -181,6 +196,7 @@ def main():
|
||||
print(e)
|
||||
|
||||
for panel in panels:
|
||||
if panel["output"] in common.outputs:
|
||||
check_key(panel, "spacing", 6)
|
||||
check_key(panel, "homogeneous", False)
|
||||
check_key(panel, "css-name", "")
|
||||
@@ -287,7 +303,7 @@ def main():
|
||||
GtkLayerShell.set_anchor(window, GtkLayerShell.Edge.BOTTOM, 1)
|
||||
|
||||
window.show_all()
|
||||
window.connect('destroy', Gtk.main_quit)
|
||||
#window.connect('destroy', Gtk.main_quit)
|
||||
|
||||
if common.key_missing:
|
||||
print("Saving amended config")
|
||||
|
@@ -133,13 +133,14 @@ def save_string(string, file):
|
||||
print("Error writing file '{}'".format(file))
|
||||
|
||||
|
||||
def list_outputs():
|
||||
def list_outputs(silent=False):
|
||||
"""
|
||||
Get output names and geometry from i3 tree, assign to Gdk.Display monitors.
|
||||
:return: {"name": str, "x": int, "y": int, "width": int, "height": int, "monitor": Gkd.Monitor}
|
||||
"""
|
||||
outputs_dict = {}
|
||||
if common.sway:
|
||||
if not silent:
|
||||
print("Running on sway")
|
||||
for item in common.i3.get_tree():
|
||||
if item.type == "output" and not item.name.startswith("__"):
|
||||
@@ -148,6 +149,7 @@ def list_outputs():
|
||||
"width": item.rect.width,
|
||||
"height": item.rect.height}
|
||||
elif os.getenv('WAYLAND_DISPLAY') is not None:
|
||||
if not silent:
|
||||
print("Running on Wayland, but not sway")
|
||||
if is_command("wlr-randr"):
|
||||
lines = subprocess.check_output("wlr-randr", shell=True).decode("utf-8").strip().splitlines()
|
||||
|
Reference in New Issue
Block a user