14

The top of my monitor is physically obstructed by a bezel. I want to use xrandr to redefine the display resolution (height only) to restrict it to the viewable portion of the monitor.

The monitor resolution is 2880x1920 but the top ~20 rows of pixels are obstructed. I'll need to experiment to determine exactly how many rows are obstructed. So, I want a resolution of roughly 2880x1900 anchored to the bottom of the monitor (not centered) leaving the top ~20 rows of pixels unused.

I think that means I need to use --pos +0-20 but when I do Iget:

$ xrandr  --output eDP-1 --pos +0-20
xrandr: failed to parse '+0-20' as a position

And I've tried other variations:

$ xrandr --fb 2880x1900 --output eDP-1 --size 2880x1900+0+20
xrandr: specified screen 2880x1900 not large enough for output eDP-1 (2880x1920+0+0)

This is very similar to an existing question How to use only part of a monitor to display the entire desktop? but that user was asking about Windows and everyone suggests just using the window manager. That would get tiresome pretty quickly given that this is going to be permanent and for every workspace. I'm looking for a more fundamental solution.

The following test for 30 rows of pixels

$ xrandr --output eDP-1 --transform 1,0,0,0,1,-30,0,0,1 

does move the output down past the obstructed area but unfortunately it also extends the desktop's framebuffer below the visible screen. I could add a scale factor to that transform but I would rather just resize the desktop so that the bottom of the desktop lands at the bottom of the monitor.

4
  • 1
    Is a monitor only or a TV? If the latter what you're noticing is called "overscanning". That being the case you can adjust in the monitor/TV itself.
    – user931000
    Commented May 10, 2019 at 16:21
  • 1
    It's a laptop lcd screen. I don't think overscan makes any sense for digital signals and LCD screens. It's a property of CRTs that need retrace time and sync pulses.
    – Greg S
    Commented May 12, 2019 at 12:36
  • It doesn't make sense in a laptop's screen and it means it's either defective or being forced a wrong resolution. But what I mentioned is not about CRTs (of which I barely remember), it is all about modern TVs that often need a certain mode to be changed for computers, otherwise the image "bleeds out".
    – user931000
    Commented May 12, 2019 at 15:55
  • Here's a recent example: superuser.com/a/1435957/931000 but of course, it isn't applicable to internal monitors. Posting this only to illustrate what I meant in the first comment.
    – user931000
    Commented May 12, 2019 at 23:16

5 Answers 5

7
+300

My configuration:

  • Intel Celeron NUC
  • Ubuntu 18.04.3 LTS
  • Intel i915 drivers (integrated video)
  • HDMI output to an old LCD TV

What didn't work:

  • Driver has no support for over/underscan properties in xrandr
  • Custom video modes still extended past the edges of the monitor

What DID work:

xrandr --output "HDMI-2" --fb 1800x1000 --transform 1,0,-60,0,1,-30,0,0,1

--fb 1800x1000 sets the display area. Using this setting by itself will give you a large margin on the right and bottom, but does not center the image.

--transform 1,0,-60,0,1,-40,0,0,1 shifts the displayed image to the right by 60 pixels (the -60) and down by 40 pixels (the -40).

Combined together, my screen has a 60 pixel left margin, 1800 pixel wide display, and another 60 pixel right margin for a total with of 1920. Vertically, I have a 40 pixel top margin, a 1000 pixel tall display, and a 40 pixel bottom margin for a total of 1080.

I still get the warning:

xrandr: specified screen 1800x1000 not large enough for output HDMI-2 (1920x1080+-60+-40)

However the frame buffer still gets resized and the transform is still applied so that the edges of the screen are no longer extended past the end of the monitor.

Errorlevel after the xrandr is zero (meaning it worked without error) even through the above warning message is displayed.

This is the solution that worked for me, and being on an Intel integrated video driver instead of the more advanced nVidia or Radeon drivers, it's the only solution that's work so far.

For your resolution, I'd suggesting using a way smaller --fb to start with:

xrandr --output eDP-1 --fb 2400x1800 

Then play with the transforms to get the top left corner visible.

Then figure out what you can expand your framebuffer to keep your right edge and bottom edge visible.

None of this changes resolution, your screen is stil 2880x1920. You're just changing the screen size and shifting the screen down and to the right.

