mirror of
https://github.com/swaywm/sway.git
synced 2024-11-22 07:51:28 +00:00
Created Startup (process manager) Integration (markdown)
parent
22c3844463
commit
1907642ca7
111
Startup-(process-manager)-Integration.md
Normal file
111
Startup-(process-manager)-Integration.md
Normal file
|
@ -0,0 +1,111 @@
|
|||
Sway can be integrated with the event driven task and service manager,
|
||||
[startup](https://gitlab.com/chinstrap/startup).
|
||||
|
||||
This integration offers a simple and unified interface for process management
|
||||
when compared to using Sway standalone. startup can offer integration with
|
||||
logind or ConsoleKit, device hotplug events, ACPI events, network device
|
||||
events, and more.
|
||||
|
||||
Two main paths can be chosen while performing this integration:
|
||||
|
||||
1. startup supervising Sway.
|
||||
2. Sway supervising startup.
|
||||
|
||||
Rather than attempting to explain the benefits of either approach as I see them,
|
||||
I will allow the reader to decide which is best for them.
|
||||
|
||||
## startup supervising Sway
|
||||
|
||||
In this integration mode, information from the Sway session must be injected into
|
||||
startup so that other startup jobs can connect to Sway.
|
||||
|
||||
This can be accomplished by adding the following to your Sway config:
|
||||
|
||||
```
|
||||
exec initctl set-env --global SWAYSOCK="$SWAYSOCK"
|
||||
exec initctl set-env --global I3SOCK="$I3SOCK"
|
||||
exec initctl set-env --global WAYLAND_DISPLAY="$WAYLAND_DISPLAY"
|
||||
# include only if xwayland is enabled and startup jobs need to access X
|
||||
exec initctl set-env --global DISPLAY="$DISPLAY"
|
||||
exec initctl emit sway-session
|
||||
```
|
||||
|
||||
Next, add a startup job configuration for sway, swayidle, swaybg, and mako.
|
||||
|
||||
```
|
||||
# ~/.config/startup/sway.conf
|
||||
start on startup
|
||||
stop on session-end
|
||||
respawn
|
||||
normal exit 0
|
||||
exec env -u UPSTART_JOB sway
|
||||
```
|
||||
|
||||
```
|
||||
# ~/.config/startup/swayidle.conf
|
||||
start on sway-session
|
||||
stop on stopping sway
|
||||
emits swayidle
|
||||
emits swayactive
|
||||
env TIME=60
|
||||
respawn
|
||||
exec swayidle timeout "$TIME" 'initctl emit -n swayidle' \
|
||||
resume 'initctl emit -n swayactive'
|
||||
```
|
||||
|
||||
```
|
||||
# ~/.config/startup/swaybg.conf
|
||||
start on swaybg
|
||||
stop on stopping sway
|
||||
instance $display
|
||||
respawn
|
||||
exec swaybg "${display}" /usr/share/backgrounds/default fill
|
||||
```
|
||||
|
||||
```
|
||||
# ~/.config/startup/swaybg-autostart.conf
|
||||
start on sway-session
|
||||
stop on stopping sway
|
||||
emits swaybg
|
||||
task
|
||||
script
|
||||
for display in $(swaymsg -rt get_outputs | jq -r .[].name); do
|
||||
initctl emit -n swaybg "display=${display}"
|
||||
done
|
||||
end script
|
||||
```
|
||||
|
||||
```
|
||||
# ~/.config/startup/mako.conf
|
||||
start on sway-session
|
||||
stop on stopping sway
|
||||
respawn
|
||||
reload signal 0
|
||||
exec mako
|
||||
```
|
||||
|
||||
If you are using logind or CK, you may want to use inhibitors to detect sleep.
|
||||
|
||||
```
|
||||
# ~/.config/startup/elogind-inhibit.conf
|
||||
start on startup or dbus SIGNAL='PrepareForSleep' ARG0='FALSE' BUS='system' INTERFACE='org.freedesktop.login1.Manager'
|
||||
stop on session-end or dbus SIGNAL='PrepareForSleep' ARG0='TRUE' BUS='system' INTERFACE='org.freedesktop.login1.Manager'
|
||||
respawn
|
||||
exec elogind-inhibit --what=sleep --who=startup --mode=delay --why="Session Sleep Hook" -- pause
|
||||
pre-stop exec initctl emit sleep
|
||||
```
|
||||
|
||||
Then any user services can inhibit the suspend action by hooking into this job's
|
||||
stopping event.
|
||||
|
||||
```
|
||||
# ~/.config/startup/swaylock.conf
|
||||
start on sleep
|
||||
stop on stopping sway
|
||||
respawn
|
||||
normal exit 0
|
||||
exec swaylock
|
||||
```
|
||||
|
||||
You may want to create additional job configurations for services such as
|
||||
dbus, gpg/ssh agent, redshift, or similar.
|
Loading…
Reference in a new issue