jhford / screenresolution

Command line utility for getting, setting and listing display resolution on Mac OS X 10.6+
Other
357 stars 67 forks source link

Command "set" not working on latest MacBook Pro 16" #32

Open hacfi opened 4 years ago

hacfi commented 4 years ago

On latest MacBook Pro 16" (running Catalina) list works fine but running set with any of the available resolutions doesn't have any effect. Any ideas what the issues could be or how this could be fixed?

shuji-koike commented 3 years ago

same here. MacBook Pro 16" (running Catalina)

$ sudo screenresolution set "3072x1920x32@60"
2021-05-21 22:53:03.531 screenresolution[17665:497304] starting screenresolution argv=screenresolution set 3072x1920x32@60 
2021-05-21 22:53:03.546 screenresolution[17665:497304] Error: mode 3072x1920x32@60.000000 not available on display 0

I forgot how I set to 3072x1920 back when I bought this mac 😩

hacfi commented 3 years ago

For for those you have the same issue: in the meantime you can use the GUI application RDM https://github.com/avibrazil/RDM

voltechs commented 3 years ago

Same, but not on a MacBook. I have an ultrawide Samsung split into two monitors. List shows options correctly, and when I select the current resolution it dumps out the same error as mentioned above.

ryancwalsh commented 1 year ago

This tool looks awesome! https://apple.stackexchange.com/a/450370/53510 led me here. I'll be so excited if we can get this working.

Unfortunately on my 16" MacBook Pro, this happens:

screenresolution list                              
2022-11-10 15:47:23.778 screenresolution[34437:530838] starting screenresolution argv=screenresolution list 
Available Modes on Display 0
  3840x2160x32@60       1280x1024x32@75         1024x768x32@75       
  1024x768x32@60        800x600x32@75           800x600x32@60        
  640x480x32@75         640x480x32@60           1920x1080x32@60      
  1600x1200x32@60       1280x1024x32@60         1920x1080x32@60      
  1920x1080x32@50       1920x1080x32@24         1920x1080x32@25      
  1280x720x32@60        1280x720x32@50          720x576x32@50        
  720x480x32@60         640x480x32@60           3840x2160x32@30      
  2560x1440x32@60       2048x1280x32@60         2048x1080x32@24      
  640x480x32@60         800x600x32@60           1024x576x32@60       
  1280x960x32@60        1344x1008x32@60         1344x756x32@60       
  1440x900x32@60        1680x1050x32@60         1600x900x32@60       
  1920x1200x32@60       2048x1152x32@60         2304x1296x32@60      
  2560x1440x32@60       2560x1600x32@60         3008x1692x32@60      
  3200x1800x32@60       3360x1890x32@60         3360x2100x32@60      
  2880x1800x32@60       2048x1280x32@60         1920x1080x32@30      
  640x480x32@30         800x600x32@30           1024x768x32@30       
  1024x576x32@30        1280x720x32@30          1280x960x32@30       
  1344x1008x32@30       1344x756x32@30          1440x900x32@30       
  1680x1050x32@30       1600x1200x32@30         1600x900x32@30       
  1920x1200x32@30       2048x1152x32@30         2304x1296x32@30      
  2560x1440x32@30       2560x1600x32@30         3008x1692x32@30      
  3200x1800x32@30       3360x1890x32@30         3360x2100x32@30      
  2880x1800x32@30       2048x1280x32@30      %                                                                                                                                                                                                                             ~/ [main*] /usr/local/bin/screenresolution set 3840x2160x32@60               
2022-11-10 15:47:41.724 screenresolution[34451:530952] starting screenresolution argv=/usr/local/bin/screenresolution set 3840x2160x32@60 
2022-11-10 15:47:41.751 screenresolution[34451:530952] Error: mode 3840x2160x32@60.000000 not available on display 0

I have a 42.5" Dell display plugged in via USB-C. I don't need the built-in Mac display to be turned on (although it's fine if it is, as long as it's identical to my main external display).

I wonder if the difference in precision between 60 and 60.000000 matters?

Gerst20051 commented 1 year ago

I also get an error when trying to set the resolution of the built in liquid retina xdr display that supports 120 hz. The command does work to update the resolutions of my external monitors though.

[$]> screenresolution set 1728x1117x32@120

Error: mode 1728x1117x32@120.000000 not available on display 0

That was the default resolution. When I tried setting it to a resolution from the list output it worked for me.

Screen Shot 2022-12-05 at 1 09 34 AM

ryancwalsh commented 1 year ago

Thanks for your comment. Yeah, I'm still not sure what's wrong with mine:

 ~/ screenresolution list
