fcitx / fcitx5

maybe a new fcitx.
1.57k stars 117 forks source link

在docker-firefox开源项目中运行会存在dbus连接失败 #1027

Closed GODU-LZR closed 4 months ago

GODU-LZR commented 4 months ago

环境为AplineLinux、xvnc、x11、firefox

我按下面issue来做 https://github.com/jlesage/docker-firefox/issues/146

Using fcitx in this image is fairly simple. Start your docker-firefox container as usual Run docker exec -it #your_started_container_name# sh Run  apk add fcitx5 fcitx5-chinese-addons --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing to install fcitx input method Commit your changes to the image Modify startapp.sh, start fcitx along with firefox Start your container with the following env variables setLANG=zh_CN.UTF-8 XMODIFIERS=@im=fcitx GTK_IM_MODULE=fcitx QT_IM_MODULE=fcitx Use Ctrl + Space to switch between English and Chinese 按上面做了后 发现进入vnc环境后不能Ctrl+space切换输入输入法 后面进入docker容器fcitx-remote /tmp # fcitx5-remote terminate called after throwing an instance of 'std::runtime_error' what(): Failed to create dbus connection Aborted (core dumped)

docker-compose.yml文件为 version: '3.3' services: firefox: image: myfirefox container_name: myfirefox environment:

set -e # Exit immediately if a command exits with a non-zero status. set -u # Treat unset variables as an error.

export HOME=/config

PIDS=

