Logo
  • waypoints
  • manual of me
  • contact

Run your apps in sandboxes

‣
Use this for easy navigation to main pages. This is hidden on your site

Run your apps in sandboxes

  • Run your apps in sandboxes
  • So how does it works?
  • Installing Flatpak
  • Usual commands
  • Then the script for multiple apps
  • Conclusion
  • some workarounds:
image

If you're a Linux user, you probably know that it's a good idea to do a fresh install of your operating system every once in a while. Over time, system upgrades can lead to compatibility issues and conflicts between different applications. But who wants to go through the hassle of reinstalling everything from scratch?

What about “Flatpak”?

Flatpak is a fantastic app manager that helps you avoid those annoying application conflicts. How, you ask? Flatpak packages run in isolated environments, or "sandboxes," on your system. This means that each app has its own dependencies, so there's no risk of one app interfering with another. Plus, you can install multiple apps with a single command using a simple script, making it easy to keep your system up to date and running smoothly.

So how does it works?

Installing Flatpak

Before you can begin installing applications with Flatpak, you will need to install the Flatpak package itself. This can be done from the command line using the Pacman package manager:

image
sudo pacman -S flatpak

Once Flatpak is installed, you will need to add the Flathub repository, which contains a large number of applications. To do this, run the following command:

flatpak remote-add --if-not-exists flathub <https://flathub.org/repo/flathub.flatpakrepo>

Here is some useful documents for going deeper:

Using Flatpak — Flatpak documentation

docs.flatpak.org

‣

Usual commands

Then the script for multiple apps

image

You can create a script with a list of multiple application IDs to automate the process of installing multiple Flatpak applications. Here's an example of what the script could look like:

Save this script to a file with a .sh extension, such as install-apps.sh, and make it executable using the following command:

chmod +x install-apps.sh

Then run the script using the following command:

bash install-apps.sh

This script will add the Flathub repository if it's not already added, and then install each application in the applications array. It will also update all installed applications at the end. You can add or remove applications from the array as needed.

💡
Since some applications are not available on Flatpak, a similar script can be written for Pacman or any other distro you love.
#!/bin/bash

# Define the list of packages to install
packages=(
    Pulseaudio LADSPA Equalizer
		clipgrab
)

# Iterate over the list of packages and install them one by one
for package in "${packages[@]}"; do
    sudo pacman -S $package
done

Conclusion

Now that we have our script ready, with a single command, we can easily install all our preferred apps, and enjoy the excitement of testing out our new setup without worrying about any conflicts or system issues.

So, let's take a deep breath, hit the <Enter↵> button, and see how our new script performs.

Wait for it….

Wait for it….

Wait for it….

Done!

image
— wait, there is still maybe a problem….
💡
One limitation to be aware of when using Flatpak is that the “sandboxing” will prevents direct communication with hardware. This means applications like “Visual Studio Code” will not be able to upload my code to Arduino or other hardware devices. Also, in Linux, you need to have the proper permissions to access the serial port where your Arduino board is connected.

some workarounds:

  1. Install this one, FlatSeal will help you to adjust how apps interact with the system.
Flathub—An app store and build service for Linux

Find and install hundreds of apps and games for Linux. Enjoy GIMP, GNU Octave, Spotify, Steam and many more!

flathub.org

  1. If you're getting a Permission denied: '/dev/ttyACM0’ error when trying to upload or communicate with the board, here are some steps you can try:
    1. Make sure your user account is a member of the dialout group, which has permission to access the serial port. You can check by running the command:
    2. groups
    3. if you don’t see uucp in the list, add your user account to the uucp group:
    4. sudo usermod -a -G uucp <username>

      Replace <username> with your actual username.

    5. Log out and log back in to apply the group membership changes.
    6. Try accessing the serial port again and see if you still get a "permission denied" error. If you do, you may need to adjust the permissions of the serial port device file directly by running the command:
    7. sudo chmod a+rw /dev/ttyACM0
icon
See all posts
nicolas de Barquin @2024
LinkedInGitHub
#!/bin/bash

# Add the Flathub repository
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

# Define an array of application IDs
applications=(
		com.visualstudio.code
		com.discordapp.Discord
		com.stremio.Stremio
		nz.mega.MEGAsync
		com.brave.Browser
		com.dropbox.Client
		org.nomacs.ImageLounge
		com.prusa3d.PrusaSlicer
		org.inkscape.Inkscape
		org.gimp.GIMP
		cc.arduino.arduinoide
		org.fritzing.Fritzing
		org.audacityteam.Audacity
		com.valvesoftware.Steam
		com.github.eneshecan.WhatsAppForLinux
		com.sindresorhus.Caprine
		md.obsidian.Obsidian
		net.codeindustry.MasterPDFEditor
		org.librepcb.LibrePCB
)

# Loop through the array of applications
for app in "${applications[@]}"; do
  # Install the application
  flatpak install -y flathub $app
done

# Update all installed applications
flatpak update