I was writing a systemd
service named 'spliti3.service' which executes a Python script in /usr/bin/
to help automatically adjust windows within 2 columns vertically for my i3wm.
In my /etc/systemd/system/spliti3.service
:
[Unit]
Description=Launches screen with my config
After=network.target
[Service]
Type=simple
User=raz0229
ExecStart=/usr/bin/spliti3
RemainAfterExit=true
StandardOutput=append:$HOME/log0.log
StandardError=append:$HOME/log1.log
[Install]
WantedBy=multi-user.target
Here's part of my Python code that is causing problems.
In /usr/bin/spliti3
:
#!/usr/bin/python3
from i3ipc import Connection, Event
import os
.
.
.
sock_path = os.environ.get('I3SOCK') # Returns NoneType
c = Connection(sock_path)
Seems like the only way to get sock_path
is either through the $I3SOCK
or i3 --get-socket-path
command and can't be hard coded in the script.
Also, the script works just fine when executed on my machine but gives error on os.environ.get('I3SOCK')
when registered as a service through systemctl
.
In the log file, it suggests that sock_path
is None which is odd.
I know there is something wrong with my spliti3.service
but not sure what's causing it.