better -h/--help display

This commit is contained in:
fdev31 2023-04-29 23:05:55 +02:00
parent e00490ee5b
commit 04724162ac
6 changed files with 15 additions and 4 deletions

View file

@ -137,7 +137,7 @@ async def run_daemon():
async def run_client():
if sys.argv[1] == "--help":
if sys.argv[1] in ("--help", "-h"):
manager = Pyprland()
await manager.load_config(init=False)
print(
@ -147,12 +147,16 @@ If command is ommited, runs the daemon which will start every configured command
Commands:
reload"""
reload Reloads the config file (only supports adding or updating plugins)"""
)
for plug in manager.plugins.values():
for name in dir(plug):
if name.startswith("run_") and callable(getattr(plug, name)):
print(f" {name[4:]:20} (from {plug.name})")
if name.startswith("run_"):
fn = getattr(plug, name)
if callable(fn):
print(
f" {name[4:]:20} {fn.__doc__.strip() if fn.__doc__ else 'N/A'} (from {plug.name})"
)
return

View file

@ -19,6 +19,7 @@ def contains(monitor, window):
class Extension(Plugin):
async def run_attract_lost(self, *args):
"""Brings lost floating windows to the current workspace"""
monitors = await hyprctlJSON("monitors")
windows = await hyprctlJSON("clients")
lost = [

View file

@ -8,6 +8,7 @@ class Extension(Plugin):
self.zoomed = False
async def run_zoom(self, *args):
"""[factor] zooms to "factor" or toggles zoom level ommited"""
if args:
value = int(args[0])
await hyprctl(f"misc:cursor_zoom_factor {value}", "keyword")

View file

@ -196,6 +196,7 @@ class Extension(Plugin):
item.just_created = False
async def run_toggle(self, uid: str) -> None:
"""<name> toggles visibility of scratchpad "name" """
uid = uid.strip()
item = self.scratches.get(uid)
if not item:
@ -227,6 +228,7 @@ class Extension(Plugin):
self.scratches_by_address[scratch.clientInfo["address"][2:]] = scratch
async def run_hide(self, uid: str, force=False) -> None:
"""<name> hides scratchpad "name" """
uid = uid.strip()
item = self.scratches.get(uid)
if not item:
@ -262,6 +264,7 @@ class Extension(Plugin):
await hyprctl(f"movetoworkspacesilent special:scratch,{pid}")
async def run_show(self, uid, force=False) -> None:
"""<name> shows scratchpad "name" """
uid = uid.strip()
item = self.scratches.get(uid)

View file

@ -5,6 +5,7 @@ from ..ipc import hyprctlJSON, hyprctl
class Extension(Plugin):
async def run_toggle_dpms(self):
"""toggles dpms on/off for every monitor"""
monitors = await hyprctlJSON("monitors")
poweredOff = any(m["dpmsStatus"] for m in monitors)
if not poweredOff:

View file

@ -28,6 +28,7 @@ class Extension(Plugin):
await hyprctl(batch)
async def run_change_workspace(self, direction: str):
"""<+1/-1> Switch workspaces of current monitor, avoiding displayed workspaces"""
increment = int(direction)
# get focused screen info
monitors = await hyprctlJSON("monitors")