Vit*_*lla 5 cursor-theme mouse-pointer 16.04
过去,我尝试过使用 Unity Tweak Tool 来更改鼠标指针主题。但是,我也想从我的终端更改它。我该如何在 Ubuntu 16.04 上执行此操作?
每个用户的个人资料由数据库管理DConf。您可以阅读我对此问题的回答:Do GUI based application在后台执行shell命令吗? 每个特定设置都有与其关联的模式(有点像 URL)和键(特定设置的名称)。
dconf watch /让我们通过在 UTT 中运行然后更改指针主题来了解当我们更改光标主题时 Unity Tweak Tool 会更改哪些设置:
$ dconf watch /
/org/gnome/desktop/interface/cursor-theme
'crystalblue_classic'
Run Code Online (Sandbox Code Playgroud)
太棒了,现在我们知道要更改什么架构和密钥了!
幸运的是,有一个名为 的命令行实用程序gsettings,我们可以使用它来更改我们需要的设置。该工具经常在 shell 脚本中使用。对于其他类型的语言,例如 Python 或 C,存在 GSettings 库,它允许我们做同样的事情。这里我们特别要使用,gsettings因为它可以在命令行上使用。
需要注意的区别在于,与 不同的是dconf,模式是点分隔的,而不是斜杠分隔的。因此,gsettings会理解org.gnome.desktop.interface模式。
因此,我们能做的是:
$ gsettings set org.gnome.desktop.interface cursor-theme 'redglass'
Run Code Online (Sandbox Code Playgroud)
请注意,在此示例中,我使用的Redglass是已安装的主题之一,而您可能没有,因此请使用您在 UTT 中列出的一些值。
通常,要找到gsettings架构上所有可能的选项,可以使用range选项:
$ gsettings range com.canonical.Unity.Launcher launcher-position
enum
'Left'
'Bottom'
Run Code Online (Sandbox Code Playgroud)
不幸的是,我们需要用来改变光标主题的模式没有enum值:
$ gsettings range org.gnome.desktop.interface cursor-theme
type s
Run Code Online (Sandbox Code Playgroud)
因此,或者,您可以做的(以及 UTT 显然所做的)是列出/usr/share/icons文件夹中具有cursors文件夹的所有目录,如下所示:
$ ls -d /usr/share/icons/*/cursors
/usr/share/icons/crystalblue_classic/cursors/ /usr/share/icons/crystalgray_nonanim/cursors/ /usr/share/icons/crystalwhiteleft_nonanim/cursors/
... more output here
Run Code Online (Sandbox Code Playgroud)
然后只需选择每个主题的文件夹名称作为新值。
当然,我们不想一遍又一遍地处理多个命令。相反,让我们通过 shell 脚本使其变得简单,在这种特殊情况下 - 一个bash脚本(因为我们想要利用数组等高级功能,并且因为我们不努力移植到 Ubuntu 以外的系统),它将列出可用的主题并允许我们选择我们想要的主题。
$ dconf watch /
/org/gnome/desktop/interface/cursor-theme
'crystalblue_classic'
Run Code Online (Sandbox Code Playgroud)
测试运行:
bash-4.3$ ./change_cursor_theme.sh
>>> Please enter the number of new theme for cursor
1) crystalblueleft_nonanim 14) crystalgray_nonanim
2) crystalgreenleft_classic 15) DMZ-Black
3) crystalwhite_nonanim 16) crystalgrayleft
4) handhelds 17) crystalblueleft_classic
5) crystalgreen 18) Deepin-sapphire
6) whiteglass 19) crystalwhiteleft
7) crystalgray 20) crystalgreenleft_nonanim
8) crystalwhiteleft_nonanim 21) crystalgrayleft_nonanim
9) redglass 22) DMZ-White
10) crystalblue 23) crystalblueleft
11) crystalwhite 24) crystalblue_nonanim
12) crystalblue_classic 25) crystalgreenleft
13) crystalgreen_nonanim 26) crystalgreen_classic
#? 9
bash-4.3$
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9794 次 |
| 最近记录: |