Example #1
0
	def run(self):
		# Initiate pipemenu
		self.menu = struct.PipeMenu(use_cache=self.cfg.printv("use_cache","Alan"), cache="appearance", cache_trigger=(self.cfg.path,"/usr/bin/paranoid"))
		if self.menu.cache_check():
			self.menu.cache_read()
		else:
			self.menu.start() # add initial tag

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

			### Begin!

			wallpaperadd = core.item(_("Add"), ga.execute("nitrogen-add-wallpaper"), icon="gtk-add") # Item that opens nitrogen-add-wallpaper
			wallpapermanage = core.item(_("Manage"), ga.execute("nitrogen"), icon="preferences-desktop-wallpaper") # Item that opens nitrogen
			wallpapermenu = core.menu("wallmenu", _("Wallpaper"), "\n".join((wallpaperadd, wallpapermanage)), icon="preferences-desktop-wallpaper") # Menu that has on it wallpaperadd and wallpapermanage

			themeselector = core.item(_("Appearance settings"), ga.execute("lxappearance"), icon="preferences-desktop-theme") # Theme selector

			if os.path.exists("/usr/bin/paranoid"):
				paranoid = core.item(_("Visual effects"), ga.execute("paranoid"), icon="preferences-system-windows") # paranoid

			i(wallpapermenu)
			i(core.separator)
			i(themeselector)
			if os.path.exists("/usr/bin/paranoid"): i(paranoid)

			# End
			self.menu.end()
Example #2
0
		def walk_menu(entry, is_system=False):
			if entry.get_type() == gmenu.TYPE_DIRECTORY and split and ids or entry.get_type() == gmenu.TYPE_DIRECTORY and not split:
								
				if not entry.menu_id in to_skip:
					obj = "\n".join(map(walk_menu, entry.get_contents()))
				elif is_system:
					obj = "\n".join(map(walk_menu_system, entry.get_contents()))
				else:
					return ""
				
				return core.menu(escape(entry.menu_id), escape(entry.name.replace("&","and")), obj, icon=entry.icon)
			elif entry.get_type() == gmenu.TYPE_DIRECTORY and split:
				if not entry.menu_id in to_skip:
					return core.pipemenu(escape(entry.menu_id), escape(entry.name.replace("&","and")), "alan-show-extension %s %s" % (sys.argv[1], entry.menu_id), icon=entry.icon)
			elif entry.get_type() == gmenu.TYPE_ENTRY and not entry.is_excluded:
				command = re.sub(' [^ ]*%[fFuUdDnNickvm]', '', entry.get_exec())
				if "oneslip" in command and not ONESLIP:
					# oneslip not installed, link to bricks
					command = "pkexec /usr/bin/bricks \"%s\" oneslip" % escape(entry.name.replace("&","and"))
				if entry.launch_in_terminal:
					command = 'x-terminal-emulator --title "%s" -e %s' % \
						(entry.name.replace("&","and"), command)
				
				# New action
				act = ga.execute(escape(command))
				# Incorporate action in item
				item = core.item(escape(entry.name.replace("&","and")), act, icon=entry.icon)
				
				return item
Example #3
0
	def run(self):
		# Initiate pipemenu
		self.menu = struct.PipeMenu()
		self.menu.start() # add initial tag

		# Get linstaller configuration file, if any
		config = self.cfg.printv("config")
		if not config:
			config = "default"
		persistent_disabled = self.cfg.printv("persistent_disabled")

		config_persistent = self.cfg.printv("config_persistent")
		if not config_persistent:
			config_persistent = "semplice-persistent"
		
		frontend = self.cfg.printv("frontend")
		if not frontend:
			frontend = "glade"

		if frontend == "cli":
			# Proper set executables
			install_ex = "roxterm --hide-menubar -T \"Install Semplice\" -n \"Semplice Live Installer\" -e /usr/bin/linstaller_wrapper.sh -c=%s -f=cli start" % config
			persistent_ex = "roxterm --hide-menubar -T \"Install Semplice in USB\" -n \"Semplice Live USB Installer\" -e /usr/bin/linstaller_wrapper.sh -c=%s -f=cli start" % config_persistent
		else:
			# Default to glade
			install_ex = "sudo /usr/bin/linstaller_crash_wrapper.sh -c=%s -f=glade start" % config
			persistent_ex = "roxterm --hide-menubar -T \"Install Semplice in USB\" -n \"Semplice Live USB Installer\" -e /usr/bin/linstaller_wrapper.sh -c=%s -f=cli start" % config_persistent

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

		### Begin!

		install = core.item(_("Start installer"), ga.execute(install_ex))
		
		persistent = core.item(_("Start USB persistent installer"), ga.execute(persistent_ex))

		i(install)
		if not persistent_disabled:
			i(core.separator)
			i(persistent)

		# End
		self.menu.end()
Example #4
0
    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()
Example #5
0
    def return_album_songs(self, album):
        """ Returns a list of items that changes the song. """

        sngs = []
        for song in self.client.listallinfo():
            try:
                if song["album"] == album:
                    # Yay!
                    sngs.append(
                        core.item(
                            song["title"],
                            ga.execute(
                                executable
                                + " %s changesong %s %s %s" % (self.NAME, song["title"], song["album"], song["artist"])
                            ),
                        )
                    )
            except:
                pass

        return sngs
