python类SessionBus()的实例源码

backlightindicator.py 文件源码 项目:backlight-indicator 作者: atareao 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def main():
    print('=== starting Backlight Indicator ===')
    if dbus.SessionBus().request_name('es.atareao.BacklightIndicator') != \
            dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER:
        print("application already running")
        exit(0)
    Notify.init('BacklightIndicator')
    BacklightIndicator()
    print('=== started Backlight Indicator === ')
    Gtk.main()
notify.py 文件源码 项目:dotfiles 作者: nfischer 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def notify(summary, body='', app_name='', app_icon='',
        timeout=DEFAULT_TIMEOUT, actions=[], hints=[], replaces_id=0):
    _bus_name = 'org.freedesktop.Notifications'
    _object_path = '/org/freedesktop/Notifications'
    _interface_name = _bus_name

    session_bus = dbus.SessionBus()
    obj = session_bus.get_object(_bus_name, _object_path)
    interface = dbus.Interface(obj, _interface_name)
    interface.Notify(app_name, replaces_id, app_icon,
            summary, body, actions, hints, timeout)

# If run as a script, just display the argv as summary
wifi_warn.py 文件源码 项目:dotfiles 作者: nfischer 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def notify(summary, body='', app_name='', app_icon='',
           timeout=DEFAULT_TIMEOUT, actions=[], hints=[], replaces_id=0):
    _bus_name = 'org.freedesktop.Notifications'
    _object_path = '/org/freedesktop/Notifications'
    _interface_name = _bus_name

    session_bus = dbus.SessionBus()
    obj = session_bus.get_object(_bus_name, _object_path)
    interface = dbus.Interface(obj, _interface_name)
    interface.Notify(app_name, replaces_id, app_icon,
            summary, body, actions, hints, timeout)

# If run as a script, just display the argv as summary
mpris_dbus.py 文件源码 项目:kawaii-player 作者: kanishka-linux 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def __init__(self, ui, home, tr_ay, new_tr):
        global tray, new_tray_widget
        tray = tr_ay
        new_tray_widget = new_tr
        bus = dbus.service.BusName(
            AW_MPRIS_BUS_NAME,
            bus=dbus.SessionBus())
        super().__init__(bus, MPRIS_OBJECT_PATH)

        self._properties = dbus.Dictionary({
            'DesktopEntry': 'kawaii-player',
            'Identity': 'kawaii-player', 
            }, signature='sv')

        self._player_properties = dbus.Dictionary({
            'Metadata': dbus.Dictionary({
                'mpris:artUrl': '',
                'xesam:artist': ['None'],
                'xesam:title': 'None',
                'xesam:album': 'None'
            }, signature='sv', variant_level=1), 
            'CanGoNext': True,
            'CanGoPrevious': True,
            'CanPause': True,
            'CanPlay': True,
            'CanControl': True,
            'CanStop': True,
        }, signature='sv', variant_level=2)

        self.ui = ui
        self.home = home
spotilib.py 文件源码 项目:Spotilyrics 作者: eitchtee 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def linux_status():
    try:
        session_bus = dbus.SessionBus()
        spotify_bus = session_bus.get_object("org.mpris.MediaPlayer2.spotify",
                                             "/org/mpris/MediaPlayer2")
        spotify_properties = dbus.Interface(spotify_bus,
                                            "org.freedesktop.DBus.Properties")
        status = spotify_properties.Get("org.mpris.MediaPlayer2.Player",
                                        "PlaybackStatus")
        return status
    except:
        return "Paused"
spotilib.py 文件源码 项目:Spotilyrics 作者: eitchtee 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def song_info_linux():
    if linux_status() == "Playing":
        session_bus = dbus.SessionBus()
        spotify_bus = session_bus.get_object("org.mpris.MediaPlayer2.spotify",
                                             "/org/mpris/MediaPlayer2")
        spotify_properties = dbus.Interface(spotify_bus,
                                            "org.freedesktop.DBus.Properties")
        metadata = spotify_properties.Get(
            "org.mpris.MediaPlayer2.Player", "Metadata")
        song_info = metadata['xesam:title']
        return song_info
    else:
        return "There is nothing playing at this moment"
