示例#1
0
文件: exaile.py 项目: semplice/alan
    def run(self):

        # Initiate pipemenu
        self.menu = struct.PipeMenu()
        self.menu.start() # add initial tag
        
        i = self.menu.insert
        
        i(core.header("Exaile"))
            
        try:
            self.remote_object = bus.get_object("org.exaile.Exaile","/org/exaile/Exaile")
            self.iface = dbus.Interface(self.remote_object, "org.exaile.Exaile")

            if self.iface.GetState() == "playing":
                i(core.item(_("Pause"), ga.execute("alan-show-extension %s playpause" % sys.argv[1]), icon="media-playback-pause"))
            else:
                i(core.item(_("Play"), ga.execute("alan-show-extension %s playpause" % sys.argv[1]), icon="media-playback-start"))
                
            i(core.item(_("Stop"), ga.execute("alan-show-extension %s stop" % sys.argv[1]), icon="media-playback-stop"))
    
            i(core.separator)
    
            i(core.item(_("Previous"), ga.execute("alan-show-extension %s prev" % sys.argv[1]), icon="media-skip-backward"))
            i(core.item(_("Next"), ga.execute("alan-show-extension %s next" % sys.argv[1]), icon="media-skip-forward"))
            
            i(core.separator)
            # Displays infos about the current song
            if(self.iface.IsPlaying()):
                i(core.item(self.iface.GetTrackAttr("title"), ga.execute("echo"), icon="audio-x-generic"))
                i(core.item(self.iface.GetTrackAttr("album"), ga.execute("echo"), icon="media-optical"))
                i(core.item(self.iface.GetTrackAttr("artist"), ga.execute("echo"), icon="audio-input-microphone"))
            else:
                #i(core.item(_("Open Exaile"), ga.execute("exaile"), icon="/usr/share/pixmaps/exaile.png"))
                i(core.item(_("Exaile is not playing."), ga.execute("echo"), icon=""))
        except dbus.exceptions.DBusException:
            i(core.item(_("Open Exaile"), ga.execute("exaile"), icon="exaile"))
            #print("Exaile is not running.")

        self.menu.end()
示例#2
0
if use_cache and menu.cache_check():
	# Oh, yay :) We can use the cache instead.
	menu.cache_read()
else:
	# Load objects now
	import alan.core.objects.core as core
	import alan.core.actions.glob as ga

	menu.start()

	# alias insert
	i = menu.insert

	# Header
	if not head == "__disabled__":
		i(core.header(parseheader(head)))

	# Begin creating menu
	for cat in categories:
		if cat == "-":
			# Separator
			i(core.separator)
			continue

		# Check if this is a main menu (@)
		if cat[0] == "@":
			# True.
			IS_MAIN = True
			
			# Depure name
			cat = cat[1:]
示例#3
0
    def run(self):
        # Initiate pipemenu
        self.menu = struct.PipeMenu()
        self.menu.start()  # add initial tag

        # Alias menu.insert() to i()
        i = self.menu.insert

        ### Begin!

        # We should determine which player use, but hey, currently only MPD is supported :)
        PLAYERS = (MPD,)

        # Process player
        for player in PLAYERS:

            # Declare class
            clas = player()

            if len(sys.argv) > 3:
                # Called from an already made pipe menu
                if clas.NAME == sys.argv[2]:
                    if sys.argv[3] == "play":
                        clas.play()
                    if sys.argv[3] == "pause":
                        clas.pause()
                    if sys.argv[3] == "stop":
                        clas.stop()
                    if sys.argv[3] == "restartsong":
                        clas.restartsong()
                    if sys.argv[3] == "prev":
                        clas.prev()
                    if sys.argv[3] == "next":
                        clas.next()
                sys.exit(0)

                #######
                # A simple ASCII mockup :D
                #
                # Play (If we are paused or stopped) - If we are playing, show Pause instead of Play.
                # Stop (If we are playing or pausing)
                # ----
                # <Song Name> -> Click -> Restarts song
                # <Album> -> Submenu that shows all songs in the album
                # <Author> -> Submenu that shows all albums and then songs in them
                # ----
                # Previous
                # Next
                # ----
                # Info
                #######

                # Begin creating all needed objects
            play = core.item(_("Play"), ga.execute(executable + " %s play" % clas.NAME))
            pause = core.item(_("Pause"), ga.execute(executable + " %s pause" % clas.NAME))
            stop = core.item(_("Stop"), ga.execute(executable + " %s stop" % clas.NAME))

            if clas.status["state"] == "stop" or not clas.song["title"]:
                song = _("Play a random song")
                album = False
                author = False
            else:
                song = clas.song["title"]
                # album = core.menu()
                # print clas.song["album"]
                try:
                    album = core.menu(
                        "albumsub", clas.song["album"], "\n".join(clas.return_album_songs(clas.song["album"]))
                    )
                except:
                    album = False

                try:
                    author = core.menu(
                        "artistsub", clas.song["artist"], "\n".join(clas.return_author_albums(clas.song["artist"]))
                    )
                except:
                    author = False

            song = core.item(_(song), ga.execute(executable + " %s restartsong" % clas.NAME))

            prev = core.item(_("Previous"), ga.execute(executable + " %s prev" % clas.NAME))
            next = core.item(_("Next"), ga.execute(executable + " %s next" % clas.NAME))

            # Begin adding to menu
            i(core.header(clas.NAME))

            if clas.status["state"] == "stop" or clas.status["state"] == "pause":
                i(play)
            if clas.status["state"] == "play":
                i(pause)
            if clas.status["state"] == "play" or clas.status["state"] == "pause":
                i(stop)

            # Separator
            i(core.separator)

            # Song name
            i(song)
            if album:
                i(album)
            if author:
                i(author)

            # Previus/Next
            if clas.status["state"] in ("play", "pause"):
                # Separator
                i(core.separator)

                i(prev)
                i(next)

                # Display info object
        i(core.info(infos))

        # End
        self.menu.end()