add some log in case of unexpected error
This commit is contained in:
parent
43619bc1ca
commit
19b9741ec3
2 changed files with 37 additions and 1 deletions
27
pyprland/plugins/ironbar.py
Normal file
27
pyprland/plugins/ironbar.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
" Ironbar Plugin "
|
||||
import os
|
||||
import json
|
||||
import asyncio
|
||||
|
||||
from .interface import Plugin
|
||||
|
||||
SOCKET = f"/run/user/{os.getuid()}/ironbar-ipc.sock"
|
||||
|
||||
|
||||
async def ipcCall(**params):
|
||||
ctl_reader, ctl_writer = await asyncio.open_unix_connection(SOCKET)
|
||||
ctl_writer.write(json.dumps(params).encode("utf-8"))
|
||||
await ctl_writer.drain()
|
||||
ret = await ctl_reader.read()
|
||||
ctl_writer.close()
|
||||
await ctl_writer.wait_closed()
|
||||
return json.loads(ret)
|
||||
|
||||
|
||||
class Extension(Plugin):
|
||||
"Toggles ironbar on/off"
|
||||
is_visible = True
|
||||
|
||||
async def run_toggle_ironbar(self, bar_name: str):
|
||||
self.is_visible = not self.is_visible
|
||||
await ipcCall(type="set_visible", visible=self.is_visible, bar_name=bar_name)
|
|
@ -3,6 +3,7 @@ import asyncio
|
|||
import os
|
||||
import subprocess
|
||||
from typing import Any, cast
|
||||
import logging
|
||||
|
||||
from ..ipc import get_focused_monitor_props, hyprctl, hyprctlJSON
|
||||
from .interface import Plugin
|
||||
|
@ -82,6 +83,7 @@ class Animations:
|
|||
|
||||
class Scratch:
|
||||
"A scratchpad state including configuration & client state"
|
||||
log = logging.getLogger("scratch")
|
||||
|
||||
def __init__(self, uid, opts):
|
||||
self.uid = uid
|
||||
|
@ -118,7 +120,14 @@ class Scratch:
|
|||
"update the internal client info property, if not provided, refresh based on the current address"
|
||||
if client_info is None:
|
||||
client_info = await get_client_props_by_address("0x" + self.address)
|
||||
assert isinstance(client_info, dict)
|
||||
try:
|
||||
assert isinstance(client_info, dict)
|
||||
except AssertionError as e:
|
||||
self.log.error(
|
||||
f"client_info of {self.address} must be a dict: {client_info}"
|
||||
)
|
||||
raise AssertionError(e) from e
|
||||
|
||||
self.client_info.update(client_info)
|
||||
|
||||
def __str__(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue