Я действительно хотел бы иметь свой .sh сценарий для отключения/включения сенсорного экрана на моем компьютере как кнопка в панели вершины гнома (панель индикатора). Я недавно переключил DE от единицы до простого гнома.
Я смог найти, как Вы могли добавить его как значок средства запуска или значок на рабочем столе, но я буду действительно любить иметь его в topbar.
Необходимо было бы создать приложение индикатора.
А быстрый пример, с которым можно работать:
#!/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_myapp = gtk.MenuItem('MyApp')
item_myapp.connect('activate', myapp)
menu.append(item_myapp)
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 myapp(_):
subprocess.call("myapp.sh", shell=True)
return myapp
def quit1(_):
notify.uninit()
gtk.main_quit()
if __name__ == "__main__":
signal.signal(signal.SIGINT, signal.SIG_DFL)
main()
В примере выше просто изменяются myapp.sh
на полный путь Вашего сценария, и он будет работать. Когда Вы запустите скрипт, он поместит объект в индикатор к строке меню.
Детали могут быть найдены в:
http://candidtim.github.io/appindicator/2014/09/13/ubuntu-appindicator-step-by-step.html
и
https://wiki.ubuntu.com/DesktopExperienceTeam/ApplicationIndicators