我正在使用UCK(Ubuntu定制工具包)自定义一个Ubuntu 14.04的Live CD。该程序在终端中提供了一个chroot环境,用于进行更改。
我想要添加和删除出现在dock上的程序。
我不确定是否可以通过修改.desktop文件来实现这一目标?
如何使用终端完成这个任务?
我想要添加和删除出现在dock上的程序。
我不确定是否可以通过修改.desktop文件来实现这一目标?
如何使用终端完成这个任务?
#!/usr/bin/env python3
import subprocess
import sys
desktopfile = sys.argv[1]
def current_launcher():
get_current = subprocess.check_output(["gsettings", "get", "com.canonical.Unity.Launcher", "favorites"]).decode("utf-8")
return eval(get_current)
def set_launcher(desktopfile):
curr_launcher = current_launcher()
last = [i for i, x in enumerate(curr_launcher) if x.startswith("application://")][-1]
new_icon = "application://"+desktopfile
if sys.argv[2] == "a":
if not new_icon in curr_launcher:
curr_launcher.insert(last, new_icon)
subprocess.Popen(["gsettings", "set", "com.canonical.Unity.Launcher","favorites",str(curr_launcher)])
elif sys.argv[2] == "r":
curr_launcher.remove(new_icon)
subprocess.Popen(["gsettings", "set", "com.canonical.Unity.Launcher","favorites",str(curr_launcher)])
set_launcher(desktopfile)
set_launcher.py
通过以下命令运行它:
python3 /path/to/set_launcher.py <name_of_.desktop_file> a
添加图标,或者:
python3 /path/to/set_launcher.py <name_of_.desktop_file> r
移除图标
示例:
python3 /path/to/set_launcher.py gedit.desktop a
将gedit
添加到启动器,或者
python3 /path/to/set_launcher.py gedit.desktop r
从启动器中移除gedit
启动器图标列表在键中定义:
com.canonical.Unity.Launcher favorites
gsettings get com.canonical.Unity.Launcher favorites
gsettings set com.canonical.Unity.Launcher favorites "[item1, item2, etc]"
.desktop
文件来实现这个吗?dconf-editor
或类似工具找到所提及的模式。请问现在它存储在哪里?谢谢! - artu-hnrq