From e00490ee5bed1ad41d7885841cde54f9ed80d82d Mon Sep 17 00:00:00 2001 From: fdev31 Date: Sat, 29 Apr 2023 21:30:37 +0200 Subject: [PATCH] Add magnify plugin --- README.md | 16 +++++++++++++++- pyprland/plugins/magnify.py | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 pyprland/plugins/magnify.py diff --git a/README.md b/README.md index 72a81ce..5f06f8f 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ A single config file `~/.config/hypr/pyprland.json` is used, using the following - `workspaces_follow_focus` provides commands and handlers allowing a more flexible workspaces usage on multi-monitor setups. If you think the multi-screen behavior of hyprland is not usable or broken/unexpected, this is probably for you. - `lost_windows` brings lost floating windows to the current workspace - `toggle_dpms` toggles the DPMS status of every plugged monitor +- `magnify` toggles zooming of viewport or sets a specific scaling factor ## Installation @@ -89,6 +90,19 @@ Create a configuration file in `~/.config/hypr/pyprland.json` enabling a list of # Configuring plugins +## `magnify` plugin + +### Command + +- `zoom [value]`: if no value, toggles magnification. If an integer is provided, it will set as scaling factor. + +### Configuration + + +#### `factor` + +Scaling factor to be used when no value is provided. + ## `toggle_dpms` plugin ### Command @@ -242,7 +256,7 @@ Just add a method called `run_`, eg with "togglezoom" comm ```python async def init(self): - self.zommed = False + self.zoomed = False async def run_togglezoom(self, args): if self.zoomed: diff --git a/pyprland/plugins/magnify.py b/pyprland/plugins/magnify.py new file mode 100644 index 0000000..6508fba --- /dev/null +++ b/pyprland/plugins/magnify.py @@ -0,0 +1,21 @@ +from .interface import Plugin + +from ..ipc import hyprctlJSON, hyprctl + + +class Extension(Plugin): + async def init(self): + self.zoomed = False + + async def run_zoom(self, *args): + if args: + value = int(args[0]) + await hyprctl(f"misc:cursor_zoom_factor {value}", "keyword") + self.zoomed = value != 1 + else: # toggle + if self.zoomed: + await hyprctl("misc:cursor_zoom_factor 1", "keyword") + else: + fact = int(self.config.get("factor", 2)) + await hyprctl(f"misc:cursor_zoom_factor {fact}", "keyword") + self.zoomed = not self.zoomed