I am trying to run an i3
command using inotify
. In my case, inotify
is started using systemctl
.
systemctl script:
[Unit]
Description=Inode event watcher
[Service]
User=root
Type=forking
ExecStart=/usr/local/services/inotify/start.sh
[Install]
WantedBy=default.target
/usr/local/services/inotify/start.sh:
I3_CURRENT_WORKSPACE='/etc/i3/script/swiping-workspace/current'
I3_UPDATE_WORKSPACE="/etc/i3/script/swiping-workspace/update.sh"
inotify $I3_WORKSPACE_TRIGGER $I3_WORKSPACE_UPDATE &
Note: my goal here is to execute update.sh
when the current
file is changed on disk.
/etc/i3/script/swiping-workspace/update.sh:
sudo -u $user i3 workspace $(cat $I3_CURRENT_WORKSPACE)
where $user
is the user in which i3 has been installed. I am running this command as root. I also tried these switches, no avail: SCREEN=':0' -E -H
The issue:
When an inotify
event is triggered, an error occurs. Here is the log message I get (using journalctl
):
<date> start.sh[1427]: /etc/i3/script/swiping-workspace/ MODIFY current
<date> sudo[6698]: root : TTY=unknown ; PWD=/ ; USER=$user ; COMMAND=/usr/bin/i3 workspace "6"
<date> sudo[6698]: pam_unix(sudo:session): session opened for user $user by (uid=0)
<date> start.sh[1427]: <date> - Additional arguments passed. Sending them as a command to i3.
<date> start.sh[1427]: <date> - ERROR: Could not get i3 IPC socket path
<date> sudo[6698]: pam_unix(sudo:session): session closed for user $user
I don't understand why i3
fails to receive the command systemctl
sends it.
The whole setup actually works if I start the inotify
command myself (in a unique terminal) instead of using systemctl.
Anybody having a clue?