Skip to content

Commit

Permalink
Fixed several KDE specific scaling issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim-Luca Lagmöller committed May 14, 2022
1 parent a901c2d commit 4b7a373
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 21 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.2
1.0.3
40 changes: 23 additions & 17 deletions rescreen/lib/environment/desktop_environment/kde.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ def pre_xrandr_hook(cls, scaling: float) -> bool:
return True

if not cls.get_user_confirmation(
"To apply the display configuration, a session restart is required. "
"All currently open applications will be closed. Continue?"
"To apply the display configuration, a session restart is required. "
"All currently open applications will be closed. Continue?"
):
return False

config_dir = cls.CONFIG_DIR.expanduser()

scaling = int(scaling)

subprocess.call(
[
"kwriteconfig5",
Expand Down Expand Up @@ -87,8 +89,8 @@ def pre_xrandr_hook(cls, scaling: float) -> bool:
"",
]
)
.decode("utf-8")
.strip()
.decode("utf-8")
.strip()
)

new_screen_scale_factors = ""
Expand Down Expand Up @@ -127,28 +129,32 @@ def pre_xrandr_hook(cls, scaling: float) -> bool:
]
)

process = subprocess.Popen(
["xrdb", "-quiet", "-merge", "-nocpp"], stdout=PIPE, stdin=PIPE, stderr=STDOUT
)
process.communicate(input=f"Xft.dpi: {font_dpi}\n".encode("utf-8"))

if scaling == 2:
cls.set_cursor_size(36)
else:
cls.set_cursor_size(24)

process = subprocess.Popen(
["xrdb", "-quiet", "-merge", "-nocpp"], stdout=PIPE, stdin=PIPE, stderr=STDOUT
)

process.communicate(input=f"Xft.dpi: {font_dpi}\n".encode("utf-8"))

cls.logout()

return False

@classmethod
def post_xrandr_hook(cls, scaling: float) -> None:
subprocess.call(["killall", "plasmashell"])

env = os.environ
env["PLASMA_USE_QT_SCALING"] = "1"
try:
subprocess.run("killall plasmashell", check=True, shell=True)
except subprocess.CalledProcessError as e:
if e.returncode == 1:
pass # No plasmashell found
else:
raise e

subprocess.call(["kstart5", "plasmashell"], env=env)
subprocess.run("PLASMA_USE_QT_SCALING=1 kstart5 plasmashell", check=True, shell=True)

@classmethod
def get_ui_scale(cls) -> float:
Expand All @@ -166,11 +172,11 @@ def get_ui_scale(cls) -> float:
"1",
]
)
.decode("utf-8")
.strip()
.decode("utf-8")
.strip()
)
return float(scale_factor)

@classmethod
def get_available_ui_scales(cls) -> List[float]:
return [1, 1.25, 1.5, 1.75, 2]
return [1, 2]
14 changes: 11 additions & 3 deletions rescreen/lib/utils/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,24 @@


def get_config_paths(suffix: Optional[Path] = None) -> Tuple[Path, List[Path]]:
config_home = "~/.config"
if "XDG_CONFIG_HOME" in os.environ:
config_home = os.environ["XDG_CONFIG_HOME"]

config_dirs = "/etc/xdg"
if "XDG_CONFIG_DIRS" in os.environ:
config_dirs = os.environ["XDG_CONFIG_DIRS"]

config_home_path = (
Path(os.environ.setdefault("XDG_CONFIG_HOME", "~/.config")).expanduser().absolute()
/ "rescreen"
Path(config_home).expanduser().absolute()
/ "rescreen"
)

if suffix:
config_home_path /= suffix

config_paths = []
for path_str in os.environ.setdefault("XDG_CONFIG_DIRS", "/etc/xdg").split(":"):
for path_str in config_dirs.split(":"):
path = Path(path_str).expanduser().absolute() / "rescreen"
if suffix:
path /= suffix
Expand Down

0 comments on commit 4b7a373

Please sign in to comment.