Skip to content

Instantly share code, notes, and snippets.

@Cloudef
Created January 5, 2012 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cloudef/1566795 to your computer and use it in GitHub Desktop.
Save Cloudef/1566795 to your computer and use it in GitHub Desktop.
Scale Katawa Shoujo
#!/bin/sh
# Katawa Shoujo
# Default setting is fullscreen for 1440x900 with black borders at side.
#
# Depends: x11vnc, Xvfb
# vncviewer comes from tightvnc, but you can alternatively use any viewer you want.
#
# To calculate the target resolution and scaler
# that matches your whole screen while maintaining aspect ratio, here's some math:
#
# L = Longest edge in your resolution, usually Width is more than Height.
# S = Shortest edge in your resolution, usually Height is less than Width.
# RL = Longest edge of the application's real resolution
# RS = Shortest edge of the application's real resolution
# TW = Target width
# TH = Target height
# scaler = Calculated scaler
#
# scaler = S / RS
# TH = RS
# TW = RL + ((L - (RL * scaler)) / scaler)
# NOTE: Renpy throws exceptions on some effects if you run the game in lower resolution than the target.
# In KS's case the target resolution would be 800x640
# There might be more exceptions I'm not aware of so don't rely on this script fully.
#
# So to avoid issues always target resolution >= real resolution
# Resolution is your resolution divided by the scaler, though this might not fill the whole screen.
# If you want to fill whole screen, use the math above.
Xvfb :1 -screen 0 1024x640x24 &> /dev/null &
XVFB_PID=$!
sleep 2
# Works universally by replacing this line
DISPLAY=:1 exec "`dirname \"$0\"`/lib/python" "-OO" "${0%.sh}.py" "$@" &
GAME_PID=$!
# Default scaler is 1.875x, you should play around to find the best one.
x11vnc -once -localhost -nocursor -scale 1.40625:nb -display :1 &> /dev/null &
sleep 2
# If you get ugly scrollbars or otherwise have problems, try adding -geometry <resolution>
# Eg. -geometry 1440x900 for full screen on my resolution in example.
# Alternatively you can use different vnc client.
vncviewer -quality 9 -compresslevel 0 -nojpeg -x11cursor -encodings "Raw CopyRect" -truecolour localhost &> /dev/null
# Kill
# Kill for GAME_PID doesn't really do anything here. Python probably spawns sub processes.
# Anyways, game gets terminated on XVFB kill.
# kill $GAME_PID
kill $XVFB_PID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment