我如何阻止 Ubuntu 覆盖我的 setxkbmap 设置?

我如何阻止 Ubuntu 覆盖我的 setxkbmap 设置?

我已将以下内容放入我的.profile中:

rm -f executed.log
echo ".profile starting" >> executed.log
if [ `whoami` != "root" ] 
    then 
    setxkbmap -v >> executed.log
    setxkbmap -layout "us" -variant "altgr-intl" -option "ctrl:nocaps"
    echo "setxkbmap executed" >> executed.log
    setxkbmap -v >> executed.log
fi

echo ".profile finished" >> executed.log

启动后写入以下日志:

[22:02:21][giorgio@Desmond:~]$ cat executed.log 
.profile starting
Trying to build keymap using the following components:
keycodes:   evdev+aliases(qwerty)
types:      complete
compat:     complete
symbols:    pc+us(altgr-intl)+inet(evdev)
geometry:   pc(pc105)
setxkbmap executed
Trying to build keymap using the following components:
keycodes:   evdev+aliases(qwerty)
types:      complete
compat:     complete
symbols:    pc+us(altgr-intl)+inet(evdev)+ctrl(nocaps)
geometry:   pc(pc105)
.profile finished

但图形登录后我得到:

[22:02:23][giorgio@Desmond:~]$ setxkbmap -v
Trying to build keymap using the following components:
keycodes:   evdev+aliases(qwerty)
types:      complete
compat:     complete
symbols:    pc+us+inet(evdev)
geometry:   pc(pc105)

Unity 似乎正在覆盖我的设置,可能是使用指示器键盘小程序或类似程序。如何禁用它以便我可以使用我的 .profile 设置?

答案1

更新

rm -f executed.log
echo ".profile starting" >> executed.log
if [ $(whoami) != "root" ] 
then 
  echo "$(setxkbmap -v)">> executed.log
  echo "$(setxkbmap -layout "us" -variant "altgr-intl" -option "ctrl:nocaps")"
  echo "setxkbmap executed" >> executed.log
  echo "$(setxkbmap -v)">> executed.log
fi

检查小修正。检查反向引用。

当您登录 GUI 时。它将 setxkbmap 视为字符串。您必须使用反向引号来将这些字符视为命令。

相关内容