notify() { for N in $(ls /etc/logmonitor/targets.d/*/send) do "$N" "$1" "$2" "$3" & PIDS="$PIDS $!" done }

Verify support for membarrier.

if ! /usr/bin/membarrier_check 2>/dev/null; then notify "$APP_NAME requires the membarrier system call." "$APP_NAME is likely t fi

Wait for all PIDs to terminate.

set +e
for PID in "$PIDS"; do
wait $PID
done
set -e

fcitx5 &

/usr/bin/firefox --version exec /usr/bin/firefox "$@" >> /config/log/firefox/output.log 2>> /config/log/fire

然后试着用新的容器自己安装dbus再次启动 命令行为 apk add dbus dbus-x11 rm /run/dbus/dbus.pid mkdir -p /var/run/dbus chmod 755 /var/run/dbus addgroup -S messagebus adduser -S -G messagebus -h /nonexistent -s /sbin/nologin messagebus chown -R root:root /tmp/run/user/app dbus-launch --sh-syntax --exit-with-session > /dev/null & dbus-daemon --system & export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus fcitx5 & 日志输出 /tmp # fcitx5 & /tmp # I2024-04-25 00:01:29.474069 instance.cpp:1348] Override Enabled Addons: {} I2024-04-25 00:01:29.474199 instance.cpp:1349] Override Disabled Addons: {} E2024-04-25 00:01:29.482080 waylandmodule.cpp:229] Failed to open wayland connection I2024-04-25 00:01:29.482131 addonmanager.cpp:193] Loaded addon wayland I2024-04-25 00:01:29.487366 xcbconnection.cpp:189] Connecting to X11 display, display name::0. I2024-04-25 00:01:29.487991 addonmanager.cpp:193] Loaded addon xcb I2024-04-25 00:01:29.490863 addonmanager.cpp:193] Loaded addon quickphrase I2024-04-25 00:01:29.494644 addonmanager.cpp:193] Loaded addon clipboard I2024-04-25 00:01:29.494887 addonmanager.cpp:193] Loaded addon imselector I2024-04-25 00:01:29.507223 addonmanager.cpp:193] Loaded addon keyboard I2024-04-25 00:01:29.507839 addonmanager.cpp:193] Loaded addon waylandim I2024-04-25 00:01:29.508221 addonmanager.cpp:193] Loaded addon unicode I2024-04-25 00:01:29.509746 addonmanager.cpp:193] Loaded addon pinyinhelper I2024-04-25 00:01:29.513590 addonmanager.cpp:193] Loaded addon dbus I2024-04-25 00:01:29.515635 addonmanager.cpp:193] Loaded addon fcitx4frontend I2024-04-25 00:01:29.517349 addonmanager.cpp:193] Loaded addon ibusfrontend I2024-04-25 00:01:29.518478 addonmanager.cpp:193] Loaded addon xim I2024-04-25 00:01:29.519613 addonmanager.cpp:193] Loaded addon dbusfrontend I2024-04-25 00:01:29.535866 inputmethodmanager.cpp:189] Found 737 input method(s) in addon keyboard I2024-04-25 00:01:29.558378 addonmanager.cpp:193] Loaded addon kimpanel I2024-04-25 00:01:29.558861 addonmanager.cpp:193] Loaded addon virtualkeyboard I2024-04-25 00:01:29.610441 classicui.cpp:64] Created classicui for x11 display::0 I2024-04-25 00:01:29.610515 addonmanager.cpp:193] Loaded addon classicui I2024-04-25 00:01:29.614824 addonmanager.cpp:193] Loaded addon notificationitem I2024-04-25 00:01:29.618465 addonmanager.cpp:193] Loaded addon notifications I2024-04-25 00:01:29.620565 kimpanel.cpp:116] Kimpanel new owner: I2024-04-25 00:01:29.620604 virtualkeyboard.cpp:216] VirtualKeyboard new owner: E2024-04-25 00:01:29.620656 portalsettingmonitor.cpp:115] DBus call error: org.freedesktop.DBus.Error.ServiceUnknown The name org.freedesktop.portal.Desktop was not provided by any .service files I2024-04-25 00:01:30.470223 addonmanager.cpp:193] Loaded addon punctuation I2024-04-25 00:01:31.212448 addonmanager.cpp:193] Loaded addon pinyin I2024-04-25 00:01:31.218745 addonmanager.cpp:193] Loaded addon cloudpinyin /tmp # fcitx5-remote terminate called after throwing an instance of 'std::runtime_error' what(): Failed to create dbus connection Aborted (core dumped)

wengxt commented 4 months ago

我推荐你用flatpak 装firefox,如果你只是想要个沙盒

有几个明显的问题,dbus-launch 不是这么用的

eval `dbus-launch --sh-syntax --exit-with-session`

你得把他生成的环境变量 source 到当前的 shell

这一行也不知道是在干嘛 DBUS_SESSION_BUS_ADDRESS=unix:path=/var/run/dbus/system_bus_socket

图形程序不应该用 system bus 也没有权限

建议先读读手册,firefox 不如直接用 xim,用不着 dbus 了

GODU-LZR commented 4 months ago

我需要在xvnc远程控制的x11图形化firefox中使用fcitx5,如何直接使用xim,不用dbus

我推荐你用flatpak 装firefox,如果你只是想要个沙盒

有几个明显的问题,dbus-launch 不是这么用的

eval `dbus-launch --sh-syntax --exit-with-session`

你得把他生成的环境变量 source 到当前的 shell

这一行也不知道是在干嘛 DBUS_SESSION_BUS_ADDRESS=unix:path=/var/run/dbus/system_bus_socket

图形程序不应该用 system bus 也没有权限

建议先读读手册,firefox 不如直接用 xim,用不着 dbus 了

wengxt commented 4 months ago

@GODU-LZR GTK_IM_MODULE=xim

GODU-LZR commented 4 months ago

@GODU-LZR GTK_IM_MODULE=xim 非常感谢 尝试了一下不行,环境中没安dbus,单纯安装fcitx5,它这个远程隔离火狐浏览器开源项目用的环境是alpine Linux+xvnc+x11+firefox 无图形化桌面环境,进入容器只有命令行,用IP端口打开后就有一个远程火狐浏览器页面,然后现在想在火狐浏览器里面使用输入法 issue 里有人成功了 https://github.com/jlesage/docker-firefox/issues/146 微信图片_20240426001823

docker-compose.yml version: '3.3' services: firefox: image: jlesage/firefox container_name: firefox environment:

alpine Linux docker 容器内的/startapp.sh启动脚本

!/bin/sh

set -e # Exit immediately if a command exits with a non-zero status. set -u # Treat unset variables as an error.

export HOME=/config

PIDS=

notify() {
for N in $(ls /etc/logmonitor/targets.d/*/send) do
"$N" "$1" "$2" "$3" &
PIDS="$PIDS $!"
done
}

Verify support for membarrier.

if ! /usr/bin/membarrier_check 2>/dev/null; then
notify "$APP_NAME requires the membarrier system call." "$APP_NAME is likely t fi

Wait for all PIDs to terminate.

set +e
for PID in "$PIDS"; do
wait $PID
done
set -e
fcitx5 &
/usr/bin/firefox --version
exec /usr/bin/firefox "$@" >> /config/log/firefox/output.log 2>> /config/log/fire

wengxt commented 4 months ago

@GODU-LZR 用xim需要有一个可用的locale,你有设置相关的环境或者locale gen吗? locale -a 命令需要输出正常

GODU-LZR commented 4 months ago

@GODU-LZR 用xim需要有一个可用的locale,你有设置相关的环境或者locale gen吗? locale -a 命令需要输出正常