spotilib.py 文件源码 项目:Spotilyrics 作者: eitchtee 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def artist_info_linux():
    if linux_status() == "Playing":
        session_bus = dbus.SessionBus()
        spotify_bus = session_bus.get_object("org.mpris.MediaPlayer2.spotify",
                                             "/org/mpris/MediaPlayer2")
        spotify_properties = dbus.Interface(spotify_bus,
                                            "org.freedesktop.DBus.Properties")
        metadata = spotify_properties.Get(
            "org.mpris.MediaPlayer2.Player", "Metadata")
        artist_info = metadata['xesam:artist'][0]
        return artist_info
    else:
        return "There is nothing playing at this moment"
spotilib.py 文件源码 项目:Spotilyrics 作者: eitchtee 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def next():
    if platform.system() == 'Linux':
        bus = dbus.SessionBus()
        proxy = bus.get_object(
            'org.mpris.MediaPlayer2.spotify', '/org/mpris/MediaPlayer2')
        interface = dbus.Interface(
            proxy, dbus_interface='org.mpris.MediaPlayer2.Player')
        interface.Next()
    elif platform.system() == 'Windows':
        win32api.keybd_event(Media_Next, hwcode(Media_Next))
spotilib.py 文件源码 项目:Spotilyrics 作者: eitchtee 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def previous():
    if platform.system() == 'Linux':
        bus = dbus.SessionBus()
        proxy = bus.get_object(
            'org.mpris.MediaPlayer2.spotify', '/org/mpris/MediaPlayer2')
        interface = dbus.Interface(
            proxy, dbus_interface='org.mpris.MediaPlayer2.Player')
        interface.Previous()
    elif platform.system() == 'Windows':
        win32api.keybd_event(Media_Previous, hwcode(Media_Previous))
spotilib.py 文件源码 项目:Spotilyrics 作者: eitchtee 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def play():
    if platform.system() == 'Linux':
        bus = dbus.SessionBus()
        proxy = bus.get_object(
            'org.mpris.MediaPlayer2.spotify', '/org/mpris/MediaPlayer2')
        interface = dbus.Interface(
            proxy, dbus_interface='org.mpris.MediaPlayer2.Player')
        interface.PlayPause()
    elif platform.system() == 'Windows':
        win32api.keybd_event(Media_Pause, hwcode(Media_Pause))
do_timeout.py 文件源码 项目:pomodoroTasks2 作者: liloman 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self):
        self.tw = TaskWarrior()
        builder.add_from_file("gui/timeout.glade")
        self.wTimeout     = builder.get_object("wTimeout")
        self.pbTimeout    = builder.get_object("pbTimeout")
        self.wContinue    = builder.get_object("wContinue")
        self.lsbReminders = builder.get_object("lsbReminders")
        self.bus = dbus.SessionBus()
        self.session_bus = self.bus.get_object('org.liloman.pomodoro', "/daemon")
        self.interface = dbus.Interface(self.session_bus, "org.liloman.pomodoroInterface")

        ################
        #  Set events  #
        ################

        self.btYes = builder.get_object("btYes")
        self.btYes.connect("clicked",self.onYesPressed)
        self.btNo = builder.get_object("btNo")
        self.btNo.connect("clicked",self.onNoPressed)
        self.wTimeout.connect("delete-event",self.onDeleteWindow)
        self.btBack = builder.get_object("btBackWork")
        self.btBack.connect("clicked",self.onBackWorkPressed)
        self.pbTimeout = builder.get_object("pbTimeout")

        DATEFORMAT='%d/%m/%Y %H:%M'
        for task in self.tw.tasks.filter('+READY +reminder'):
                #get all fields in task
                task.refresh()
                self.addReminder(task['description'],task['due'].strftime(DATEFORMAT))

    ###############
    #  Reminders  #
    ###############
client.py 文件源码 项目:pomodoroTasks2 作者: liloman 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def doCommand(self,comm):
        self.com = comm 
        #Quit daemon and systray
        if self.com == "quit":
            #close systray when closing the daemon as well
            self.interface.do_quit(True)
            print("pomodoro daemon halted")
        # Show the change task gui
        elif self.com == "systray":
            # use busConnection better than bus = dbus.SessionBus() to work with systemd for example
            self.bus = dbus.bus.BusConnection(self.dbus_path)
            self.session_bus = self.bus.get_object('org.liloman.pomodoro.systray', "/systray")
            systray = dbus.Interface(self.session_bus, "org.liloman.pomodoro.systrayInterface")
            systray.show_change_task()
        # Start a uuid task
        elif self.com == "do_start":
            if len(sys.argv) != 3:
                print("must pass a valid uuid")
                sys.exit(1)
            dic = dbus.Dictionary({'uuid': sys.argv[2] , 'resume': 'No'  } , signature = 'ss' )
            try:
                print ("reply:"+self.interface.do_start(dic)[0])
            except:
                print("Incorrect uuid:"+sys.argv[2]+" .The task couldn't be started")
        # Do any other command
        else:
            print(u''.join(self.interface.do_fsm(self.com)[0]).encode('utf-8').strip())