Example #6
0
def info(authors, sep=True, icon=False):
	""" Displays informations on the extension.
	authors should be a dict which contains categories (coders, documentation etc). Every category should have another dict with a name and an email/website."""

	if icon:
		icon = "gtk-about"

	menus = []
	for lab,cat in authors.iteritems():
		work = []
		for aut,to in cat.iteritems():
			# Add new action and then item
			work.append(item(aut, ga.execute("xdg-open %s" % to)))
		# Add work to an ad-hoc menu
		menus.append(menu(lab, lab, "\n".join(work)))
	
	if sep:
		sep = separator + "\n"
	else:
		sep = ""
	
	return sep + menu("informations", _("Info"), "\n".join(menus), icon=icon)
Example #7
0
	def run(self):
		
		# Get filemanager
		filemanager = self.cfg.printv("filemanager")
		if not filemanager: filemanager = "pcmanfm --new-win" # Default to pcmanfm if not filemanager specified.
		
		# Initiate pipemenu
		self.menu = struct.PipeMenu(use_cache=self.cfg.printv("use_cache","Alan"), cache="places", cache_trigger=(self.cfg.path, os.path.join(HOME,".gtk-bookmarks"), "/proc/mounts"))
		if self.menu.cache_check():
			self.menu.cache_read() # Read cache
		else:
			self.menu.start() # add initial tag

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

			### Begin!

			# Home
			i(core.item(USER, ga.execute(self.exfm(filemanager, "file://%s" % HOME)), icon="user-home"))

			# Desktop
			i(core.item(_("Desktop"), ga.execute(self.exfm(filemanager, "file://%s" % os.path.join(HOME,"Desktop"))), icon="user-desktop"))

			# Trash
			i(core.item(_("Trash"), ga.execute(self.exfm(filemanager, "trash://")), icon="user-trash"))

			# Computer
			i(core.item(_("Computer"), ga.execute(self.exfm(filemanager, "computer://")), icon="computer"))

			i(core.separator)

			#### MOUNTED ITEMS

			# Root (/)
			i(core.item(_("System (/)"), ga.execute(self.exfm(filemanager, "file:///")), icon="drive-harddisk"))

			with open("/proc/mounts") as mounts:

				# Other items listed in /media
				for media in mounts.readlines():
					if "/media" in media:
						
						if ICONS:
							if "iso9660" in media or "udf" in media:
								# It is a CD. Maybe.
								icon = "media-optical"
							else:
								icon = "drive-harddisk"
						else:
							icon = ""
						
						# Is on media. Yay.
						dire = media.split(" ")[1].replace('\\040'," ") # use only the directory name
						i(core.item(os.path.basename(dire).replace("_","__"), ga.execute(self.exfm(filemanager, dire)), icon=icon))

			if os.path.exists(os.path.join(HOME, ".gtk-bookmarks")):
				i(core.separator)

				_file = open(os.path.join(HOME, ".gtk-bookmarks"))
				lines = _file.readlines()
				for line in lines:
					line = line.split(" ")
					directory = line[0].replace("\n","")
					if len(line) > 1:
						name = " ".join(line[1:]).replace("_","__").replace("\n","")
					else:
						name = os.path.basename(directory.replace("file://","")).replace("_","__").replace("\n","")
					if directory.startswith("smb://"):
						icon = "folder-remote-smb"
					elif directory.startswith("nfs://"):
						icon = "folder-remote-nfs"
					elif directory.startswith("ssh://"):
						icon = "folder-remote-ssh"
					elif directory.startswith("ftp://"):
						icon = "folder-remote-ftp"
					else:
						icon = "folder"
					i(core.item(name, ga.execute(self.exfm(filemanager, directory)), icon=icon))

			# End
			self.menu.end()
