Skip to content

Commit

Permalink
support sockets moved to $XDG_RUNTIME_DIR/hypr #290
Browse files Browse the repository at this point in the history
  • Loading branch information
nwg-piotr committed Apr 30, 2024
1 parent dfc5104 commit 0fd1c52
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion nwg_panel/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,12 @@ def restart():
def hypr_watcher():
import socket

# /tmp/hypr moved to $XDG_RUNTIME_DIR/hypr in #5788
hypr_dir = f"{os.getenv("XDG_RUNTIME_DIR")}/hypr" if os.path.isdir(
f"{os.getenv("XDG_RUNTIME_DIR")}/hypr") else "/tmp/hypr"

client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
client.connect("/tmp/hypr/{}/.socket2.sock".format(his))
client.connect(f"{hypr_dir}/{his}/.socket2.sock")

global last_client_addr, last_client_title
client_addr, client_title = None, None
Expand Down
6 changes: 5 additions & 1 deletion nwg_panel/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ class SortOrder(Enum):


def hyprctl(cmd):
# /tmp/hypr moved to $XDG_RUNTIME_DIR/hypr in #5788
hypr_dir = f"{os.getenv("XDG_RUNTIME_DIR")}/hypr" if os.path.isdir(
f"{os.getenv("XDG_RUNTIME_DIR")}/hypr") else "/tmp/hypr"

s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
s.connect("/tmp/hypr/{}/.socket.sock".format(os.getenv("HYPRLAND_INSTANCE_SIGNATURE")))
s.connect(f"{hypr_dir}/{os.getenv("HYPRLAND_INSTANCE_SIGNATURE")}/.socket.sock")

s.send(cmd.encode("utf-8"))
output = s.recv(20480).decode('utf-8')
Expand Down
6 changes: 5 additions & 1 deletion nwg_panel/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,9 +820,13 @@ def load_shell_data():


def hyprctl(cmd, buf_size=2048):
# /tmp/hypr moved to $XDG_RUNTIME_DIR/hypr in #5788
hypr_dir = f"{os.getenv("XDG_RUNTIME_DIR")}/hypr" if os.path.isdir(
f"{os.getenv("XDG_RUNTIME_DIR")}/hypr") else "/tmp/hypr"

s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
try:
s.connect("/tmp/hypr/{}/.socket.sock".format(os.getenv("HYPRLAND_INSTANCE_SIGNATURE")))
s.connect(f"{hypr_dir}/{os.getenv("HYPRLAND_INSTANCE_SIGNATURE")}/.socket.sock")
s.send(cmd.encode("utf-8"))

output = b""
Expand Down

0 comments on commit 0fd1c52

Please sign in to comment.