firefox-webapp/add-webapp.sh

90 lines
1.9 KiB
Bash
Raw Permalink Normal View History

2023-12-18 21:19:26 +00:00
#!/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-esr -CreateProfile $simple_name
# Create desktop entry
cat >~/.local/share/applications/$simple_name.desktop <<EOL
[Desktop Entry]
Exec=firefox-esr -P $simple_name $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
# Modify chrome/userChrome.css to hide everyting on top and bottom
profile_dir=$(find ~/.mozilla/firefox/ -maxdepth 1 | grep $simple_name)
mkdir $profile_dir/chrome
cat >$profile_dir/chrome/userChrome.css <<EOL
/* Hide tabs toolbar on top*/
#TabsToolbar {
visibility: collapse !important;
}
/* Hide navbar on top*/
#nav-bar {
/* customize this value. */
--navbar-margin: -30px;
margin-top: var(--navbar-margin);
margin-bottom: 0;
z-index: -100;
transition: all 0.3s ease !important;
opacity: 0;
}
#navigator-toolbox:focus-within > #nav-bar,
#navigator-toolbox:hover > #nav-bar
{
margin-top: 0;
margin-bottom: var(--navbar-margin);
z-index: 100;
opacity: 1;
}
/* Hide tabs toolbar on bottom*/
#TabsToolbar {
visibility: collapse !important;
}
/* Hide navbar on bottom*/
#nav-bar {
/* customize this value. */
--navbar-margin: -30px;
margin-top: 0;
margin-bottom: var(--navbar-margin);
z-index: -100;
transition: all 0.3s ease !important;
opacity: 0;
}
#navigator-toolbox:focus-within > #nav-bar,
#navigator-toolbox:hover > #nav-bar
{
margin-top: var(--navbar-margin);
margin-bottom: 0;
z-index: 100;
opacity: 1;
}
EOL