Display GUI on Raspberry Pi without startx - raspberry-pi

I'm currently playing with my brand-new raspberry with adafruit's touch-tft and raspberry Cam.
I noticed, if I run raspivid -p, it displays the preview in a frame on top of the bash.
How can I create an application (java, python, c++(preferred)) to display a GUI without having to startx?
I'd love to use adafruit's touch-tft for a project, but startx needs a lot of resources. Of course it would be cool to have the touch-functionality too.
Edit:
Maybe I expressed myself a little bit confusing: I would like to create an application that doesn't need startx but has some kind of GUI.
The answers below aren't 100% ready to go but they pointed me to the right direction. Since I saw many similar questions I will try to give a step-by-step solution:
Setup your raspberry with adafruit's TFT: https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/overview
(you don't have to replace the TFT with HDMI as standart display)
be sure FRAMEBUFFER=/dev/fb1 startx is running correctly on the TFT screen, I have my TV plugged in the HDMI port, this way I can use the bash on the TV screen and run x on the TFT
Follow this tutorial to create your first pygame: http://www.pygame-doku.laymaxx.de/tut/intro/intro.html
(you can just copy&paste, wget ball.gif)
Insert this 2 lines at the beggining: (github.com/notro/fbtft/wiki/Pygame)
import os
os.environ["SDL_FBDEV"] = "/dev/fb1"
If you want to test the touch-screen to, you can change Line 15:
From:
if event.type == pygame.QUIT: sys.exit()
To:
if event.type == pygame.MOUSEBUTTONDOWN: sys.exit()
This will exit the application if you touch the screen
Save file e.g. pygame1.py and execute with $python pygame1.py
You should now see a bouncing ball on your TFT while the HDMI output still displays the BASH on your TV (but it isn't active of course) touching the screen will exit the game if you completed step 6
Why I'm doing this? This way you can display a simple GUI with e.g. buttons to do some action, like turn your lights on/off if you use your RPI for home-control.

You can use for example pygame library! check this tutorial http://archive.furtherfield.org/rp-resources/RP-workshop-handout.pdf pg. 17

Below, you will find a detailed description of how to be a minimal window manager to start a graphics program of your choice.
-Install Required Packages:
apt-get update
apt-get install xorg - no-install-recommends gdm3 matchbox-window-manager Iceweasel rsync-y
-The system in question, select Add a new user interface gdm3. The terminal is the default name will be used.
adduser kiosk
-Create-Xsession. This script will be executed when the user logs on.
xset s off
xset -dpms
matchbox-window-manager &
while true; do
rsync -qr --delete --exclude='.Xauthority’ /opt/kiosk/ $HOME/
firefox http://www.google.com (Replace your application!!!)
done
Save Ctrl + O; Exit: Ctrl + X
chmod a + x. xsession
cp / opt / kiosk / .xsession / home / kiosk
Set Auto-Login. Kiosk user will enter automatically after boot.
nano / etc/gdm3/daemon.conf
[Daemon]
AutomaticLoginEnable = true
AutomaticLogin = kiosk
We have chosen to configure, program, if necessary
-Screen calibration when not loaded up the whole screen:
/ Boot / config.txt file, clear the comment:
disable_overscan = 1
I hope I helped

Check out Urwid, a text-based ui that can run in a terminal, or, I assume, on a Raspberry Pi started up without startx.

In short you can't, applications like gedit are built atop of a desktop environment (e.g. Gnome, Kde).

Related

Raspberry Pi Camera Module Troubleshooting

Typically I use the basic camera module 2 on my boards but I wanted to up the resolution and purchased the HQ camera module. After I installed the component and executed the
raspistill -o .jpgs command I just end up with these blank images. I've tried just about everything but get the same result and I'm hoping this thing isn't just a lost cause.
I set-up the config file for a camera
sudo raspi-config
Then ran the following command
raspistill -o testing.jpg
This will just output the blank image and I also tried to view the camera by executing
raspistill -t 0
Still no view opens from the camera

How to run a MicroPython host script file on the Raspbery Pi PIco from the host command line and receive UART output back on terminal?

I know how to do something similar with Thonny: I could paste my code into the editor, and press the green "Run" button. This would run the program and give me output. But it would require copy pasting my file into Thonny (I want to code in Vim or run pre-existing examples) and pressing GUI buttons which I don't want to do.
Another related approach would be to copy the program as main.py to the pico, e.g. with rshell: How can you make a micropython program on a raspberry pi pico autorun? But this requires plugging and unplugging the USB, and then reconnecting to the UART every time to see the output.
Is it possible to send file contents to a GNU Screen session? would likely also solve or almost solve my problem, but:
I don't want to start a named server and then run another command, it's messy, I just want to run!
I would need to think about how to send Ctrl+D to soft restart. Should not be hard, but lazy to learn
The first way I got it to work was with https://github.com/scientifichackers/ampy That tool is just designed for the job, and does it perfectly with the run command:
python3 -m pip install --user adafruit-ampy
ampy --port /dev/ttyACM0 run blink.py
Outcome:
stops execution of current program
starts execution of blink.py
shows UART output on my shell
I can then quit ampty with Ctrl + C to get back to my shell, and the program continues to run.
Tested on adafruit-ampy==1.1.0, Ubuntu 22.04 host, Raspberry Pi Pico W, MicroPython rp2-pico-w-20221014-unstable-v1.19.1-544-g89b320737.uf2.

Resizing Epiphany browser (Webbrowser) in Raspberry pi

I have been searching in google since one day and I have not found any information of how to resize the webbrowser window (for example, half of the screen) just starting the raspberry pi.
At the moment I achieved starting the webbrowser in kiosk with this code:
In /etc/xdg/lxsession/LXDE-pi/autostart
#xset s off
#xset -dpms
#xset s noblank
#epiphany-browser http://www.google.de
Any idea of how can give/configure a given size to the browser?
I solved by my own.
Just creating a script and using wmctrl in the script.
When starting the PC it run automatically this script.
#!/bin/bash
epiphany http://www.google.de &
sleep 15s
epiphany --new-window www.wikipedia.com &
sleep 15s
SOURCE=/usr/bin
echo "$SOURCE"
$SOURCE/wmctrl -r wikipedia -e 0,0,0,800,1080
$SOURCE/wmctrl -r Google -e 0,800,0,1120,1080

OpenSuse - Command for Beep Sound (System Bell)

I have a source code that runs perfectly fine on Ubuntu, it does some copumtations, and at some points it beeps like this
system("beep -f 400 -l 500");
On Ubuntu I had to do
apt-get install beep
However, I migrated to OpenSuse (not my choice) and now I get this message "sh: beep: command not found", as the command and package are obviously different.
Does anybody know hot to trigger the system beep sound and define the duration and frequency? I have been able to find only one way to change the parameters
setterm -bfreq 500 -blength 500
, but no way to actually trigger the system bell (beep). The following things don't work
echo ^G
echo -e "\a"
PS - the system Bell is enabled at
Configure Desktop -> Application and System Notifications -> System Bell
and you can actually play with this
So, I did what #fvu proposed.
However, one needs to have sudo rights, to do so, otherwise (e.g. at my work-place we don't have sudo rights) there is this output message
Could not open /dev/tty0 or /dev/vc/0 for writing open: No such file or directory
In this case, you should:
sudo chmod 4755 /usr/bin/beep
as proposed here
I noticed that on my OpenSuse 12.3 system, the bell is working in xterm or gnome-terminal, but not in konsole or xfce4-terminal.
If the same applies to your system, then maybe a work-around could be creating a shell script called "beep" which calls xterm and rings the bell:
#!/bin/sh
xterm -e "echo -e '\a'; sleep 1"

Raspberry Pi Raspbian Web Kiosk Virtual Keyboard Solution

I followed Alan D. Moore's step-by-step guide to have my Raspberry Pi running in kiosk mode.
I did my own configuration as I needed it to run on a touchscreen with no physical keyboard and mouse.
Here's how my ~/.xinitrc file looks.
xset s off
xset -dpms
matchbox-window-manager &
matchbox-keyboard &
while true; do
rsync -qr --delete --exclude='.Xauthority' /opt/kiosk/ $HOME/
midori -i 600 -e Fullscreen -e Navigationbar -a http://myport.ac.uk
done
I used apt-get install for the matchbox-keyboard to be used as an on-screen virtual keyboard solution.
Just look at how small the keys are! Barely touchable and super inaccurate...
The real question is if anyone knows of a way to make the keyboard bigger, could recommend other solutions or tweak the config? I am a total debian newbie so I really hope I get some help here. :)
Look here: http://mottie.github.io/Keyboard/
You can make an OSK with javascript.
Try to replace the line:
matchbox-keyboard &
with:
matchbox-keyboard -s 20 &
where -s is the font size (letter) that appears on each key.