[SOLVED] Context-menu items for running AppImages with Firejail

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Mintymandy34

[SOLVED] Context-menu items for running AppImages with Firejail

Post by Mintymandy34 »

Hello.
Newbie here.
I primarily use softwares from the Mint's Software Manager.
But sometimes I need to use latest versions of some graphical applications which aren't available over the repo.
I've used Flatpaks and AppImages for this purpose.
I like AppImages more, but I know it lacks the sandboxing feature.

So, I'm intending to run AppImages within Firejail, don't know if it's a good idea, please correct me on that.
I've successfully run AppImages from within the terminal by using the firejail command but wish to do so with the help of GUI, using context menu.

I've written this small firejail.nemo_action file and put it in ~/.local/share/nemo/actions.

Code: Select all

[Nemo Action]

Name=Open in Firejail

Comment=Open "%f" in Firejail with the default profile

Icon-Name=firetools

Exec=firejail --appimage %F

Selection =appimage

Extensions=appimage;
This feels like it works. Please correct me on that too.
But, I wish to have other options in along with that item like in a tree structure.

Example;

Code: Select all

Open in Firejail > with default profile
                 > in private mode
                 > with custom configuration
Can this be implemented here, in Nemo.
The commands are available, I need a way to implement these in a tree structure with the context menu.

Please help.


SOLUTION:

Create a file named firejail.nemo_action

Code: Select all

[Nemo Action]
Name=Open in Firejail
Comment=Open "%f" in Firejail
Icon-Name=firetools
Exec=<open_with_firejail.sh %F>
Selection=s
Extensions=appimage;
Dependencies=firejail;zenity;
EscapeSpaces=true

Create a bash file named open_with_firejail.sh

Code: Select all

#!/bin/bash
#Define Choice
CHOICE=$(zenity --forms --width 200 --title "Open with Firejail" --text "Open with Firejail options" --add-combo "Choose option." --combo-values "1. Default|2. Private|3. Offline")
case $CHOICE in
    "1. Default")
         firejail --appimage "$1";;
    "2. Private")
         firejail --appimage --private "$1";;
    "3. Offline")
         firejail --appimage --net=none "$1";;
     *)
	 firejail --appimage "$1";;
esac
exit

Copy both these files to ~/.local/share/nemo/actions and restart Nemo.

Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Mintymandy34

Re: Context-menu items for running AppImages with Firejail

Post by Mintymandy34 »

smurphos wrote:
User avatar
smurphos
Level 18
Level 18
Posts: 8498
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Context-menu items for running AppImages with Firejail

Post by smurphos »

Hi,

Your action looks pretty much OK - there is one syntax error and a few fields I think you should have. I don't use firejail so not sure of it's options/arguments.

In nemo navigate to ~/.local/share/nemo/actions and click on more info in the info bar to get a commented action template.

The Selection needs to be one of {s}ingle, {m}ultiple, any, notnone, none (background click), or
# a number representing how many files must be selected to display.

You might want to make firejail a dependency, and use an EscapeSpaces line in case %F includes any spaces.

Make sure the icon name is valid or the action won't show. I normally get an action up and running and tested with no Icon-name entry initially then add the Icon-Name as the last step.

Code: Select all

[Nemo Action]
Name=Open in Firejail
Comment=Open "%f" in Firejail with the default profile
Icon-Name=firetools
Exec=firejail --appimage %F
Selection=s
Extensions=appimage;
Dependencies=firejail;
EscapeSpaces=true
As to whether you can make a nested menu entry I don't think the nemo action framework supports that other than having three main menu entries.

The way i would go is have the action call a script and use zenity in the script to pop a custom GTK dialog.....

Example of a zenity dialog...

Code: Select all

zenity --forms --width 200 --title "Open with Firejail" --text "Open with Firejail options" --add-combo "Choose option." --combo-values "1. Default|2. Private|3. Custom Config"
Image

With the combo box open
Image

The script will need to be executable and can live in the actions folder with the action.

So your action and it's associated script might look something like this. Note $1 in the script is the %F passed to the script by the action.

Code: Select all

[Nemo Action]
Name=Open in Firejail
Comment=Open "%f" in Firejail with choice of profile
Icon-Name=firetools
Exec=<open_with_firejail.sh %F>
Selection=s
Extensions=appimage;
Dependencies=firejail; zenity;
EscapeSpaces=true

Code: Select all

#!/bin/bash
#Define Choice
CHOICE=$(zenity --forms --width 200 --title "Open with Firejail" --text "Open with Firejail options" --add-combo "Choose option." --combo-values "1. Default|2. Private|3. Custom Config")
case $CHOICE in
    "1. Default")
         firejail --whatever-the-options-are "$1";;
    "2. Private")
         firejail --whatever-the-options-are "$1";;
    "3. Custom Config")
         firejail --whatever-the-options-are "$1";;
esac
exit
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
Mintymandy34

Re: Context-menu items for running AppImages with Firejail

Post by Mintymandy34 »

smurphos wrote: Tue Feb 26, 2019 1:58 am Hi,

Your action looks pretty much OK - there is one syntax error and a few fields I think you should have. I don't use firejail so not sure of it's options/arguments.

In nemo navigate to ~/.local/share/nemo/actions and click on more info in the info bar to get a commented action template.

The Selection needs to be one of {s}ingle, {m}ultiple, any, notnone, none (background click), or
# a number representing how many files must be selected to display.

You might want to make firejail a dependency, and use an EscapeSpaces line in case %F includes any spaces.

Make sure the icon name is valid or the action won't show. I normally get an action up and running and tested with no Icon-name entry initially then add the Icon-Name as the last step.

Code: Select all

[Nemo Action]
Name=Open in Firejail
Comment=Open "%f" in Firejail with the default profile
Icon-Name=firetools
Exec=firejail --appimage %F
Selection=s
Extensions=appimage;
Dependencies=firejail;
EscapeSpaces=true
As to whether you can make a nested menu entry I don't think the nemo action framework supports that other than having three main menu entries.

The way i would go is have the action call a script and use zenity in the script to pop a custom GTK dialog.....

Example of a zenity dialog...

Code: Select all

zenity --forms --width 200 --title "Open with Firejail" --text "Open with Firejail options" --add-combo "Choose option." --combo-values "1. Default|2. Private|3. Custom Config"
Image

With the combo box open
Image

The script will need to be executable and can live in the actions folder with the action.

So your action and it's associated script might look something like this. Note $1 in the script is the %F passed to the script by the action.

Code: Select all

[Nemo Action]
Name=Open in Firejail
Comment=Open "%f" in Firejail with choice of profile
Icon-Name=firetools
Exec=<open_with_firejail.sh %F>
Selection=s
Extensions=appimage;
Dependencies=firejail; zenity;
EscapeSpaces=true

Code: Select all

#!/bin/bash
#Define Choice
CHOICE=$(zenity --forms --width 200 --title "Open with Firejail" --text "Open with Firejail options" --add-combo "Choose option." --combo-values "1. Default|2. Private|3. Custom Config")
case $CHOICE in
    "1. Default")
         firejail --whatever-the-options-are "$1";;
    "2. Private")
         firejail --whatever-the-options-are "$1";;
    "3. Custom Config")
         firejail --whatever-the-options-are "$1";;
esac
exit
Thanks, will try this and ask you if I've any doubts.
Thanks for the help. :D
Locked

Return to “Software & Applications”