我真的很喜欢window spread
Ubuntu 的功能。
有没有办法把它像指示器一样放在顶部面板,以便更快地访问?如果我能把它放在面板角落的菜单图标旁边就更好了。
先谢谢了! :)
答案1
使用 Ubuntu 的指示器功能。
这是一个 Python 示例,它将执行您所描述的功能。运行脚本时,您将在导航栏中看到可点击的指示。
将其另存为myindicator.py
。使其可执行并运行它。
#!/usr/bin/python
# This code is an example for a tutorial on Ubuntu Unity/Gnome AppIndicators:
# http://candidtim.github.io/appindicator/2014/09/13/ubuntu-appindicator-step-by-step.html
# https://gist.github.com/candidtim/7290a1ad6e465d680b68
import os
import signal
import json
import subprocess
from urllib2 import Request, urlopen # URLError
from gi.repository import Gtk as gtk
from gi.repository import AppIndicator3 as appindicator
from gi.repository import Notify as notify
APPINDICATOR_ID = 'myappindicator'
def main():
indicator = appindicator.Indicator.new(APPINDICATOR_ID, os.path.abspath('sample_icon.svg'), appindicator.IndicatorCategory.SYSTEM_SERVICES)
indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
indicator.set_menu(build_menu())
notify.init(APPINDICATOR_ID)
gtk.main()
def build_menu():
menu = gtk.Menu()
item_windowsspread = gtk.MenuItem('Windows Spread')
item_windowsspread.connect('activate', windowsspread)
menu.append(item_windowsspread)
item_quit1 = gtk.MenuItem('Quit')
item_quit1.connect('activate', quit1)
menu.append(item_quit1)
menu.show_all()
return menu
def fetch_joke():
request = Request('http://api.icndb.com/jokes/random?limitTo=[nerdy]')
response = urlopen(request)
joke = json.loads(response.read())['value']['joke']
return joke
def windowsspread(_):
subprocess.call("xdotool key super+w", shell=True)
return windowsspread
def quit1(_):
notify.uninit()
gtk.main_quit()
if __name__ == "__main__":
signal.signal(signal.SIGINT, signal.SIG_DFL)
main()
在 Ubuntu 中制作指标的详细信息可以在这里找到:
Ubuntu 应用程序指标 wiki