ディスプレイマネージャーLightDMの導入

概要

ディスプレイマネージャーをそれまで使っていたLXDMから、Ubuntuなどで使われているLightDMに切り替える。
LightDM - Wikipedia


LXDMに特に不満はなかったが、特定のデスクトップ環境に依存しないように作られた軽量ディスプレイマネージャーという事で、依存関係を減らしたい自分は興味を持った。
なお、Xウィンドウサーバ(X.Org)やディスプレイマネージャーとウィンドウマネージャーの関係については、導入にあたってかなり詳しく調べたので後日まとめて記事にする予定。

インストール

1. DNFでインストール

$ dnf install lightdm

2. デフォルトのXsessionがxprofileを読み込んでくれないので、読み込むXsessionを設定ファイルで変更する。
   設定ファイルは/usr/share/lightdm以下にあるが、
   直接設定はせずユーザー設定用のディレクトリ/etc/lightdm/lightdm.xonf.dにファイルを作ることで上書き設定する。
   (lightdm-sessionの内容は後述の「補遺A」参照)

$ vim /etc/lightdm/lightdm.conf.d/50-session-wrapper.conf 
[Seat:*]
session-wrapper=/etc/lightdm/lightdm-session

3. 壁紙の設定ができるので以下のファイルを編集。
   使用する画像は全ユーザーが読める/usr/share/backgrounds以下に配置する。

$ vim /etc/lightdm/lightdm-gtk-greeter.conf
# 〜〜前略〜〜
[greeter]
background=/usr/share/backgrounds/user/5756963.jpg
# 〜〜後略〜〜

4. systemdにて起動設定
   (最後のstopを実行した時点で画面がコンソールに戻る。暫く待って再起動しないようだったら電源ボタンから再起動。)

$ systemctl disable lxdm
$ systemctl enabel lightdm
$ systemctl stop lxdm

以上

補遺

A. lightdm-sessionの内容
   補遺Bに記載しているLightDM本家のソースコードから取得できるが、バージョン管理のインストールなど色々面倒なので以下に引用。(GPLv3)

#!/bin/bash
#
# LightDM wrapper to run around X sessions.

echo "Running X session wrapper"

message () {
  # pretty-print messages of arbitrary length; use xmessage if it
  # is available and $DISPLAY is set
  MESSAGE="$PROGNAME: $*"
  echo "$MESSAGE" | fold -s -w ${COLUMNS:-80} >&2
  if [ -n "$DISPLAY" ] && which xmessage > /dev/null 2>&1; then
    echo "$MESSAGE" | fold -s -w ${COLUMNS:-80} | xmessage -center -file -
  fi
}

errormsg () {
  # exit script with error
  message "$*"
  exit 1
}

# temporary storage of error messages
ERR=$(mktemp --tmpdir config-err-XXXXXX)

source_with_error_check () {
    CONFIG_FILE="$1"
    echo "Loading $CONFIG_FILE"
    BASH_VERSION= . "$CONFIG_FILE" 2>"$ERR"
    if [ -s "$ERR" ]; then
        . /usr/lib/lightdm/config-error-dialog.sh
    fi
    cat "$ERR" >&2
    truncate -s 0 "$ERR"
}

# Load profile
for file in "/etc/profile" "$HOME/.profile" "/etc/xprofile" "$HOME/.xprofile"; do
    if [ -f "$file" ]; then
        source_with_error_check "$file"
    fi
done

# Load resources
if type xrdb >/dev/null 2>&1; then
    xresourcedir="/etc/X11/Xresources"
    if [ -d "$xresourcedir" ]; then
        for file in $xresourcedir/*; do
            echo "Loading resource: $file"
            xrdb -merge "$file"
        done
    fi
    xresourcefile="$HOME/.Xresources"
    if [ -f "$xresourcefile" ]; then
        echo "Loading resource: $xresourcefile"
        xrdb -merge "$xresourcefile"
    fi
fi

# Load keymaps
if type setxkbmap >/dev/null 2>&1; then
    for file in "/etc/X11/Xkbmap" "$HOME/.Xkbmap"; do
        if [ -f "$file" ]; then
            echo "Loading keymap: $file"
            setxkbmap `cat "$file"`
            XKB_IN_USE=yes
        fi
    done
fi

# Load xmodmap if not using XKB
if type xmodmap >/dev/null 2>&1; then
    if [ -z "$XKB_IN_USE" ]; then
        for file in "/etc/X11/Xmodmap" "$HOME/.Xmodmap"; do
            if [ -f "$file" ]; then
               echo "Loading modmap: $file"
               xmodmap "$file"
            fi
        done
    fi
fi

unset XKB_IN_USE

# Run all system xinitrc shell scripts.
xinitdir="/etc/X11/xinit/xinitrc.d"
if [ -d "$xinitdir" ]; then
    for script in $xinitdir/*; do
        echo "Loading xinit script $script"
        if [ -x "$script" -a ! -d "$script" ]; then
            . "$script"
        fi
    done
fi

# Load Xsession scripts
# OPTIONFILE, USERXSESSION, USERXSESSIONRC and ALTUSERXSESSION are required
# by the scripts to work
xsessionddir="/etc/X11/Xsession.d"
OPTIONFILE=/etc/X11/Xsession.options
USERXSESSION=$HOME/.xsession
USERXSESSIONRC=$HOME/.xsessionrc
ALTUSERXSESSION=$HOME/.Xsession

if [ -d "$xsessionddir" ]; then
    for i in `ls $xsessionddir`; do
        script="$xsessionddir/$i"
        echo "Loading X session script $script"
        if [ -r "$script"  -a -f "$script" ] && expr "$i" : '^[[:alnum:]_-]\+$' > /dev/null; then
            . "$script"
        fi
    done
fi

echo "X session wrapper complete, running session $@"

exec $@

B.ソースコードの取得


lightdmのソースコードを参照するにはBazaarが必要。
Bazaar - Wikipedia

DNFでBazaarをインストールして、2行目でLaunchpadというBazaarのホスティングサービスからソースを取得する。なお、結構な容量(数MB)があるので数分を要する。

dnf install bzr
bzr branch lp:lightdm

コンパイル&インストールは以下のコマンドで実行する。(未実施)

cd lightdm
./autogen.sh
make
make install

感想

壁紙が設定できるようになったのが地味に便利。壁紙出すソフトを探している最中だったのだがその手間が無くなった。


最初Xsessionを変更する設定が効かず非常に迷った。
その関係でXサーバやディスプレイマネージャに必要以上に詳しくなった上ソースコードも取得したのだが、
結果的には一度アンインストールしてファイルから再インストールした所正常動作に戻り、
普通に使えるようになった。


…その辺の顛末を削って必要な作業だけまとめた結果、割と短かい記事に。悔しいので後日調べた内容を別に出す。