mydm(5) | File Formats Manual | mydm(5) |
mydm - session scripts format
mydm session scripts are executables stored in $MYDM_SESSION_DIR (by default in $HOME/.local/share/mydm-sessions). They can be any executables, but their most common format is shell scripts which set up the particular session environment.
Scripts can set special options, which use a special syntax. They are set inside the comments, typically near the top of the file, after the shebang, followed by the slash, followed by the option name. For example:
#!/bin/sh #/option
The following options are supported:
#/xsession
It is a good practice, which applies for all kind of sessions to exec whichever program your script ultimately starts.
Users must be aware that session startup is usually quite involved and does a lot of things behind the scenes about which ordinary users are often unaware. These things must be manually replicated in session scripts. The most common ones are:
When in doubt, users are adviced to check the documentation of their Operating System distributions.
#!/bin/bash #/xsession export XDG_CURRENT_DESKTOP=somewm export XDG_SESSION_TYPE=x11 xrdb -merge "$HOME/.Xresources" dbus-update-activation-environment --verbose --systemd --all systemctl --user import-environment exec /usr/bin/dbus-launch /usr/bin/x-window-manager
#!/bin/bash source "${HOME}/.env" source "${HOME}/.activate-dbus-environment export XDG_CURRENT_DESKTOP=sway export XDG_SESSION_TYPE=wayland dbus-update-activation-environment --verbose --systemd --all systemctl --user unset-environment SWAYSOCK I3SOCK WAYLAND_DISPLAY DISPLAY systemctl --user import-environment exec /usr/bin/dbus-launch /usr/bin/sway
A little more involved, but closer to the real world session script includes running a session bus separately:
#!/bin/bash #/xsession # user-session socket has already been set up if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] && \
[ -n "$XDG_RUNTIME_DIR" ] && \
[ "$XDG_RUNTIME_DIR" = "/run/user/`id -u`" ] && \
[ -S "$XDG_RUNTIME_DIR/bus" ]; then
DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus"
export DBUS_SESSION_BUS_ADDRESS fi dbus-update-activation-environment --verbose --systemd \
DBUS_SESSION_BUS_ADDRESS DISPLAY XAUTHORITY # launch dbus if it isn't launched yet if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
eval $(/usr/bin/dbus-launch --exit-with-session --sh-syntax) fi # unset unnecessary env variables safely in a subshell and export environment # to dbus if [ -n "$DBUS_SESSION_BUS_ADDRESS" ]; then
(
unset XDG_SEAT
unset XDG_SESSION_ID
unset XDG_VTNR
dbus-update-activation-environment --verbose --systemd --all
) fi # dbus-update-activation-environment --systemd works only if systemd --user is # available on dbus systemctl --user import-environment exec /usr/bin/x-window-manager
mydm(1) dbus-launch(1) systemctl(1)
Michał Góral <dev@goral.net.pl>
Source code: https://git.goral.net.pl/mydm.git
2024-12-21 |