When I plug in an external monitor or projector, it oftentimes comes with a sub-optimal resolution. I found that the =xrandr= utility (X Resize and Rotate) is able to detect the maximum resolution and then automatically set that, but it usually takes two commands. Thus, I made a simple script =fix-display= that does that automatically:
#!/bin/bash DISPLAYS=$(xrandr | grep ' connected' | cut -f1 -d' ') xrandr --auto > devnull for d in $DISPLAYS do xrandr --auto --output $d done
This finds all connected displays and runs =xrandr= on them.
It's easy enough to make this even more accessible from Emacs:
(defun fix-display () "Run the fix-display shell script to fix the resolution of external displays." (interactive) (shell-command "fix-display"))