收到,docker-compose.yml中含有- LANG=zh_CN.UTF-8,环境基于上面的回复,alpine Linux不自带locale,然后安装locale->export LANG=zh_CN.UTF-8 ->docker restart,进入容器内 [root@ECS-6461039870 ~]# docker restart firefox firefox [root@ECS-6461039870 ~]# docker exec -it firefox sh /tmp # locale -a C C.UTF-8 a_DJ aa_ER aa_ET af_ZA agr_PE ak_GH am_ET an_ES anp_IN ar_AE ar_BH ar_DZ ar_EG ar_IN ar_IQ ar_JO ar_KW ar_LB ar_LY ar_MA ar_OM ar_QA ar_SA ar_SD ar_SS ar_SY ar_TN ar_YE as_IN ast_ES ayc_PE az_AZ az_IR be_BY bem_ZM ber_DZ ber_MA bg_BG bhb_IN bho_IN bho_NP bi_VU bn_BD bn_IN bo_CN bo_IN br_FR brx_IN bs_BA byn_ER ca_AD ca_ES ca_FR ca_IT ce_RU ch_DE chr_US cmn_TW crh_UA cs_CZ csb_PL cv_RU cy_GB da_DK de_AT de_BE de_CH de_DE de_IT de_LI de_LU doi_IN dsb_DE dv_MV dz_BT el_CY el_GR en_AG en_AU en_BW en_CA en_DK en_GB en_HK en_IE en_IL en_IN en_NG en_NZ en_PH en_SC en_SG en_US en_ZA en_ZM en_ZW eo es_AR es_BO es_CL es_CO es_CR es_CU es_DO es_EC es_ES es_GT es_HN es_MX es_NI es_PA es_PE es_PR es_PY es_SV es_US es_UY es_VE et_EE eu_ES fa_IR ff_SN fi_FI fil_PH fo_FO fr_BE fr_CA fr_CH fr_FR fr_LU fur_IT fy_DE fy_NL ga_IE gd_GB gez_ER gez_ET gl_ES gu_IN gv_GB ha_NG hak_TW he_IL hi_IN hif_FJ hne_IN hr_HR hsb_DE ht_HT hu_HU hy_AM ia_FR id_ID ig_NG ik_CA is_IS it_CH it_IT iu_CA ja_JP ka_GE kab_DZ kk_KZ kl_GL km_KH kn_IN ko_KR kok_IN ks_IN ku_TR kw_GB ky_KG lb_LU lg_UG li_BE li_NL lij_IT ln_CD lo_LA lt_LT lv_LV lzh_TW mag_IN mai_IN mai_NP mfe_MU mg_MG mhr_RU mi_NZ miq_NI mjw_IN mk_MK ml_IN mn_MN mni_IN mnw_MM mr_IN ms_MY mt_MT my_MM nan_TW nb_NO nds_DE nds_NL ne_NP nhn_MX niu_NU niu_NZ nl_AW nl_BE nl_NL nn_NO nr_ZA nso_ZA oc_FR om_ET om_KE or_IN os_RU pa_IN pa_PK pap_AW pap_CW pl_PL ps_AF pt_BR pt_PT quz_PE raj_IN ro_RO ru_RU ru_UA rw_RW sa_IN sah_RU sat_IN sc_IT sd_IN se_NO sgs_LT shn_MM shs_CA si_LK sid_ET sk_SK sl_SI sm_WS so_DJ so_ET so_KE so_SO sq_AL sq_MK sr_ME sr_RS ss_ZA st_ZA sv_FI sv_SE sw_KE sw_TZ szl_PL ta_IN ta_LK tcy_IN te_IN tg_TJ th_TH the_NP ti_ER ti_ET tig_ER tk_TM tl_PH tn_ZA to_TO tpi_PG tr_CY tr_TR ts_ZA tt_RU ug_CN uk_UA unm_US ur_IN ur_PK uz_UZ ve_ZA vi_VN wa_BE wae_CH wal_ET wo_SN xh_ZA yi_US yo_NG yue_HK yuw_PG zh_CN zh_HK zh_SG zh_TW zu_ZA /tmp # locale LANG=zh_CN.UTF-8 LC_CTYPE=zh_CN.UTF-8 LC_NUMERIC=zh_CN.UTF-8 LC_TIME=zh_CN.UTF-8 LC_COLLATE=zh_CN.UTF-8 LC_MONETARY=zh_CN.UTF-8 LC_MESSAGES=zh_CN.UTF-8 LC_ALL= 1234

triumph commented 4 months ago

谁能提供个可以支持中文输入的 docker-firefox, 谢谢

GODU-LZR commented 4 months ago

谁能提供个可以支持中文输入的 docker-firefox, 谢谢

老哥要不加个好友一起研究一下怎么弄