Example #8
0
    def run(self):

        # Initiate pipemenu
        self.menu = struct.PipeMenu(
            use_cache=self.cfg.printv("use_cache", "Alan"),
            cache="logout",
            cache_trigger=(self.cfg.path, cfile, "/etc/passwd"),
        )
        if self.menu.cache_check():
            self.menu.cache_read()
        else:
            self.menu.start()  # add initial tag

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

            ### Begin!

            sort = (
                "lock",
                "logout",
                "switch",
                "suspend",
                "hibernate",
                "shutdown",
                "reboot",
            )  # Workaround that has to be made after switching from numbers to words.

            actions = {
                "lock": _("Lock Screen"),
                "logout": _("Logout"),
                "switch": _("Switch User"),
                "switch_guest": _("Guest session"),
                "suspend": _("Suspend"),
                "hibernate": _("Hibernate"),
                "shutdown": _("Shutdown"),
                "reboot": _("Reboot"),
            }
            ections = {
                "lock": "semplice-logout --lock",
                "logout": "semplice-logout --logout",
                "switch": "semplice-logout --switch-user",
                "switch_guest": "semplice-logout --switch-to-guest",
                "suspend": "semplice-logout --suspend",
                "hibernate": "semplice-logout --hibernate",
                "shutdown": "semplice-logout --shutdown",
                "reboot": "semplice-logout --reboot",
            }
            ictions = {
                "lock": "system-lock-screen",
                "logout": "system-log-out",
                "switch": "system-users",
                "switch_guest": "system-users",
                "suspend": "gnome-session-suspend",
                "hibernate": "gnome-session-hibernate",
                "shutdown": "gnome-session-halt",
                "reboot": "gnome-session-reboot",
            }

            # After <robo>, add a separator.
            sep = ("switch", "hibernate")

            # Read configuration file
            if os.path.exists(cfile):
                cfg = cp.SafeConfigParser()
                cfg.read(cfile)

                # Get last choice
                last = cfg.get("Last", "last_action")
                if last.lower() == "none":
                    last = False
            else:
                last = False

                # Add that choice!
            if last:
                choice = actions[last] + " " + _("(CTRL+ALT+SPACE)")
                i(core.item(choice, ga.execute(ections[last]), icon=ictions[last]))
                i(core.separator)

                # Add normal choices

                # Lock screen
            i(core.item(_("Lock Screen"), ga.execute("semplice-logout --lock"), icon="system-lock-screen"))

            # Logout
            i(core.item(_("Logout"), ga.execute("semplice-logout --logout"), icon="system-log-out"))

            # Switch User
            # create menu:
            switch_items = []
            # open passwd and populate switch_items
            with open("/etc/passwd", "r") as passwd:
                for line in passwd.readlines():
                    line = line.split(":")
                    _uid = int(line[2])
                    if _uid < userbegin or _uid == 65534:
                        continue  # Skip users < userbegin and 65534 (nobody)

                    _uname = line[0]
                    _udesc = line[4].split(",")[0]
                    if not _udesc:
                        _udesc = _uname

                    if not _uname == USER:
                        _uhome = line[5]
                        if os.path.exists(os.path.join(_uhome, ".face")):
                            _uface = os.path.join(_uhome, ".face")
                        else:
                            _uface = "system-users"

                        switch_items.append(
                            core.item(_udesc, ga.execute("semplice-logout --switch-to %s" % _uname), icon=_uface)
                        )
                    else:
                        _uface = "gnome-settings-default-applications"

                        # create another menu on which put the "change profile image" item...
                        change_image = core.item(
                            _("Change profile image"), ga.execute("semplice-change-face"), icon="eog"
                        )
                        switch_items.append(core.menu("usermenu", _udesc, change_image, icon=_uface))

                        # add guest session
            switch_items.append(core.separator)
            # switch_items.append(core.item(_("Guest session"), ga.execute("semplice-logout --switch-to-guest"), icon="system-users"))
            # add Other...
            switch_items.append(core.item(_("Other..."), ga.execute("semplice-logout --switch-user"), icon="gdm"))

            # then create the menu...
            i(core.menu("switchmenu", _("Switch User"), "\n".join(switch_items), icon="system-users"))

            # Separator
            i(core.separator)

            # Suspend
            i(core.item(_("Suspend"), ga.execute("semplice-logout --suspend"), icon="gnome-session-suspend"))

            # Hibernate
            i(core.item(_("Hibernate"), ga.execute("semplice-logout --hibernate"), icon="gnome-session-hibernate"))

            # Separator
            i(core.separator)

            # Shutdown
            i(core.item(_("Shutdown"), ga.execute("semplice-logout --shutdown"), icon="gnome-session-halt"))

            # Reboot
            i(core.item(_("Reboot"), ga.execute("semplice-logout --reboot"), icon="gnome-session-reboot"))

            # for num in sort:
            # 	robo = actions[num]
            # 	i(core.item(robo, ga.execute(ections[num]), icon=ictions[num]))
            # 	if num in sep:
            # 		# We should add a separator!
            # 		i(core.separator)

            # Add Settings... item
            i(core.separator)
            i(core.item(_("Settings..."), ga.execute("semplice-logout --settings"), icon="preferences-desktop"))

            # End
            self.menu.end()
Example #9
0
					
					# If name, create an header
					if _name:
						items.append(core.header(_name))
					
					count = int(conf.printv("count"))
					done = 0
					while done != count:
						# Create items
						done += 1

						# Get object icon
						_icon = conf.printv("icon%s" % done)
						if not icons or not _icon: _icon = ""

						items.append(core.item(parsename(conf.printv("item%s" % done)), ga.execute(conf.printv("item%s_ex" % done)), icon=_icon))
				elif _ext == "__menu__":
					# Internal menu id
					items.append(core.menu(conf.printv("id"), icon=_icon))
				elif _ext == "__item__":
					# Normal menu item
					items.append(core.item(parsename(conf.printv("name")), ga.execute(conf.printv("executable")), icon=_icon))
				else:
					# An external extension
					items.append(core.pipemenu(ext, _name, "%s %s" % (execu,ext), icon=_icon))
		
		if IS_MAIN:
			# We are main? The items should not be in submenu.
			i("\n".join(items))
		else:
			# Generate a submenu and then add the items.
Example #10
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()