pigmonkey / firewarden

Open a file via the specified application within a private Firejail sandbox.
The Unlicense
74 stars 7 forks source link

problem running dark theme in featherpad/firewarden #12

Open Rosika2 opened 5 days ago

Rosika2 commented 5 days ago

Hi all, :wave:

Info:

my system: Linux Lite 6.2

here´s the scenario:

In thunar file-manager I created a user-defined command which looks like this:

lxterminal --command="/media/rosika/f14a27c2-0b49-4607-94ea-2e56bbf76fe1/DATEN-PARTITION/Dokumente/Ergänzungen_zu_Programmen/zu_firewarden_focal/firewarden_strict_dark_theme %f"

My aim is to display any text file by using featherpad the secure way with firewarden. The problem is: it doesn´t respect darkColorScheme settings. It keeps displaying the text black-on-white, even if I change the respective settings in fp.conf.

So I tried to fiddle around a bit.

To this end I created the folder:

mkdir -p ~/.config/featherpad_dark/featherpad

cp ~/.config/featherpad/fp.conf ~/.config/featherpad_dark/featherpad/fp.conf

I changed darkColorScheme=false to darkColorScheme=true in the new config.

I also changed firewarden_strict_dark_theme (which once was an exact copy of the firewarden script thus:

XDG_CONFIG_HOME="/home/rosika/.config/featherpad_dark/featherpad/"

# Log 
echo "XDG_CONFIG_HOME: $XDG_CONFIG_HOME" >> /tmp/firewarden_log.txt
echo "QT_STYLE_OVERRIDE: $QT_STYLE_OVERRIDE" >> /tmp/firewarden_log.txt

execute() {
    export XDG_CONFIG_HOME="/home/rosika/.config/featherpad_dark"
    export QT_STYLE_OVERRIDE="Fusion"
    /usr/bin/firejail --disable-mnt --private-srv=firewarden-"$now" --private-opt=firewarden-"$now" $quiet $homeopt $netopt $devopt featherpad "${appopt[@]}" "${finalargs[@]}" >> /tmp/firewarden_log.txt 2>&1
}

... and also tried some more fiddling.

Nothing worked however. :disappointed:

Dark theme settings keep being ignored.

Can anybody help me finding another way of getting featherpad to use darkColorScheme=true together with firewarden :question:

Many thanks in advance and many greetings from Rosika :slightly_smiling_face:

pigmonkey commented 5 days ago

Firewarden creates a temporary directory, and tells Firejail to use that as the home directory when executing the program. So your normal config file at /home/rosika/.config/featherpad/fp.conf will not be loaded within the jail.

Firewarden has a -c flag, which tells it to look for and execute a shell script named for the program being executed. The path to the temporary home directory of the sandbox will be passed to this script as $FIREWARDEN_HOME. This allows you to do any needed configuration, such as creating directories or copying files.

You want to create a shell script at /home/rosika/.config/firewarden/featherpad.sh, make it executable, and put inside it something like:

#!/bin/sh
mkdir -p "$FIREWARDEN_HOME/.config/featherpad
cp "$HOME/.config/featherpad/fp.conf" "$FIREWARDEN_HOME/.config/featherpad/"

Then instead of executing firewarden featherpad file.txt, run firewarden -c featherpad file.txt. Firewarden will run the above shell script prior to launching Featherpad, so Featherpad will see your normal config file and will respect all your normal settings.

Rosika2 commented 5 days ago

Update:

In the meantime I managed to solve my problem. For anyone interested here´s the how-to:

mkdir -p ~/.config/firewarden/
nano ~/.config/firewarden/featherpad.sh
#!/bin/sh
# Create the necessary directories in the sandbox home
mkdir -p "$FIREWARDEN_HOME/.config/featherpad"

# Copy the dark theme configuration to the sandbox
cp "$HOME/.config/featherpad/fp.conf" "$FIREWARDEN_HOME/.config/featherpad/fp.conf"

chmod +x ~/.config/firewarden/featherpad.sh

firewarden -c featherpad /home/rosika/Videos/test4.txt

Works like a charm. Black theme is activated now. :+1:

As a user-defined entry for thunar:

lxterminal --command="/media/rosika/f14a27c2-0b49-4607-94ea-2e56bbf76fe1/DATEN-PARTITION/Dokumente/Ergänzungen_zu_Programmen/zu_firewarden_focal/firewarden -c featherpad %f"

That´s my personal location of firewarden, of course. Yod need to adapt the command according to your preferences.

So, more generally speaking:

lxterminal --command="[path-to-firewarden]/firewarden -c featherpad %f"

Glad it could be solved. :smiley:

Many greetings from Rosika :slightly_smiling_face:

Rosika2 commented 5 days ago

Hi @pigmonkey , :wave:

Thanks, Peter, for your help. :heart:

I think our posts overlapped in time. I just saw your comment after I had posted my how-to. I guess both tell the same story, right? :smiley:

I´m really glad it worked out.

Thank you so much, Peter.

Many greetings from Rosika :slightly_smiling_face: