Skip to content

Commit

Permalink
Add ipc scripts for pin-view plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
soreau committed Aug 13, 2024
1 parent 248b9a5 commit f1d3972
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ipc-scripts/pin-view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/python3

import os
import sys
from wayfire_socket import *

if len(sys.argv) < 3:
print(f"Usage: {sys.argv[0]} <view_id> <layer> [workspace_x], [workspace_y]")
exit(1)

addr = os.getenv('WAYFIRE_SOCKET')

commands_sock = WayfireSocket(addr)

for view in commands_sock.list_views():
if view["id"] == int(sys.argv[1]):
if len(sys.argv) == 3:
commands_sock.pin_view(int(sys.argv[1]), sys.argv[2], None, None)
if len(sys.argv) == 4:
commands_sock.pin_view(int(sys.argv[1]), sys.argv[2], int(sys.argv[3]), None)
elif len(sys.argv) == 5:
commands_sock.pin_view(int(sys.argv[1]), sys.argv[2], int(sys.argv[3]), int(sys.argv[4]))
17 changes: 17 additions & 0 deletions ipc-scripts/unpin-view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/python3

import os
import sys
from wayfire_socket import *

if len(sys.argv) < 2:
print(f"Usage: {sys.argv[0]} <view_id>")
exit(1)

addr = os.getenv('WAYFIRE_SOCKET')

commands_sock = WayfireSocket(addr)

for view in commands_sock.list_views():
if view["id"] == int(sys.argv[1]):
commands_sock.unpin_view(int(sys.argv[1]))
16 changes: 16 additions & 0 deletions ipc-scripts/wayfire_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,19 @@ def ghost_view_toggle(self, view_id: int):
message = get_msg_template("ghost/ghost_toggle")
message["data"]["view-id"] = view_id
return self.send_json(message)

def pin_view(self, view_id: int, layer: str, ws_x: int, ws_y: int):
message = get_msg_template("pin-view/pin")
message["data"]["view-id"] = view_id
message["data"]["layer"] = layer
if ws_x != None:
message["data"]["x"] = ws_x
message["data"]["y"] = 0
if ws_y != None:
message["data"]["y"] = ws_y
return self.send_json(message)

def unpin_view(self, view_id: int):
message = get_msg_template("pin-view/unpin")
message["data"]["view-id"] = view_id
return self.send_json(message)

0 comments on commit f1d3972

Please sign in to comment.