-
Notifications
You must be signed in to change notification settings - Fork 770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start i3 with a systemd service, if systemd is running and the service is loaded. #5591
base: next
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
|
||
# This script tries to start i3 via the i3-session systemd unit if it is loaded | ||
# and systemd is running, otherwise falls back to execing i3 directly. | ||
|
||
# Check if the i3-session systemd unit is loaded. | ||
UNIT_LOAD_STATE=$(systemctl show i3-session.service -P LoadState) | ||
if [[ $? != 0 || "${UNIT_LOAD_STATE}" != "loaded" ]]; then | ||
# The unit is not loaded, or systemctl failed, so just start i3 normally. | ||
exec i3 | ||
fi | ||
|
||
# Start the i3 systemd session. | ||
systemctl start --user --wait i3-session.service |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where does the service get Although I don't often have two instances open, it does happen. My suggestion is to make the unit into a template and use the instance variable like As for |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,11 @@ | ||||||||
[Unit] | ||||||||
Description=i3 Session | ||||||||
|
||||||||
Requires=graphical-session-pre.target | ||||||||
After=graphical-session-pre.target | ||||||||
BindsTo=graphical-session.target | ||||||||
Before=graphical-session.target | ||||||||
|
||||||||
[Service] | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, this might not be the best since it seems like all processes i3 spawns, including applications, then fall under the session slice. |
||||||||
Type=exec | ||||||||
ExecStart=i3 | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Units usually use absolute paths for exec. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
In case the user want's to reload or restart i3. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If run a second time before the first is done, it will hang and wait for the same service. If not implementing support for multiple instances, a check and message for if the service is already running would at least show that the single instance limit is intended.