Skip to content

Instantly share code, notes, and snippets.

@kumar-rajeswaran
Forked from debloper/xrandr.sh
Created October 13, 2023 10:00
Show Gist options
  • Select an option

  • Save kumar-rajeswaran/ab5a10a8056287d1afa6315fa5108b26 to your computer and use it in GitHub Desktop.

Select an option

Save kumar-rajeswaran/ab5a10a8056287d1afa6315fa5108b26 to your computer and use it in GitHub Desktop.

Revisions

  1. @debloper debloper revised this gist May 10, 2021. 1 changed file with 25 additions and 0 deletions.
    25 changes: 25 additions & 0 deletions xrandr.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,30 @@
    #!/bin/bash

    # Copyright (c) 2021 Soumya Deb <[email protected]>
    #
    # Permission is hereby granted, free of charge, to any person obtaining a copy
    # of this software and associated documentation files (the "Software"), to deal
    # in the Software without restriction, including without limitation the rights
    # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    # copies of the Software, and to permit persons to whom the Software is
    # furnished to do so, subject to the following conditions:
    #
    # The above copyright notice and this permission notice shall be included in
    # all copies or substantial portions of the Software.
    #
    # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    # SOFTWARE.
    #
    # ---
    # Q: WHY IS THERE A COPYRIGHT NOTICE ON THIS SCRIPT?
    # A: It had to be added on (a very reasonable) user request.
    # https://gist.github.com/chirag64/7853413#gistcomment-3736041

    # First we need to get the modeline string for xrandr
    # Luckily, the tool `gtf` will help you calculate it.
    # e.g. `gtf <hRes> <vRes> <refreshRate>`:
  2. @debloper debloper revised this gist Jun 2, 2019. 1 changed file with 11 additions and 9 deletions.
    20 changes: 11 additions & 9 deletions xrandr.sh
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,7 @@

    # First we need to get the modeline string for xrandr
    # Luckily, the tool `gtf` will help you calculate it.
    # All you have to do is to pass the resolution & the-
    # refresh-rate as the command parameters:
    # e.g. `gtf <hRes> <vRes> <refreshRate>`:
    gtf 1920 1080 60

    # In this case, the horizontal resolution is 1920px the
    @@ -14,14 +13,13 @@ gtf 1920 1080 60
    # e.g. "1920x1080_60.00" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync
    # Copy this entire string (except for the starting "Modeline")

    # Now, use `xrandr` to make the system recognize a new
    # display mode. Pass the copied string as the parameter
    # to the --newmode option:
    # Now, use `xrandr` to add a new display mode. Pass the
    # copied string as the parameter to the --newmode option:
    xrandr --newmode "1920x1080_60.00" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync

    # Well, the string within the quotes is the nick/alias
    # of the display mode - you can as well pass something
    # as "MyAwesomeHDResolution". But, careful! :-|
    # as "MyAwesomeHDResolution". But, why though!?!

    # Then all you have to do is to add the new mode to the
    # display you want to apply, like this:
    @@ -33,8 +31,12 @@ xrandr --addmode VGA1 "1920x1080_60.00"
    # you've set in the previous command (--newmode)

    # It should add the new mode to the display & apply it.
    # Usually unlikely, but if it doesn't apply automatically
    # then force it with this command:
    # If it doesn't apply automatically, force it with:
    xrandr --output VGA1 --mode "1920x1080_60.00"

    # That's it... Enjoy the new awesome high-res display!
    # That's it... Enjoy the new awesome high-res display!

    # NOTE to make the change persistent over reboots:
    # - save the script file (with the necessary changes)
    # - run it at startup (search the web for "How To")
    # Thanks for the feedback!
  3. @debloper debloper created this gist May 26, 2012.
    40 changes: 40 additions & 0 deletions xrandr.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    #!/bin/bash

    # First we need to get the modeline string for xrandr
    # Luckily, the tool `gtf` will help you calculate it.
    # All you have to do is to pass the resolution & the-
    # refresh-rate as the command parameters:
    gtf 1920 1080 60

    # In this case, the horizontal resolution is 1920px the
    # vertical resolution is 1080px & refresh-rate is 60Hz.
    # IMPORTANT: BE SURE THE MONITOR SUPPORTS THE RESOLUTION

    # Typically, it outputs a line starting with "Modeline"
    # e.g. "1920x1080_60.00" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync
    # Copy this entire string (except for the starting "Modeline")

    # Now, use `xrandr` to make the system recognize a new
    # display mode. Pass the copied string as the parameter
    # to the --newmode option:
    xrandr --newmode "1920x1080_60.00" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync

    # Well, the string within the quotes is the nick/alias
    # of the display mode - you can as well pass something
    # as "MyAwesomeHDResolution". But, careful! :-|

    # Then all you have to do is to add the new mode to the
    # display you want to apply, like this:
    xrandr --addmode VGA1 "1920x1080_60.00"

    # VGA1 is the display name, it might differ for you.
    # Run `xrandr` without any parameters to be sure.
    # The last parameter is the mode-alias/name which
    # you've set in the previous command (--newmode)

    # It should add the new mode to the display & apply it.
    # Usually unlikely, but if it doesn't apply automatically
    # then force it with this command:
    xrandr --output VGA1 --mode "1920x1080_60.00"

    # That's it... Enjoy the new awesome high-res display!