Jump to content

Firefox: Difference between revisions

From postmarketOS Wiki
Post my ugly script, in hopes others will use it
Alpabrz (talk | contribs)
m Add Syntax Highlighting.
Line 3: Line 3:
postmarketOS ships the desktop version of Firefox as default in Phosh and Plasma Mobile, the mobile and privacy friendly configuration from [https://gitlab.com/postmarketOS/mobile-config-firefox mobile-config-firefox]. To remove this configuration, uninstall the <code>mobile-config-firefox</code> package.
postmarketOS ships the desktop version of Firefox as default in Phosh and Plasma Mobile, the mobile and privacy friendly configuration from [https://gitlab.com/postmarketOS/mobile-config-firefox mobile-config-firefox]. To remove this configuration, uninstall the <code>mobile-config-firefox</code> package.
== Webapps ==
== Webapps ==
To create webapps for use with Firefox, the following shell script can be used. It generates a separate Firefox profile for isolation, and adds a desktop entry that opens the corresponding site as a single-site browser (without a url-bar)
To create webapps for use with Firefox, the following shell script can be used. It generates a separate Firefox profile for isolation, and adds a desktop entry that opens the corresponding site as a single-site browser (without a url-bar).
#!/usr/bin/env bash
<syntaxhighlight lang="bash">
# Create firefox profile
#!/usr/bin/env bash
set -e
# Create firefox profile
name=$1
set -e
url=$2
name=$1
# Ugly, copy-pasted from SO
url=$2
simple_name=$(echo "$name" | awk '{print tolower($0)}' | sed 's/ //g')
# Ugly, copy-pasted from SO
echo "Creating webapp $name, using $url."
simple_name=$(echo "$name" | awk '{print tolower($0)}' | sed 's/ //g')
echo "Creating webapp $name, using $url."
firefox -CreateProfile $simple_name
 
profile_dir=$(find ~/.mozilla/firefox/ -maxdepth 1 | grep $simple_name)
firefox -CreateProfile $simple_name
echo 'user_pref("browser.ssb.enabled",true);' > $profile_dir/user.js
profile_dir=$(find ~/.mozilla/firefox/ -maxdepth 1 | grep $simple_name)
echo 'user_pref("browser.ssb.enabled",true);' > $profile_dir/user.js
# Create desktop entry
 
cat >~/.local/share/applications/$simple_name.desktop <<EOL
# Create desktop entry
[Desktop Entry]
cat >~/.local/share/applications/$simple_name.desktop <<EOL
Exec=firefox -P $simple_name --ssb $url
[Desktop Entry]
Icon=/home/user/.local/share/applications/$simple_name.png
Exec=firefox -P $simple_name --ssb $url
Type=Application
Icon=/home/user/.local/share/applications/$simple_name.png
Terminal=false
Type=Application
Name=$name
Terminal=false
StartupNotify=true
Name=$name
StartupWMClass=firefox
StartupNotify=true
EOL
StartupWMClass=firefox
EOL
# Get icon
 
wget $url/favicon.ico -O /tmp/favicon.ico
# Get icon
convert /tmp/favicon.ico /tmp/favicon.png
wget $url/favicon.ico -O /tmp/favicon.ico
mv /tmp/favicon.png .local/share/applications/$simple_name.png ||
convert /tmp/favicon.ico /tmp/favicon.png
mv /tmp/favicon-0.png .local/share/applications/$simple_name.png
mv /tmp/favicon.png .local/share/applications/$simple_name.png ||
rm /tmp/favicon*.png
mv /tmp/favicon-0.png .local/share/applications/$simple_name.png
rm /tmp/favicon*.png
</syntaxhighlight>
Save this script as <code>/add-webapp.sh</code>, and mark it as executable.
Save this script as <code>/add-webapp.sh</code>, and mark it as executable.
Running the command <code>./add-webapp.sh "Hacker News" "https://news.ycombinator.com"</code> will create a launcher shortcut to Hacker News.
Running the command <code>./add-webapp.sh "Hacker News" "https://news.ycombinator.com"</code> will create a launcher shortcut to Hacker News.

Revision as of 16:50, 7 March 2021

Alt text
Firefox running on Phosh with mobile-config-firefox

postmarketOS ships the desktop version of Firefox as default in Phosh and Plasma Mobile, the mobile and privacy friendly configuration from mobile-config-firefox. To remove this configuration, uninstall the mobile-config-firefox package.

Webapps

To create webapps for use with Firefox, the following shell script can be used. It generates a separate Firefox profile for isolation, and adds a desktop entry that opens the corresponding site as a single-site browser (without a url-bar).

#!/usr/bin/env bash
# Create firefox profile
set -e
name=$1
url=$2
# Ugly, copy-pasted from SO
simple_name=$(echo "$name" | awk '{print tolower($0)}' | sed 's/ //g')
echo "Creating webapp $name, using $url."

firefox -CreateProfile $simple_name
profile_dir=$(find ~/.mozilla/firefox/ -maxdepth 1 | grep $simple_name)
echo 'user_pref("browser.ssb.enabled",true);' > $profile_dir/user.js

# Create desktop entry
cat >~/.local/share/applications/$simple_name.desktop <<EOL
[Desktop Entry]
Exec=firefox -P $simple_name --ssb $url
Icon=/home/user/.local/share/applications/$simple_name.png
Type=Application
Terminal=false
Name=$name
StartupNotify=true
StartupWMClass=firefox
EOL

# Get icon
wget $url/favicon.ico -O /tmp/favicon.ico
convert /tmp/favicon.ico /tmp/favicon.png
mv /tmp/favicon.png .local/share/applications/$simple_name.png ||
mv /tmp/favicon-0.png .local/share/applications/$simple_name.png
rm /tmp/favicon*.png

Save this script as /add-webapp.sh, and mark it as executable. Running the command ./add-webapp.sh "Hacker News" "https://news.ycombinator.com" will create a launcher shortcut to Hacker News.

See also