/etc/profile.d/ 中的脚本未在 X 登录时运行 (debian)

/etc/profile.d/ 中的脚本未在 X 登录时运行 (debian)

以下脚本:

name='ILITEK ILITEK-TP'
echo 'running touchscreens' | systemd-cat
ids=$(xinput --list |awk -Fid= "/$name/"'{print $2+0}')
echo 'after xinput' | systemd-cat
for id in $ids
do event=$(xinput list-props "$id" | awk -F'"' '/Device Node/{print $2}')
   path=$(udevadm info "$event" |
          awk -F/ '/DEVPATH=/{printf "%s \n",$7}')
   if [[ "$path" == *"1-5"* ]]; then
      screen='HDMI-2'
      #echo "$id $path $screen"
      xinput map-to-output $id $screen
   elif [[ "$path" == *"1-6"* ]]; then
      screen='HDMI-3'
      #echo "$id $path $screen"
      xinput map-to-output $id $screen
   fi
done

如果由用户执行,则可以正常工作。但是,它不会在作为 X 会话用户登录时运行,尽管位于 中/etc/profile.d/并以 结尾.sh。另一方面,如果我通过 SSH 登录,它就会运行,但这与我希望它运行的时间完全相反。

这一定意味着/etc/profile当 X 会话登录时也许根本没有被调用?我怎样才能让它运行?我的窗口管理器是肉桂。

更新:我将脚本移动到,/etc/X11/Xsession.d/现在它运行了,但是似乎还为时过早,因为它还xinput map-to-output不能正常工作,或者在脚本执行后被覆盖。

更新 2:将脚本放在 ~/.bashrc 中是可行的,但只有在启动终端后才有效。这让我发疯

答案1

在 debian 系统上,创建自定义 .xsession 文件并将其放置在登录用户的主目录中,其中自定义 X 命令后跟exec {yourwindowmanager}.

根据要求编辑,即

xinput map-to-output 12 HDMI-1
exec gnome-session

相关内容