#!/bin/sh
set -eu

MODE="${1:-}"

case "$MODE" in
    640x480|800x600|1024x768) ;;
    *)
        echo "Usage: $0 {640x480|800x600|1024x768}" >&2
        exit 1
        ;;
esac

echo "$MODE" > "$HOME/.resolution.config"

if xmessage -center -buttons Yes:0,No:1 \
"Changed resolution to $MODE.
Should we restart X now ?"; then
    echo "$MODE" > "$HOME/.resolution.config"
    killall fluxbox
fi