-
I have an ipc script I want to execute on boot, which uses wayfire socket to detect viewport switches. Here's my systemctl config file: [Unit]
Description=Run run-script-on-viewport-change python script
After=graphical.target
[Service]
ExecStart=/usr/bin/python3 %h/.config/wayfire/ipc-scripts/run-script-on-viewport-change.py
WorkingDirectory=%h/.config/wayfire/ipc-scripts/
Restart=on-failure
[Install]
WantedBy=default.target After noticing it wasn't working on boot because the socket was unavailable, my first guess was the script was probably call too early on startup. So I used a loop to await for the socket, here's my final script: from wayfire import WayfireSocket
import subprocess
TARGET_WINDOW = "Alacritty"
while True:
try:
events_sock = WayfireSocket()
break
except Exception as e:
print("Wayfire socket not available, retrying in 5 seconds...")
time.sleep(5)
events_sock.watch(["view-focused"])
last_window = None
while True:
msg = events_sock.read_message()
if msg["view"] is not None:
current_window = msg["view"]["app-id"]
if last_window == TARGET_WINDOW:
subprocess.run(
['$HOME/.config/tmux/tmux-save-nvim.sh'], shell=True)
last_window = current_window Unfortunately this is still not working, (notice the print in the script), it keeps printing Can you help me to find a clean (and working) solution? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You probably want to have wayfire autostart plugin run this for you. This way, WAYFIRE_SOCKET will be set. |
Beta Was this translation helpful? Give feedback.
You probably want to have wayfire autostart plugin run this for you. This way, WAYFIRE_SOCKET will be set.