-
-
Notifications
You must be signed in to change notification settings - Fork 39
feat(niri): add niri service #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(niri): add niri service #118
Conversation
Fixed scroll handler so you can scroll to switch workspaces. |
Testing is needed... |
@packetverse Great work. Try using idx instead of id in sync_workspace and click for having currect workspace tags in bar. |
After reading this myself I've found that some rough edges need to be smoothed out. Also, it doesn't really match our way of writing code, even though this is a modified version of the I'll try to point you to the mentioned manner through comments. If found no response from you I'll need to close this and maybe reimplement it the right way. |
fabric/niri/service.py
Outdated
super().__init__(**kwargs) | ||
self._ready = False | ||
|
||
self.socket_path = os.getenv("NIRI_SOCKET") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You define the socket_path
here.
fabric/niri/service.py
Outdated
response = {} | ||
try: | ||
client = Gio.SocketClient() | ||
address = Gio.UnixSocketAddress.new(os.getenv("NIRI_SOCKET")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you're not using the socket_path
already defined above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get it that this is a @staticmethod
but why not use the same way we cache the socket path in Hyprland
?
fabric/niri/service.py
Outdated
**kwargs: P.kwargs, | ||
) -> None: | ||
client = Gio.SocketClient() | ||
address = Gio.UnixSocketAddress.new(os.getenv("NIRI_SOCKET")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above...
fabric/niri/service.py
Outdated
event_name = next(iter(event_data)) | ||
event_obj = NiriEvent(name=event_name, data=event_data[event_name], raw=raw_str) | ||
|
||
# logger.debug(f"Emitting event: {event_name} with data: {event_data}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot of commented code in this file...
fabric/niri/widgets.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the service is ready this file is going to be nuked for a much smaller one in footprint making use of the new abstracted window manager specific premade widgets.
The service is very poorly coded and I was definitely rushing, I'll see what I can do, give me a couple of weeks or so. |
I have to add that the widgets are also very poorly coded, I'll start off by refactoring the service and let you review that before getting started on the widgets as well. |
It's fine. Would be better to get rid of the widgets and work only on a service. I'll take care of the widgets. |
Did some refactoring, but needs testing. |
# if not self.socket_path or not os.path.exists(self.socket_path): | ||
# raise NiriSocketNotFoundError("NIRI_SOCKET not found or invalid.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left overs...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that thing even functions? I doubt really...
def __init__(self, commands_only: bool = False, **kwargs): | ||
super().__init__(**kwargs) | ||
self._ready = False | ||
self.lookup_socket() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method returns a cached socket path, however is it not being used...
@staticmethod | ||
def lookup_socket() -> str: | ||
if not os.path.exists(os.getenv("NIRI_SOCKET")): | ||
raise NiriSocketNotFoundError("NIRI_SOCKET not found or invalid.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you check if the niri socket path was present in environment variables. However, you never return anything back as described in the method signature.
# ostream = conn.get_output_stream() | ||
# istream = Gio.DataInputStream.new(conn.get_input_stream()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left overs...
A Fabric-compatible service to interact with the Niri window manager via its IPC socket. | ||
""" | ||
|
||
SOCKET_PATH = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to have a look at how we handle loading and caching the socket path. See Hyprland
.
Generally, This needs testing by the author. |
Yeah, I'll set up a machine with Niri so I can improve the code and test it out as soon as possible. |
Stale? |
I need to make my own pr for niri service I believe |
This pull request introduces a set of new widgets for use with the Niri window manager.
⚙️ Service
A completely new service has been created to handle interactions between Niri and its widgets, enabling IPC communication and real-time updates.
✨ Features
Language
widgetDisplays the current keyboard layout using data from
KeyboardLayoutsChanged
andKeyboardLayoutSwitched
events.ActiveWindow
widgetShows the title and app ID of the currently focused window, updating in real-time.
Workspaces
widgetInteractive workspace buttons reflecting the state of Niri's workspaces.
Supports:
📌 Note
The code is not the cleanest and is mainly based on the Hyprland service, modified to work with Niri. It may need some refactoring and structural improvements, but it works well with no issues so far during testing.