5
  • Alas, this does not work for me. My native resolution is 1920x1200. Let's say I want to crop off 10px on the left and 10px on the right; I'd do xrandr --output DP-5 --fb 1900x1200 --transform 1,0,-10,0,1,0,0,0,1. But apart from the "specified screen 1900x1200 not large enough for output DP-5" error, I also get "BadValue (integer parameter out of range for operation)" and an exit status of 1. I'm on Arch Linux by the way, latest Xorg and xrandr and everything, and using an NVIDIA graphics card with proprietary drivers.
    – Thomas
    Commented Oct 25, 2019 at 7:43
  • Run xrandr with one setting at a time and find out which setting it's choking on. Example: xrandr --output DP-5 --fb 1900x1200 xrandr --output DP-5 --transform 1,0,-10,0,1,0,0,0,1
    – Dan
    Commented Oct 26, 2019 at 11:09
  • Apparently it's the -10; if I put 10 it is accepted (but shifts to the left while I want to shift to the right, and I get panning at the edges). Additionally, if I add --fb 1900x1200 then the "not large enough for output" error appears.
    – Thomas
    Commented Oct 26, 2019 at 14:36
  • If you can run 1920x1200 as a native resolution on your monitor, you shouldn't have overscan issues. Try changing resolution to 1920x1080 (standard HD) and use my xrandr line below: ```` xrandr --output HDMI-2 --fb 1920x1080 --panning 1960x1100 --transform 1.075,0,-60,0,1.08,-40,0,0, ````
    – Dan
    Commented Oct 26, 2019 at 20:50
  • Here, have a bounty for actually trying it out for yourself instead of pointing to other answers, even though it didn't work for me.
    – Thomas
    Commented Oct 30, 2019 at 7:06
3

This solution can “crop” and position without transformations. It can even leave multiple cropped areas on multiple real monitors. The mouse will not be caged to the “crop” area(s).¹

This command line should answer the question. For more explanation read on:

xrandr --setmonitor my-monitor-0 2880/2000x1900/1500+0+20 eDP-1

The following figures show an example X11 screen in different states. Note that an X11 screen is always one rectangle. Some parts of an X11 screen might not be visible. That happens whenever no real monitor is configured to reflect those parts of the X11 screen.

4 real monitors are used to show this X11 screen. They are positioned 2×2. The figures suggest where those real monitors are exactly, as the window manager (i3 in this case) puts a desktop/workspace on each of them. This also explains the black border in the top right. That particular monitor has a resolution slightly below the others. The window manager put a workspace on that monitor, which has its position snug to the other monitors, leaving an “off-screen” area on the X11 screen where i3 does not paint anything. Non-tiling window managers often allow you to move windows half outside of the monitor(s), so that area might actually contain something (and have that visible on a screenshot).

          
          Figure 1: X11 screen with 4 real monitors configured 2×2

Figure 2 was created by launching xrandr --setmonitor my-monitor-0 520/5x480/4+1400+600 DVI-0. --setmonitor together with --delmonitor, --listactivemonitors and --listmonitors are not mentioned (yet) in the man page on my system, but xrandr --help (version 1.5.0 running on an X11 server with RandR 1.6) shows them.

Here we create a virtual monitor named my-monitor-0. The point is that the window manager (or any other X11 client/app) will see it while iterating through all X11 monitors, composed of virtual and regular monitors (e.g. to determine where to create workspaces on the X11 screen). DVI-0 is the --output name of the real monitor on the top left where we are doing this trick on. While DVI-0 now forms part of the virtual monitor my-monitor-0, the point here is something else though: DVI-0 will be de-listed from the regular X11 monitor list, so no desktop/workspace will be created here by window managers!

The string 520/5x480/4+1400+600 dictates the resolution, position and the pixel density of the virtual monitor. 520x480 is the width and height in pixels, +1400+600 is the offset in pixels from the left and from the top, respectively, and /5 & /4 should be the size in millimeters (width and hight). (The millimeter size is used to calculate the pixel density of that virtual screen; apps can request these numbers and possibly adapt their widget sizes etc.—In my example here they are totally wrong. Measure with a ruler on your real monitor to get numbers for your final setup.)

Note that the real DVI-0 monitor is still showing the same position of the X11 screen and will not be reconfigured by this command. It will only be taken off the X11 monitor list.

          
          Figure 2: top left (real) monitor content replaced with a virtual monitor with smaller dimensions

For figure 3 I executed xrandr --setmonitor my-monitor-1 300/30x200/20+50+30 none to create an additional virtual mointor (“crop area”) in the top left. The command is similar to before. Here I picked a location and dimension that is not yet covered by any other X11 monitor, but that it is part of the area covered by the real DVI-0 monitor. The name of the virtual monitor is new and the list of real monitors in use by this virtual one is empty (none). Reusing DVI-0 would destroy any other virtual monitors containing it.

          
          Figure 3: additional virtual monitor added on empty area covered by top left real monitor

