Score:2

How to create a wrapper script for the Flatpak version of Octave, to avoid the long command flatpak run org.octave.Octave?

us flag

In the apt version of octave, I can use the command octave script.m to execute the file script.m. Similarly flatpak run org.octave.Octave script.m works too.

However, to avoid the long command flatpak run org.octave.Octave, I created a file ~.local/bin/octave with the contents flatpak run org.octave.Octave, and marked it as executable (I already removed the apt version of Octave). While it runs octave just fine, octave script.m does not work anymore, it only opens the command line version of Octave.

I know that I can open Octave and run the script from within, but I am interested to know if the script can be directly run from terminal with the flatpak version of Octave.

Score:5
cn flag

Apparently, the trick is to unset the environmental variable SESSION_MANAGER [source].

In order not to interfere with your regular environment, prefer to unset the environment only for the current command using env:

env -u SESSION_MANAGER flatpak run org.octave.Octave script.m

Of course, you can make your life much easier defining for example an alias:

alias octave='env -u SESSION_MANAGER flatpak run org.octave.Octave'

From now on, you can run an octave script as of old:

octave script.m

Include the alias definition in your ~/.bashrc configuration file so it is always available in an interactive terminal.

vanadium avatar
cn flag
@terdon thanks for correcting the error in the command for the alias definition!
Score:2
zw flag

I have just installed Octave 6.4.0 from Flatpak on my Ubuntu 20.04.3 LTS system, then rebooted and I'm able to execute my script.m file from terminal from both MATE and GNOME as simple as:

flatpak run org.octave.Octave script.m

Or create a wrapper script by

cat <<'EOF' | tee ~/.local/bin/octave
#!/bin/bash
flatpak run org.octave.Octave "$@"
EOF

chmod +x ~/.local/bin/octave

and call Octave from Flatpak by executing octave script.m. Make sure that ~/.local/bin is defined in your $PATH variable.

Note: make sure that you do not have both deb- and Flatpak-versions of Octave. Remove the first by sudo apt-get autopurge octave if you prefer Flatpak.


If Flatpak fails on your system, you can install Octave 6.4.0 from some PPA by executing below commands:

sudo add-apt-repository ppa:devacom/science
sudo apt-get update
sudo apt-get install octave
vanadium avatar
cn flag
Maybe the reboot was all what was needed. I also installed it specifically for this question, got it to work while in the /home directory, but not after copying the script to another direcrtory (and cd-ing into it). Still, you may see the error `Qt: Session management error: None of the authentication protocols specified are supported`
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.