This commit is contained in:
2026-08-24 11:35:20 +12:00
parent ebf18d2ce7
commit d7453ed56e
3 changed files with 32 additions and 5 deletions
@@ -1,6 +1,7 @@
import os import os
import re import re
import subprocess import subprocess
from typing import override
from ..abstracts import AbstractDisplay from ..abstracts import AbstractDisplay
from ..structs import Modeline, MonitorInfo from ..structs import Modeline, MonitorInfo
@@ -12,6 +13,7 @@ from ._gnome_types import GNOMEDisplayConfig
MODE_REGEX_PATTERN = re.compile(r"(\d+)x(\d+)@(\d+\.\d+)") MODE_REGEX_PATTERN = re.compile(r"(\d+)x(\d+)@(\d+\.\d+)")
class Display(AbstractDisplay): class Display(AbstractDisplay):
@override
def get_modes(self): def get_modes(self):
mutter_display_state = GNOMEDisplayConfig() mutter_display_state = GNOMEDisplayConfig()
mutter_display_state.get_dbus_info() mutter_display_state.get_dbus_info()
@@ -44,6 +46,7 @@ class Display(AbstractDisplay):
return result return result
@override
def set_mode(self, modeline, requested_connector=None) -> None: def set_mode(self, modeline, requested_connector=None) -> None:
subprocess.run( subprocess.run(
[ [
@@ -58,6 +61,7 @@ class Display(AbstractDisplay):
] ]
) )
@override
def save_current_mode(self, location): def save_current_mode(self, location):
gdctl_output = subprocess.run( gdctl_output = subprocess.run(
["gdctl", "show"], capture_output=True, text=True, check=True ["gdctl", "show"], capture_output=True, text=True, check=True
@@ -67,6 +71,7 @@ class Display(AbstractDisplay):
with open(location, "w") as file: with open(location, "w") as file:
file.write(f"{w}x{h}@{r}") file.write(f"{w}x{h}@{r}")
@override
def read_saved_mode(self, location): def read_saved_mode(self, location):
with open(location, "r") as file: with open(location, "r") as file:
config_file_content = file.read() config_file_content = file.read()
@@ -77,5 +82,6 @@ class Display(AbstractDisplay):
return Modeline(width=int(w), height=int(h), refresh_rate=float(r)) return Modeline(width=int(w), height=int(h), refresh_rate=float(r))
@staticmethod @staticmethod
@override
def detect(): def detect():
return "gnome" in os.environ.get("XDG_CURRENT_DESKTOP", "").lower() return "gnome" in os.environ.get("XDG_CURRENT_DESKTOP", "").lower()
+15 -2
View File
@@ -1,15 +1,28 @@
import os import os
from typing import override
from ..abstracts import AbstractDisplay from ..abstracts import AbstractDisplay
from ..structs import MonitorInfo, Modeline
class Display(AbstractDisplay): class Display(AbstractDisplay):
def get_modes(self): @override
def get_modes(self) -> list[MonitorInfo]:
pass pass
def set_mode(self, modeline: str): @override
def set_mode(self, modeline: Modeline, requested_connector: str) -> None:
pass
@override
def read_saved_mode(self, location: str | Path) -> Modeline:
pass
@override
def save_current_mode(self, location: str | Path) -> None:
pass pass
@staticmethod @staticmethod
@override
def detect(): def detect():
return "plasma" in os.environ.get("XDG_CURRENT_DESKTOP", "").lower() return "plasma" in os.environ.get("XDG_CURRENT_DESKTOP", "").lower()
@@ -1,13 +1,21 @@
import os import os
from typing import override
from ..abstracts import AbstractDisplay from ..abstracts import AbstractDisplay
from ..structs import MonitorInfo, Modeline
class Display(AbstractDisplay): class Display(AbstractDisplay):
def get_modes(self): def get_modes(self) -> list[MonitorInfo]:
pass pass
def set_mode(self, modeline: str): def set_mode(self, modeline: Modeline, requested_connector: str) -> None:
pass
def read_saved_mode(self, location: str | Path) -> Modeline:
pass
def save_current_mode(self, location: str | Path) -> None:
pass pass
@staticmethod @staticmethod