Refactor fcitx environment variable setup for Japanese locale and adjust default resolution for Xorg

This commit is contained in:
Tatsuya Ishikawa 2026-01-03 23:29:52 +09:00
parent c77143ea3e
commit 373f687623
3 changed files with 66 additions and 28 deletions

View File

@ -178,16 +178,6 @@ RUN set -eux; \
echo 'LANG=ja_JP.UTF-8' > /etc/default/locale; \
echo 'LANGUAGE=ja_JP:ja' >> /etc/default/locale; \
echo 'LC_ALL=ja_JP.UTF-8' >> /etc/default/locale; \
printf '%s\n' \
'export GTK_IM_MODULE=fcitx' \
'export QT_IM_MODULE=fcitx' \
'export XMODIFIERS=@im=fcitx' \
'export INPUT_METHOD=fcitx' \
'export SDL_IM_MODULE=fcitx' \
'export GLFW_IM_MODULE=fcitx' \
'export FCITX_DEFAULT_INPUT_METHOD=mozc' \
> /etc/profile.d/fcitx.sh; \
chmod 644 /etc/profile.d/fcitx.sh; \
printf '%s\n' \
'XKBMODEL="jp106"' \
'XKBLAYOUT="jp"' \
@ -219,16 +209,6 @@ RUN set -eux; \
> /etc/xdg/autostart/fcitx-autostart.desktop; \
cp /etc/xdg/autostart/fcitx-autostart.desktop "/home/${USER_NAME}/.config/autostart/fcitx-autostart.desktop"; \
chown "${USER_UID}:${USER_GID}" "/home/${USER_NAME}/.config/autostart/fcitx-autostart.desktop"; \
printf '%s\n' \
'export GTK_IM_MODULE=fcitx' \
'export QT_IM_MODULE=fcitx' \
'export XMODIFIERS=@im=fcitx' \
'export INPUT_METHOD=fcitx' \
'export SDL_IM_MODULE=fcitx' \
'export GLFW_IM_MODULE=fcitx' \
'export FCITX_DEFAULT_INPUT_METHOD=mozc' \
'fcitx -d >/tmp/fcitx.log 2>&1' \
> "/home/${USER_NAME}/.xprofile"; \
printf '%s\n' \
'[Layout]' \
'DisplayNames=' \
@ -238,9 +218,33 @@ RUN set -eux; \
'ResetOldOptions=true' \
'Use=true' \
> "/home/${USER_NAME}/.config/kxkbrc"; \
chown "${USER_UID}:${USER_GID}" "/home/${USER_NAME}/.xprofile" "/home/${USER_NAME}/.config/kxkbrc"; \
chown "${USER_UID}:${USER_GID}" "/home/${USER_NAME}/.config/kxkbrc"; \
fi
# Set fcitx environment variables globally when Japanese locale is selected
ARG USER_LANGUAGE
RUN LANG_SEL="$(echo "${USER_LANGUAGE}" | tr '[:upper:]' '[:lower:]')" ; \
if [ "${LANG_SEL}" = "ja" ] || [ "${LANG_SEL}" = "ja_jp" ] || [ "${LANG_SEL}" = "ja-jp" ]; then \
mkdir -p /etc/profile.d && \
printf '%s\n' \
'export GTK_IM_MODULE=fcitx' \
'export QT_IM_MODULE=fcitx' \
'export XMODIFIERS="@im=fcitx"' \
'export INPUT_METHOD=fcitx' \
'export SDL_IM_MODULE=fcitx' \
'export GLFW_IM_MODULE=fcitx' \
> /etc/profile.d/99-fcitx-env.sh && \
chmod 644 /etc/profile.d/99-fcitx-env.sh; \
fi
# Apply fcitx ENV globally when USER_LANGUAGE is ja
ENV GTK_IM_MODULE=fcitx \
QT_IM_MODULE=fcitx \
XMODIFIERS="@im=fcitx" \
INPUT_METHOD=fcitx \
SDL_IM_MODULE=fcitx \
GLFW_IM_MODULE=fcitx
# create XDG user dirs and desktop shortcuts (Home/Trash)
RUN set -eux; \
for d in Desktop Documents Downloads Music Pictures Videos Templates Public; do \

View File

@ -1,5 +1,10 @@
#!/usr/bin/env bash
# Setup XDG runtime directory for KDE/Plasma
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/tmp/runtime-$USER}"
mkdir -p "$XDG_RUNTIME_DIR"
chmod 700 "$XDG_RUNTIME_DIR"
# GPU detection and configuration for WebGL/Vulkan/OpenGL support
NVIDIA_PRESENT=false
GPU_AVAILABLE=false
@ -39,11 +44,40 @@ if [ -n "${DISPLAY_REFRESH}" ]; then
export VGL_FPS="${DISPLAY_REFRESH}"
fi
# Start DE with appropriate GPU acceleration
if [ "${GPU_AVAILABLE}" = "true" ] && which vglrun > /dev/null 2>&1; then
echo "Starting desktop with VirtualGL acceleration"
exec vglrun -d "${VGL_DISPLAY:-egl}" +wm dbus-launch --exit-with-session /usr/bin/openbox-session > /dev/null 2>&1
# Set additional session variables for KDE
export XDG_SESSION_ID="${DISPLAY#*:}"
export QT_LOGGING_RULES="${QT_LOGGING_RULES:-*.debug=false;qt.qpa.*=false}"
# Start KDE Plasma desktop with appropriate GPU acceleration
if which startplasma-x11 > /dev/null 2>&1; then
echo "Starting KDE Plasma desktop"
if [ "${GPU_AVAILABLE}" = "true" ] && which vglrun > /dev/null 2>&1; then
echo "Starting with VirtualGL acceleration"
/usr/bin/vglrun -d "${VGL_DISPLAY:-egl}" +wm /usr/bin/dbus-launch --exit-with-session /usr/bin/startplasma-x11 > /tmp/startwm.log 2>&1 &
else
echo "Starting with software rendering"
/usr/bin/dbus-launch --exit-with-session /usr/bin/startplasma-x11 > /tmp/startwm.log 2>&1 &
fi
# Start fcitx if installed
if which fcitx > /dev/null 2>&1; then
/usr/bin/fcitx &
fi
# Keep the script running
echo "Session running. Desktop environment started in background."
wait
elif which openbox-session > /dev/null 2>&1; then
echo "Starting Openbox desktop"
if [ "${GPU_AVAILABLE}" = "true" ] && which vglrun > /dev/null 2>&1; then
echo "Starting with VirtualGL acceleration"
exec vglrun -d "${VGL_DISPLAY:-egl}" +wm dbus-launch --exit-with-session /usr/bin/openbox-session
else
echo "Starting with software rendering"
exec dbus-launch --exit-with-session /usr/bin/openbox-session
fi
else
echo "Starting desktop with software rendering"
exec dbus-launch --exit-with-session /usr/bin/openbox-session > /dev/null 2>&1
echo "ERROR: No desktop environment found"
exit 1
fi

View File

@ -21,7 +21,7 @@ if [ "${DISABLE_DRI3}" != "false" ]; then
fi
# Clamp virtual screen max size based on env
DEFAULT_RES="15360x8640"
DEFAULT_RES="7680x4320"
if [ ! -z ${MAX_RES+x} ]; then
DEFAULT_RES="${MAX_RES}"
fi