|
51 | 51 |
|
52 | 52 | WINDOW_MANAGERS = {
|
53 | 53 | "x11": "W1",
|
54 |
| - "wayland": "W2", |
| 54 | + "wayfire": "W2", |
55 | 55 | "labwc": "W3",
|
56 | 56 | }
|
57 | 57 |
|
@@ -175,6 +175,12 @@ def write_templated_file(self, output_path, template, **kwargs):
|
175 | 175 | # Render the template with the provided context
|
176 | 176 | rendered_content = self.load_template(template, **kwargs)
|
177 | 177 |
|
| 178 | + if rendered_content is None: |
| 179 | + self.error( |
| 180 | + f"Failed to load template '{template}'. Unable to write file '{output_path}'." |
| 181 | + ) |
| 182 | + return False |
| 183 | + |
178 | 184 | with open(output_path, "w") as output_file:
|
179 | 185 | output_file.write(rendered_content)
|
180 | 186 |
|
@@ -718,6 +724,32 @@ def set_window_manager(self, manager):
|
718 | 724 | ):
|
719 | 725 | raise RuntimeError("Unable to change window manager")
|
720 | 726 |
|
| 727 | + def get_window_manager(self): |
| 728 | + """ |
| 729 | + Get the current window manager |
| 730 | + """ |
| 731 | + sessions = {"wayfire": "LXDE-pi-wayfire"} |
| 732 | + # Check for Raspbian Desktop sessions |
| 733 | + if self.exists("/usr/share/xsessions/rpd-x.desktop") or self.exists( |
| 734 | + "/usr/share/wayland-sessions/rpd-labwc.desktop" |
| 735 | + ): |
| 736 | + sessions = {"x11": "rpd-x", "labwc": "rpd-labwc"} |
| 737 | + else: |
| 738 | + sessions = { |
| 739 | + "x11": "LXDE-pi-x", |
| 740 | + "labwc": "LXDE-pi-labwc", |
| 741 | + } |
| 742 | + |
| 743 | + matches = self.pattern_search( |
| 744 | + "/etc/lightdm/lightdm.conf", "^(?!#.*?)user-session=(.+)", False, True |
| 745 | + ) |
| 746 | + if matches: |
| 747 | + session_match = matches.group(1) |
| 748 | + for key, session in session_match.items(): |
| 749 | + if session == sessions[key]: |
| 750 | + return key |
| 751 | + return None |
| 752 | + |
721 | 753 | def get_boot_config(self):
|
722 | 754 | """
|
723 | 755 | Get the location of the boot config file
|
|
0 commit comments