RSS Amplifier

Rida Ayed · Mar 14, 2020

Change Firefox's zoom by script

0
Sign in to vote or save

This page cannot be shown here. You can still read it on the original site — the toolbar below keeps your place in the directory.

Each time I change the monitor I have to zoom in or out firefox. Here’s how to set it via script: Figure 1: Large Figure 2: Small Locate the appropriate file ls /home/*/.mozilla/firefox/*/prefs.js Locate the appropriate parameter grep layout.css.devPixelsPerPx /home/*/.mozilla/firefox/*/prefs.js Large screen: Set the zoom #!/usr/bin/env bash factor = 2.5 if grep 'layout.css.devPixelsPerPx'…

Each time I change the monitor I have to zoom in or out firefox. Here’s how to set it via script:

"Figure

Figure 1: Large

"Figure

Figure 2: Small

Locate the appropriate file

ls /home/*/.mozilla/firefox/*/prefs.js

Locate the appropriate parameter

grep layout.css.devPixelsPerPx /home/*/.mozilla/firefox/*/prefs.js

Large screen: Set the zoom

#!/usr/bin/env bash
factor=2.5
if grep 'layout.css.devPixelsPerPx' /home/*/.mozilla/firefox/*/prefs.js
then
    sed -i -e "s/^user_pref(\"layout.css.devPixelsPerPx.*$/user_pref(\"layout.css.devPixelsPerPx\", \"$factor\");/" /home/*/.mozilla/firefox/*/prefs.js
else
    echo "user_pref(\"layout.css.devPixelsPerPx\", \"$factor\");" >> /home/*/.mozilla/firefox/*/prefs.js
fi

Small screen: Set the zoom

#!/usr/bin/env bash
factor=1.0
if grep 'layout.css.devPixelsPerPx' /home/*/.mozilla/firefox/*/prefs.js
then
    sed -i -e "s/^user_pref(\"layout.css.devPixelsPerPx.*$/user_pref(\"layout.css.devPixelsPerPx\", \"$factor\");/" /home/*/.mozilla/firefox/*/prefs.js
else
    echo "user_pref(\"layout.css.devPixelsPerPx\", \"$factor\");" >> /home/*/.mozilla/firefox/*/prefs.js
fi

Make the scripts executable

sudo chmod --verbose +x ~/src/scripts/FirefoxZoomIn.sh
sudo chmod --verbose +x ~/src/scripts/FirefoxZoomOut.sh
~/src/scripts/FirefoxZoomIn.sh
~/src/scripts/FirefoxZoomOut.sh

Docking/undocking triggers those scripts, which I’m handling with Autorandr.

Read on /posts/change_firefox_zoom_by_script/

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.