python Unity启动器指示器改变侧面和自动隐藏

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python Unity启动器指示器改变侧面和自动隐藏相关的知识,希望对你有一定的参考价值。

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" enable-background="new 0 0 64 64"><g fill="#ff9d27"><path d="m10.9 48.7c4-4 4.4-5 6.9-2.5 2.5 2.5 1.5 2.8-2.5 6.9-3 3-6.8 2.4-6.8 2.4s-.6-3.8 2.4-6.8"/><path d="m18.5 52.8c1.6-4.2 2.1-4.7-.2-6-2.3-1.3-2.3-.4-3.8 3.8-1.2 3.1.2 5.9.2 5.9s2.7-.5 3.8-3.7"/></g><path d="m16.2 48.9c.9-2.3.9-2.8 2.1-2.1 1.3.7 1 1 .1 3.3-.6 1.7-2.1 2.1-2.1 2.1s-.7-1.5-.1-3.3" fill="#fdf516"/><path d="m17.1 45.7c-1.3-2.3-1.8-1.8-6-.2-3.1 1.2-3.7 3.8-3.7 3.8s2.8 1.4 5.9.2c4.2-1.6 5.1-1.6 3.8-3.8" fill="#ff9d27"/><g fill="#fdf516"><path d="m15 47.8c2.3-.9 2.8-.9 2.1-2.1-.7-1.3-1-1-3.3-.1-1.7.6-2.1 2.1-2.1 2.1s1.6.7 3.3.1"/><path d="m13.9 47.6c2.2-2.2 2.4-2.8 3.8-1.4 1.4 1.4.8 1.6-1.4 3.8-1.7 1.7-3.8 1.3-3.8 1.3s-.2-2 1.4-3.7"/></g><path d="M18.5,38C12.3,27.6,2,31.9,2,31.9s14.7-14.7,24.6-4.8L18.5,38z" fill="#3baacf"/><path d="m23.3 30.3l3.2-3.2c-9.8-9.9-24.5 4.8-24.5 4.8s12.9-9.2 21.3-1.6" fill="#428bc1"/><path d="M26,45.5C36.4,51.7,32.1,62,32.1,62s14.7-14.7,4.8-24.6L26,45.5z" fill="#3baacf"/><path d="m33.7 40.7l3.2-3.2c9.9 9.9-4.8 24.6-4.8 24.6s9.2-13 1.6-21.4" fill="#428bc1"/><path d="m48.8 30.9c-11.7 11.6-24.6 17.9-29.1 13.4-4.5-4.5 1.8-17.4 13.4-29.1 13.6-13.6 28.7-13 28.7-13s.5 15.1-13 28.7" fill="#c5d0d8"/><path d="M45.8,27.6C34.2,39.2,22.6,46.8,19.9,44.1c-2.7-2.7,4.9-14.3,16.5-25.9C50,4.6,62,2,62,2S59.4,14,45.8,27.6z" fill="#dae3ea"/><path d="m24.3 47.5c-.5.5-1.3.5-1.8 0l-6-6c-.5-.5-.5-1.4 0-1.9l1.8-1.8 7.8 7.8-1.8 1.9" fill="#c94747"/><path d="m22.6 45.7c-.5.5-1.1.7-1.4.4l-3.4-3.4c-.3-.3-.1-.9.4-1.4l1.8-1.8 4.4 4.4-1.8 1.8" fill="#f15744"/><path d="m20.9 48.2c-.3.3-1 .3-1.3 0l-3.9-3.9c-.3-.3-.2-.9.1-1.2l1.2-1.2 5.1 5.1-1.2 1.2" fill="#3e4347"/><path d="m20.1 47.4c-.3.3-.9.4-1.1.2l-2.7-2.7c-.2-.2-.1-.7.3-1l1.2-1.2 3.5 3.5-1.2 1.2" fill="#62727a"/><path d="m61.8 2.2c0 0-5.4-.2-12.7 2.6l10.1 10.1c2.8-7.3 2.6-12.7 2.6-12.7" fill="#c94747"/><path d="m61.8 2.2c0 0-4.3.9-10.8 4.6l6.2 6.2c3.7-6.5 4.6-10.8 4.6-10.8" fill="#f15744"/><circle cx="43.5" cy="20.5" r="5" fill="#edf4f9"/><circle cx="43.5" cy="20.5" r="3.3" fill="#3baacf"/><circle cx="33.5" cy="30.5" r="5" fill="#edf4f9"/><circle cx="33.5" cy="30.5" r="3.3" fill="#3baacf"/><g fill="#fff"><path d="m48.9 6.9c-.3.3-.9.3-1.2 0-.3-.3-.3-.9 0-1.2.3-.3.9-.3 1.2 0 .3.3.3.9 0 1.2"/><circle cx="50.6" cy="8.6" r=".8"/><circle cx="53" cy="11" r=".8"/><circle cx="55.3" cy="13.4" r=".8"/><circle cx="57.7" cy="15.7" r=".8"/></g></svg>
#!/usr/bin/env python3