systray.py 文件源码 项目:pomodoroTasks2 作者: liloman 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, rc = '~/.task'):
        self.tw = TaskWarrior(data_location=rc, create=True)
        self.status_icon = Gtk.StatusIcon()
        self.status_icon.set_from_file("images/iconStarted-0.png")
        self.status_icon.connect("popup-menu", self.right_click_event)
        self.status_icon.connect("activate", self.left_click_event)
        # systray daemon
        name = dbus.service.BusName(self.bus_name, bus=dbus.SessionBus(),do_not_queue=True, replace_existing=False, allow_replacement=False )
        dbus.service.Object.__init__(self, name, '/systray')
        # client for daemon
        bus = dbus.SessionBus(private = True)
        daemon_client = bus.get_object('org.liloman.pomodoro', "/daemon")
        self.interface = dbus.Interface(daemon_client, "org.liloman.pomodoroInterface")
main.py 文件源码 项目:ibus-typing-booster 作者: mike-fabian 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def check_instance(self):
        '''
        Check whether another instance of the setup tool is running already
        '''
        if (dbus.SessionBus().request_name("org.ibus.typingbooster")
                != dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER):
            self.__run_message_dialog(
                _("Another instance of this app is already running."),
                Gtk.MessageType.ERROR)
            sys.exit(1)
        else:
            return False
main.py 文件源码 项目:ibus-typing-booster 作者: mike-fabian 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __init__(self):
        bus_name = dbus.service.BusName(
            'org.ibus.typingbooster', bus=dbus.SessionBus())
        dbus.service.Object.__init__(self, bus_name, '/org/ibus/typingbooster')
server.py 文件源码 项目:systemd-workshop 作者: docent-net 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __init__(self):
        busname = dbus.service.BusName('org.documentroot.AAuname',
                                       bus=dbus.SessionBus())
        dbus.service.Object.__init__(self, busname, '/AAuname')
indicator.py 文件源码 项目:sony-av-indicator 作者: aschaeffer 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def __init__(self, sony_av_indicator, device_service, state_service, command_service):
        threading.Thread.__init__(self)
        self.sony_av_indicator = sony_av_indicator
        self.device_service = device_service
        self.state_service = state_service
        self.command_service = command_service
        self.properties = {
            ROOT_INTERFACE: self._get_root_iface_properties(),
            PLAYER_INTERFACE: self._get_player_iface_properties()
        }
        self.main_loop = dbus.mainloop.glib.DBusGMainLoop(set_as_default = True)
        # self.main_loop = GObject.MainLoop()
        self.bus = dbus.SessionBus(mainloop = self.main_loop)
        self.bus_name = self._connect_to_dbus()
        dbus.service.Object.__init__(self, self.bus_name, OBJECT_PATH)
indicator.py 文件源码 项目:sony-av-indicator 作者: aschaeffer 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def _connect_to_dbus(self):
        # bus_type = self.config['mpris']['bus_type']
        self.bus = dbus.SessionBus()
        bus_name = dbus.service.BusName(BUS_NAME, self.bus)
        return bus_name
menu.py 文件源码 项目:gnome-hud 作者: hardpixel 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self, window):
        self.window = window
        self.session = dbus.SessionBus()
        self.menu_items = dict()
        self.menu_actions = dict()

        self.explore_menu_paths()
        self.explore_menu_items()
menu.py 文件源码 项目:ukui-menu 作者: ukui 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def reboot(self, menu, widget):
        session_bus = dbus.SessionBus()
        obj = session_bus.get_object('org.gnome.SessionManager','/org/gnome/SessionManager')
        interface = dbus.Interface(obj,'org.gnome.SessionManager')
        interface.RequestReboot()
        self.ukuiMenuWin.hide()
        Gdk.flush()


问题


面经


文章

微信
公众号

扫码关注公众号