2022-12-05 09:13:19.092 screenresolution[68018:3316963] starting screenresolution argv=screenresolution list 
Available Modes on Display 0
  3840x2160x32@60       1280x1024x32@75         1024x768x32@75       
  1024x768x32@60        800x600x32@75           800x600x32@60        
  640x480x32@75         640x480x32@60           1920x1080x32@60      
  1600x1200x32@60       1280x1024x32@60         1920x1080x32@60      
  1920x1080x32@50       1920x1080x32@24         1920x1080x32@25      
  1280x720x32@60        1280x720x32@50          720x576x32@50        
  720x480x32@60         640x480x32@60           3840x2160x32@30      
  2560x1440x32@60       2048x1280x32@60         2048x1080x32@24      
  640x480x32@60         800x600x32@60           1024x576x32@60       
  1280x960x32@60        1344x1008x32@60         1344x756x32@60       
  1440x900x32@60        1680x1050x32@60         1600x900x32@60       
  1920x1200x32@60       2048x1152x32@60         2304x1296x32@60      
  2560x1440x32@60       2560x1600x32@60         3008x1692x32@60      
  3200x1800x32@60       3360x1890x32@60         3360x2100x32@60      
  2880x1800x32@60       2048x1280x32@60         1920x1080x32@30      
  640x480x32@30         800x600x32@30           1024x768x32@30       
  1024x576x32@30        1280x720x32@30          1280x960x32@30       
  1344x1008x32@30       1344x756x32@30          1440x900x32@30       
  1680x1050x32@30       1600x1200x32@30         1600x900x32@30       
  1920x1200x32@30       2048x1152x32@30         2304x1296x32@30      
  2560x1440x32@30       2560x1600x32@30         3008x1692x32@30      
  3200x1800x32@30       3360x1890x32@30         3360x2100x32@30      
  2880x1800x32@30       2048x1280x32@30      %                                                                                                                                                                                                                     ~/ screenresolution list > ~/Desktop/tmp.txt ;grep -E '^ ' < ~/Desktop/tmp.txt |tr -cd "[:print:]" |tr ' ' '\n' |sort -n |uniq |sed '/^$/d' |pbcopy ;pbpaste
2022-12-05 09:13:43.467 screenresolution[68027:3317124] starting screenresolution argv=screenresolution list 
640x480x32@30
640x480x32@60
640x480x32@75
720x480x32@60
720x576x32@50
800x600x32@30
800x600x32@60
800x600x32@75
1024x576x32@30
1024x576x32@60
1024x768x32@30
1024x768x32@60
1024x768x32@75
1280x1024x32@60
1280x1024x32@75
1280x720x32@30
1280x720x32@50
1280x720x32@60
1280x960x32@30
1280x960x32@60
1344x1008x32@30
1344x1008x32@60
1344x756x32@30
1344x756x32@60
1440x900x32@30
1440x900x32@60
1600x1200x32@30
1600x1200x32@60
1600x900x32@30
1600x900x32@60
1680x1050x32@30
1680x1050x32@60
1920x1080x32@24
1920x1080x32@25
1920x1080x32@30
1920x1080x32@50
1920x1080x32@60
1920x1200x32@30
1920x1200x32@60
2048x1080x32@24
2048x1152x32@30
2048x1152x32@60
2048x1280x32@30
2048x1280x32@60
2304x1296x32@30
2304x1296x32@60
2560x1440x32@30
2560x1440x32@60
2560x1600x32@30
2560x1600x32@60
2880x1800x32@30
2880x1800x32@60
3008x1692x32@30
3008x1692x32@60
3200x1800x32@30
3200x1800x32@60
3360x1890x32@30
3360x1890x32@60
3360x2100x32@30
3360x2100x32@60
3840x2160x32@30
3840x2160x32@60
 ~/ screenresolution get                                                                                                                                     
2022-12-05 09:13:57.641 screenresolution[68042:3317229] starting screenresolution argv=screenresolution get 
2022-12-05 09:13:57.675 screenresolution[68042:3317229] Display 0: 3840x2160x32@60
 ~/ screenresolution set 3840x2160x32@60                                                                                                                          
2022-12-05 09:14:36.500 screenresolution[68049:3317443] starting screenresolution argv=screenresolution set 3840x2160x32@60 
2022-12-05 09:14:36.530 screenresolution[68049:3317443] Error: mode 3840x2160x32@60.000000 not available on display 0
 ~/ screenresolution set 1920x1080x32@30
2022-12-05 09:15:35.669 screenresolution[68059:3317801] starting screenresolution argv=screenresolution set 1920x1080x32@30 
2022-12-05 09:15:35.699 screenresolution[68059:3317801] Error: mode 1920x1080x32@30.000000 not available on display 0
dunhamsteve commented 1 year ago

The issue is the float compare, this works around it, but maybe better to check if the floats are "close enough" to each other?

diff --git a/cg_utils.c b/cg_utils.c
index 4fef025..6f1c4d0 100644
--- a/cg_utils.c
+++ b/cg_utils.c
@@ -68,7 +68,7 @@ unsigned int configureDisplay(CGDirectDisplayID display, struct config *config,
         if (pw == config->w &&
             ph == config->h &&
             pd == config->d &&
-            pr == config->r) {
+            (int)pr == (int)config->r) {
             looking = 0; // Stop looking for more modes!
             newMode = possibleMode;
         }
dunhamsteve commented 1 year ago

Yeah, these are the real numbers coming back from the OS:

Available Modes on Display 1
   640x 480x32@47.952194        1152x 720x32@48.000183  1650x1050x32@49.999741 
   640x 480x32@48.000183        1152x 720x32@49.999741  1650x1050x32@59.940414 
....