import os
import gi
from subprocess import call

gi.require_version('Gtk', '3.0')
gi.require_version('AppIndicator3', '0.1')
gi.require_version('Notify', '0.7')

from gi.repository import Gtk
from gi.repository import AppIndicator3
from gi.repository import Notify

scriptlen = len(os.path.basename(__file__))

if os.path.islink(__file__):
    root = os.readlink(__file__)[:-int(scriptlen)]
else:
    root = os.path.dirname(__file__)

APPINDICATOR_ID = 'changelauncherlocation'
APP_NAME = 'Change Launcher Location'
APP_VERSION = '1.0.0'
APP_INDICATOR_ICON = os.path.abspath(os.path.join(root, 'indicator.svg'))

# Commands
# --------
#
# Set the launcher to the BOTTOM
#  $ gsettings set com.canonical.Unity.Launcher launcher-position Bottom
#
# Set the launcher to the LEFT
#  $ gsettings set com.canonical.Unity.Launcher launcher-position Left
#
# Set the launcher autohide to ON
#  $ gsettings set org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ launcher-hide-mode 1
#
# Set the launcher autohide to OFF
#  $ gsettings set org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ launcher-hide-mode 0


class ChangeLauncherLocationApp():

    def __init__(self, *args, **kwargs):
        indicator = AppIndicator3.Indicator.new(
            APPINDICATOR_ID,
            APP_INDICATOR_ICON,
            AppIndicator3.IndicatorCategory.SYSTEM_SERVICES
        )
        indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
        indicator.set_menu(self._build_menu())
        Notify.init(APPINDICATOR_ID)
        Gtk.main()

    def quit(self):
        Notify.uninit()
        Gtk.main_quit()

    def _build_menu(self):
        menu = Gtk.Menu()

        # Add "left" item
        item_left = Gtk.MenuItem('Left')
        item_left.connect('activate', self._set_menu_left)
        menu.append(item_left)

        # Add "bottom" item
        item_bottom = Gtk.MenuItem('Bottom')
        item_bottom.connect('activate', self._set_menu_bottom)
        menu.append(item_bottom)

        # Add "separator"
        separator1 = Gtk.SeparatorMenuItem()
        separator1.show()
        menu.append(separator1)

        # Add "autohide ON" item
        item_autohide_on = Gtk.MenuItem('Autohide ON')
        item_autohide_on.connect('activate', self._set_menu_autohide_on)
        menu.append(item_autohide_on)

        # Add "autohide OFF" item
        item_autohide_off = Gtk.MenuItem('Autohide OFF')
        item_autohide_off.connect('activate', self._set_menu_autohide_off)
        menu.append(item_autohide_off)

        # Add "separator"
        separator2 = Gtk.SeparatorMenuItem()
        separator2.show()
        menu.append(separator2)

        # Add "quit" item
        item_quit = Gtk.MenuItem('Quit')
        item_quit.connect('activate', quit)
        menu.append(item_quit)

        menu.show_all()

        return menu

    def _set_menu_left(self, event):
        call(["gsettings", "set", "com.canonical.Unity.Launcher", "launcher-position", "Left"])
        Notify.Notification.new("Launcher Change", "The launcher was repositioned to the LEFT.").show()

    def _set_menu_bottom(self, event):
        call(["gsettings", "set", "com.canonical.Unity.Launcher", "launcher-position", "Bottom"])
        Notify.Notification.new("Launcher Change", "The launcher was repositioned to the BOTTOM.").show()

    def _set_menu_autohide_on(self, event):
        call(["gsettings", "set", "org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/", "launcher-hide-mode", "1"])
        Notify.Notification.new("Launcher Change", "The launcher autohide setting was set to ON.").show()

    def _set_menu_autohide_off(self, event):
        call(["gsettings", "set", "org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/", "launcher-hide-mode", "0"])
        Notify.Notification.new("Launcher Change", "The launcher autohide setting was set to OFF.").show()


# Create the app
app = ChangeLauncherLocationApp()

以上是关于python Unity启动器指示器改变侧面和自动隐藏的主要内容,如果未能解决你的问题,请参考以下文章

Unity 拖拽图片自动改变图片纹理类型

Unity 自动编译后启动Unity

Tradingview Pine脚本-如何使自定义音量指示器的行为类似于内置的Vol

ubuntu14.04安装bodhi桌面系统后,unity启动界面改变,如何还原

unity3d中. 地面上有一个文字, 文字上有一个cube, 现在我想在上方往下看,能透过cube看的到文字,

Unity 实战篇 | 一键生成 x *y 的方阵,并按照地图配置自动改变方阵中某个格子的属性