Aar*_*yer 7 command-line unity launcher uck .desktop
我正在使用 UCK(Ubuntu 定制工具包)定制 Ubuntu 14.04 Live CD。该程序在终端中为您提供了一个 chroot 环境以进行更改。
我想添加和删除扩展坞上出现的程序。
我不确定这是否可以通过修改.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)
Run Code Online (Sandbox Code Playgroud)
set_launcher.py
通过以下命令运行它:
python3 /path/to/set_launcher.py <name_of_.desktop_file> a
Run Code Online (Sandbox Code Playgroud)
添加图标,或:
python3 /path/to/set_launcher.py <name_of_.desktop_file> r
Run Code Online (Sandbox Code Playgroud)
删除图标
例子:
python3 /path/to/set_launcher.py gedit.desktop a
Run Code Online (Sandbox Code Playgroud)
添加gedit
到启动器,或
python3 /path/to/set_launcher.py gedit.desktop r
Run Code Online (Sandbox Code Playgroud)
gedit
从启动器中删除
启动器图标列表在键中定义:
com.canonical.Unity.Launcher favorites
Run Code Online (Sandbox Code Playgroud)
并且可以通过以下命令获取:
gsettings get com.canonical.Unity.Launcher favorites
Run Code Online (Sandbox Code Playgroud)
要设置一个替代列表(给你使用正确的格式的事实):
gsettings set com.canonical.Unity.Launcher favorites "[item1, item2, etc]"
Run Code Online (Sandbox Code Playgroud)
.desktop
文件来实现此目的吗?不,它与文件本身无关。重要的是该文件是否在启动器收藏夹列表中。
从命令行编辑此列表正是脚本所做的。
归档时间: |
|
查看次数: |
2143 次 |
最近记录: |