Skip to content

Instantly share code, notes, and snippets.

@boppy
Last active October 25, 2018 17:03
Show Gist options
  • Save boppy/e33b1f91d3f12e0fc83a4838ae3000f2 to your computer and use it in GitHub Desktop.
Save boppy/e33b1f91d3f12e0fc83a4838ae3000f2 to your computer and use it in GitHub Desktop.
Simple resolution fake shell script

Synapsis

Emulates screen resolution on some linux. Like: Got some 8K res on my RasPi!

Be sure to enjoy the most beautiful effects on font blurring...

"Installation" note

Ensure to be in your screens native resolution when first using the script since it writes the current resolution into a file (and the current screens name into a second file. Both inside /tmp/ starting with zooom_).

I have not tested this in multi-monitor-setups (but will...).

Usage

zooom [factor]

factor is optional. Without it beeing set the script will return to native resolution.

Example

zooom 2 - Sets a 1366x768 native res display to 2732x1536 virtual size.

#!/bin/bash
if [ ! -f /tmp/zooom_nativeres.txt ]; then
xdpyinfo | awk '/dimensions/{print $2}' > /tmp/zooom_nativeres.txt
xrandr | awk '/ connected /{print $1}' > /tmp/zooom_screen_name.txt
fi
IFS='x' read -a res < /tmp/zooom_nativeres.txt
scale=${1:-1}
resx=${res[0]}
resy=${res[1]}
display="$(cat /tmp/zooom_screen_name.txt)"
resOut=$(bc <<< "scale=0; ($scale * $resx)/1")"x"$(bc <<< "scale=0; ($scale * $resy)/1")
xrandr \
--output $display \
--mode "${resx}x${resy}" \
--scale "${scale}x${scale}" \
--panning $resOut
ret="$?"
if [[ $ret -eq 0 ]]; then
if [ "$scale" = "1" ]; then
echo "reset resolution" >&2
else
echo "emulating ${resOut}" >&2
fi
else
echo "failed. kinda badly..." >&2
exit $ret
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment