Quantcast
Channel: CodeSection,代码区,Linux操作系统:Ubuntu_Centos_Debian - CodeSec
Viewing all articles
Browse latest Browse all 11063

RetroPie and Raspberry Pi PIXEL Desktop

$
0
0

In linux, there's always more than one way to do it. RetroPie is a wonderful set of scripts and skins for EmulationStation, a collection of retro computer and video game emulators. By far the easiest way of running RetroPie is to flash their ready-made image to a memory card , but what if you want to have both RetroPie and Raspbian Pixel on the same card? Well, NOOBS and BerryBoot will both support multiple operating system partitions on a single card.

I don't want that. I want to have a RetroPie icon in my PIXEL menu under "Games".

What I wanted to achieve, was to have a single Raspbian operating system running from a single partition (plus /boot) and be able to boot to the PIXEL desktop, then be able to run RetroPie as if it were any other desktop application. And that's where it gets complicated, because RetroPie is not a desktop application.

If you like this and want to say thanks, donate to Cotswold Raspberry Jam , the computing club aimed at children that I run in Gloucestershire.You can find out more about Cotswold Jam here.

Install RetroPie alongside Raspbian PIXEL

You will need to manually install RetroPie as it doesn't come with Raspbian PIXEL by default.

From a terminal on Raspbian PIXEL, follow these instructions to manually install RetroPie:

RetroPie Manual Installation

My Solution

Important: The PIXEL desktop will be stopped and any work you haven't saved will be lost. I recommend you close all your desktop programs/windows yourself before you run RetroPie using my method. We'll start the desktop again when we're finished with RetroPie.

The manual method

Now you've got RetroPie installed alongside Raspbian PIXEL, you'll need a way of starting RetroPie. A way to do this manually is:

Press CTRL+ALT+F1 to bring up the first text console Type sudo systemctl stop lightdm and press the Enter key - this will stop the destop Type emulationstation and press the Enter key. RetroPie will start; have fun. To exit RetroPie, use the Start button to get the main menu, select Quit, then select Quit Emulationstation. Type sudo systemctl start lightdm and Enter to restart the PIXEL desktop If you don't see the desktop after a few moments, press CTRL+ALT+F7 to bring up the graphical console

What we're going to do now, is to automate that manual process as a desktop menu item. My solution is to stop the desktop, run RetroPie without the desktop, and then start the desktop again once RetroPie is finished. Yup, I'm cheating. We're not really running RetroPie from the desktop, we're just finding a way to start it from the desktop - and then temporarily getting rid of the desktop!

To implement my solution, you need two files:

1. ttyecho

ttyecho is a program that pretends to type into the Linux console. This isn't included by default in Raspbian, so you'll need to download it. You have a few options:

View the source and compile it yourself Download it directly from me (Right-click and Save As...) (note this is only for the Raspberry Pi ARM)

In both the above cases, you should move the file to /usr/local/sbin , chown root.root and chmod 755 . Alternatively you can copy and paste this all-on-one-line incantation into the terminal, which will download it, move it to the right place and set the ownership and permissions:

curl -O "http://aoakley.com/articles/artifacts/retropie-pixel/ttyecho" && sudo mv ttyecho /usr/local/sbin && sudo chmod 755 /usr/local/sbin/ttyecho && sudo chown root.root /usr/local/sbin/ttyecho

2. retropie.desktop

A .desktop file is a file that tells the PIXEL menu (and other Linux desktop menus) about an item in the menu. It typically includes an icon, a name, what command to run, and often a description. The .desktop files go inside the /usr/share/applications/ folder.

Here's what's needed inside retropie.desktop:

[Desktop Entry]
Type=Application
Name=RetroPie
Comment=Retro video game emulators
Exec=sudo su -c "systemctl stop lightdm ; ttyecho -n /dev/tty1 \"emulationstation ; sudo systemctl start lightdm\""
Icon=face-smile-big
Terminal=false
Categories=Application;Game;

If you want to download it, you can:

Download the retropie.desktop file directly (right-click and Save As...)

then move the file to /usr/share/applications , chown root.root and chmod 755 .

Alternatively, copy & paste into a terminal, this all-on-one-line incantation to download, move and set ownership & permissions:

curl -O "http://aoakley.com/articles/artifacts/retropie-pixel/retropie.desktop" && sudo mv retropie.desktop /usr/share/applications && sudo chmod 644 /usr/share/applications/retropie.desktop && sudo chown root.root /usr/share/applications/retropie.desktop

Starting and stopping RetroPie from the desktop

Once you've restarted your Raspberry Pi (or at least restarted the desktop with sudo systemctl restart lightdm ) then you should find a new smiley-faced RetroPie icon under the Raspberry menu - Games - RetroPie.

How and why does this work?

RetroPie, and many (but not all) of its emulators, expect to be in sole charge of the "console". In the context of multi-user computer systems, "console" means the monitor, keyboard and mouse which is directly attached to your computer. Raspbian, like almost all variants of GNU/Linux, are multi-user systems, and are designed so they can be connected to by several users at once, for example over the internet. However they assume, more or less, that there is only ever one user actually sitting at the monitor, mouse and keyboard.

Linux, including Raspbian, Debian, RedHat, Ubuntu, Mint and others, is usually configured to have four to six text consoles (usually at least four) and between two and six graphical consoles (usually at least two).

You can switch between these consoles with the following CTRL+ALT key combinations (by which I mean, hold down the CTRL key, also hold down the ALT key, then press the nominated F-number key):

CTRL+ALT+F1 - first text console, tty1
…through to… CTRL+ALT+F6 - sixth text console, tty6 CTRL+ALT+F7 - first graphical console; this is where the PIXEL desktop lives CTRL+ALT+F8 - second graphical console - if you have two users logged in to PIXEL (unlikely) then this is where the second desktop will appear. But most likely, this will be blank.
…through to… CTRL+ALT+F12 - sixth graphical console - again, most likely blank

Some Linux systems use CTRL+ALT+F9, F10, F11 and F12 for different purposes. F7 and F8 are usually reserved for graphical consoles for desktop versions of Linux.

Give it a try - if you get lost, use CTRL+ALT+F7 to return to the desktop.

It's worth mentioning that you can run graphics from what we call the text consoles - but those tend to be full-screen applications, usually quite old prog

Viewing all articles
Browse latest Browse all 11063

Trending Articles