Note that the mouse is confined to the real monitors (limited by the X11 screen) as long as they form one continuous area. If one real monitor is even only 1 pixel apart from all others, the mouse is allowed to go anywhere on the bigger X11 screen rectangle.

For similar questions and similar, often shorter, answers refer to the list in this answer.


¹ X11 can restrict the mouse with pointer barriers, but that needs additional X11 API calls with other software.
Images made with xwd -root | convert xwd:- screen.jpg

1

How to emulate a 1440p ultrawide monitor in a 4K TV [Ubuntu 23.04]

Greg question was how to crop the monitor using xrandr to work around an obstruction on his display. I used that to test if a ultrawide 1440p monitor would be a good fit to me:

Exemplo

#!/bin/sh
xrandr --output HDMI-A-0 --mode 3840x2160 --panning 3840x2160
sleep 1
xrandr --output HDMI-A-0 --mode 3840x2160 --panning 3840x2160
sleep 1
xrandr --output HDMI-A-0 --mode 3840x2160 --fb 3440x1440 --transform 1,0,-200,0,1,-360,0,0,1

Replace the HDMI-A-0 by the actual name of your output.

You can check the name running xrandr --listmonitors on a terminal.

I tested this in a Ubuntu 23.04, but I had to switch to Xorg. In the login screen, click in the gear in the lower right corner of the screen and choose Ubuntu on Xorg.

How to calculate the resolution

    real resolution: 3840x2160 
emulated resolution: 3440x1440

 3840 - 3440 = 400px which means a border of 200px on each side
 2160 - 1440 = 720px which means a border of 360px on top and bottom
                                       
Notice the -200 and -360 in the example script. 
0

After reading Greg S.'s questions carefully, I noticed:

I've found this:

$ xrandr --output eDP-1 --transform 1,0,0,0,1,-30,0,0,1

does move the output down just right so that the top isn't cut off. Unfortunately now the whole desktop framebuffer extends below the visible screen. I could add a scale factor to that transform but I would rather just resize the desktop so that the bottom of the desktop lands at the bottom of the monitor.

My answer doesn't quite address this issue.

Greg, I can only think of two ways to do what you want.

  • Use the scale transform to shrink the Y axes to squeeze the desktop onto the displayable area. However you mentioned you don't want to do this.

  • Other option is to place a desktop widget along the top edge that takes up the 20-30 pixels of unusable space (probably easiest on KDE).

Changing the --fb doesn't change the desktop size, it just limits the displayed image to the --fb size. Setting a new mode doesn't help, since it will start at the top of the screen which is blocked by your bezel.

If it were me, I'd either take a dremel tool to the top bezel or live with a compressed desktop:

xrandr --output eDP-1 --fb 2880x1920 --panning 2880x1950 --transform 1,0,0,0,1.02,-30,0,0,1 

If the command errors out, try without the --fb parameter.

0

After reading and testing all of these answers (and from anothers questions), I found a tricky way to achieve what you were looking for... that it is the same that I needed. I have a laptop with 200px of the left side totally lost (I think something hit the screen phisicaly). Screen is 1366x768. I needed to make a 1166x768 screen, with 200px of horizontal offset to the right. I did this script to run at startup:

#!/bin/bash
# This works for my laptop!
xrandr --output LVDS --mode 1366x768 --panning 1366x768 && sleep 5
xrandr --output LVDS --mode 1366x768 --panning 1166x768 --transform 1,0,-200,0,1,0,0,0,1

It's important to run both commands with a delay of some seconds (you can try with less time). I think the first command set the panning like the monitor resolution. To the naked eye, it does nothing. The second one makes a smaller screen and move it 200px to the right.

  • If I run xrandr --output LVDS --mode 1366x768 --transform 1,0,-200,0,1,0,0,0,1 (without panning), screen moves 200px to right, but, even mouse doesn't go beyond display limitations, desktop does. I maximize a window and min-max-close buttons are lost: invisibles and unreachables.

  • If I run the second command without the first one, it doesn't work, it shows me an error. The only way to achieve it is by running both commands, one after the other.

For your need, you have to play with --mode, --panning and --transform values, but I think this would be right for you:

#!/bin/bash
# This *may* works for you.
xrandr --output LVDS --mode 2880x1920 --panning 2880x1920 && sleep 5
xrandr --output LVDS --mode 2880x1920 --panning 2880x1900 --transform 1,0,0,0,1,-20,0,0,1

Hope this helps you or someone else.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .