# Contribute MacDisplaySettings to PsychContributed folder

**URL:** <https://psychtoolbox.discourse.group/t/contribute-macdisplaysettings-to-psychcontributed-folder/3210>\
**Category:** Tips & Tricks\
**Tags:** osx\
**Created:** [May 6, 2020, 7:00am UTC](https://psychtoolbox.discourse.group/t/contribute-macdisplaysettings-to-psychcontributed-folder/3210 "2020-05-06T07:00:54Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![denis.pelli](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/denis.pelli/32/7_2.png) [@denis.pelli](https://psychtoolbox.discourse.group/u/denis.pelli)\
**Post date:** [May 6, 2020, 7:00am UTC](https://psychtoolbox.discourse.group/t/contribute-macdisplaysettings-to-psychcontributed-folder/3210/1 "2020-05-06T07:00:54Z")

</div>

[https://www.dropbox.com/s/k9ty3xoefizf2fl/MacDisplaySettings.zip?dl=0](https://www.dropbox.com/s/k9ty3xoefizf2fl/MacDisplaySettings.zip?dl=0)  
Dear Mario  
Please add this to the PsychContributed folder. MacDisplaySettings uses AppleScript to peek and poke 7 parameters of the macOS System Preferences:Displays panel, any of which can wreak havoc on attempts to calibrate a display if other users fiddle with them. It solves the problem by saving whatever values are present, imposing the values you need, and when you’re done, allows you to restore whatever was current. It handles Brightness, AutoBrightness, True Tone, Night Shift, and Color Profile.  
It consists of two files: MacDisplaySettings.m and MacDisplaySettings.applescript  
The usual psychtoolbox license is fine.  
Thanks.  
Best  
Denis  
p.s.  
This routine is not intended to ADD features. Rather it is intended to eliminate unwanted effects of macOS features that get in the way of doing vision research on a Mac.  
pps  
This makes AutoBrightness obsolete. MacDisplaySettings is much faster and more reliable and handles many more parameters.

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [May 6, 2020, 6:53pm UTC](https://psychtoolbox.discourse.group/t/contribute-macdisplaysettings-to-psychcontributed-folder/3210/2 "2020-05-06T18:53:35Z")

</div>

Hi Denis,

could you send this as a GitHub pull request, so origin and authorship is better documented in the commit logs, and also so i have less work with it?

I added an extra disclaimer to the PsychContributed folders help text to warn users that any code in that folder has to be considered completely untested and unsupported in case of trouble, and that the code may change or even be removed without warning or regards towards backwards compatibility.

This way i can just pull this function in without any previous testing or review of the code, for which i don’t have time atm.

With that in mind, is it possible for you to change AutoBrightness to become a dumb wrapper around the new function, so it keeps working, but uses MacDisplaySettings() internally? We could also just delete it. A bit user hostile, but given that the normal rules for Quality and stability do not apply for the PsychContributed folder, i can live with that.

Thanks,  
-mario

---

<div class="post-metadata">

**Author:** ![denis.pelli](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/denis.pelli/32/7_2.png) [@denis.pelli](https://psychtoolbox.discourse.group/u/denis.pelli)\
**Post date:** [May 6, 2020, 8:22pm UTC](https://psychtoolbox.discourse.group/t/contribute-macdisplaysettings-to-psychcontributed-folder/3210/3 "2020-05-06T20:22:05Z")

</div>

dear mario  
sure. i’ve used github for my own software, but never done a pull request. i tried to submit it as a pull request last night, but I got stuck and couldn’t figure out whether i was connected to the right repository. i’ll try again tonight.

yes, you’re right, replacing the guts of AutoBrightness with a call to MacDIsplaySettings is a good clean solution. I’ll do that.  
best  
denis

---

<div class="post-metadata">

**Author:** ![dcnieho](https://avatars.discourse-cdn.com/v4/letter/d/779978/32.png) [@dcnieho](https://psychtoolbox.discourse.group/u/dcnieho)\
**Post date:** [May 6, 2020, 9:24pm UTC](https://psychtoolbox.discourse.group/t/contribute-macdisplaysettings-to-psychcontributed-folder/3210/4 "2020-05-06T21:24:27Z")

</div>

Hi Denis,

Make sure you fork the psychtoolbox repository so you have your own copy on your own github. Update that one, adding/changing the files, committing and then pushing it to your online copy of the PTB repository. Then, in the github interface looking at your repository, or at the PTB repository, it should probably note the differences between your copy and the PTB repo you forked, and suggest making a pull request.

Cheers,  
Dee

---

<div class="post-metadata">

**Author:** ![denis.pelli](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/denis.pelli/32/7_2.png) [@denis.pelli](https://psychtoolbox.discourse.group/u/denis.pelli)\
**Post date:** [May 6, 2020, 9:55pm UTC](https://psychtoolbox.discourse.group/t/contribute-macdisplaysettings-to-psychcontributed-folder/3210/5 "2020-05-06T21:55:53Z")

</div>

Dear Dee  
Thanks. I’ve done the first part—I made the changes, committed, and pushed them to my branch of the Psychtoobox-3 repo. But, no, Tower is not prompting me to make a Pull Request. I’m stuck. Here’s a screen shot.  
Any suggestion?  
Best  
Denis

 ![image.jpg](https://global.discourse-cdn.com/free1/uploads/psychtoolbox/original/1X/1e8e4afc060531ec4ab1cead3e5da60335e6b229.jpeg)

---

<div class="post-metadata">

**Author:** ![Ian-Max-Andolina](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/ian-max-andolina/32/4_2.png) [@Ian-Max-Andolina](https://psychtoolbox.discourse.group/u/Ian-Max-Andolina)\
**Post date:** [May 7, 2020, 12:07am UTC](https://psychtoolbox.discourse.group/t/contribute-macdisplaysettings-to-psychcontributed-folder/3210/6 "2020-05-07T00:07:29Z")

</div>

Hi Denis, I normally initiate a pull request from Github itself:

 ![Screenshot 2020-05-07 at 07.54.07_SMALL](https://global.discourse-cdn.com/free1/uploads/psychtoolbox/original/1X/0e192d3d7a8e9ff909b8a6981180c555f0a3e335.png)

I’ve never used Tower, so don’t know if it supports handling pull requests but other GUIs don’t. If it is supposed to, it may need an `upstream` repository added. Adding the `upstream` repo allows you to pull in Mario’s changes locally to keep your fork “fresh” (you’ll notice you are quite a few commits behind Mario’s). At least on the commandline, to add an upstream remote you can use:

```auto
cd Psychtoolbox-3 # cd to your fork's local directory first
git pull # make sure you're up-to-date locally
git remote add upstream https://github.com/kleinerm/Psychtoolbox-3.git
git fetch --all
git merge --ff-only upstream/master

```

As you’ve pushed to your master, then `--ff-only` will fail and you can just remove and merge manually. This is why it is preferable to always make a new branch to make any changes, and keep your master a pure copy of the upstream master.

---

<div class="post-metadata">

**Author:** ![denis.pelli](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/denis.pelli/32/7_2.png) [@denis.pelli](https://psychtoolbox.discourse.group/u/denis.pelli)\
**Post date:** [May 7, 2020, 12:43am UTC](https://psychtoolbox.discourse.group/t/contribute-macdisplaysettings-to-psychcontributed-folder/3210/7 "2020-05-07T00:43:05Z")

</div>

Dear Mario, Dee, and Ian  
thanks for the help. This new version of Tower advertises its support for pull requests, but I can’t get anywhere with that. Instead I went to GitHub, following Dee’s advice, and tried from there. It seems to have worked.

 ![image](https://global.discourse-cdn.com/free1/uploads/psychtoolbox/original/1X/ff4c604aa46d4af8132ab82a555dcaac81bfb8b5.png)  
However, I can well believe i’m several commits behind the master.  
Ian, thanks, but i’m not fluent enough with Git to follow you. What “Command line”? Terminal?  
Thanks all  
Denis

---

<div class="post-metadata">

**Author:** ![Ian-Max-Andolina](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/ian-max-andolina/32/4_2.png) [@Ian-Max-Andolina](https://psychtoolbox.discourse.group/u/Ian-Max-Andolina)\
**Post date:** [May 7, 2020, 1:13am UTC](https://psychtoolbox.discourse.group/t/contribute-macdisplaysettings-to-psychcontributed-folder/3210/8 "2020-05-07T01:13:14Z")

</div>

> Ian, thanks, but i’m not fluent enough with Git to follow you. What “Command line”? Terminal?

Yes, Terminal.app (or iTerm.app etc.) will allow you to work directly with git (you need the Apple command line tools installed, or use homebrew to install git). Most git commands are very straight forward and logical (pull / push / merge etc.)

---

<div class="post-metadata">

**Author:** ![denis.pelli](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/denis.pelli/32/7_2.png) [@denis.pelli](https://psychtoolbox.discourse.group/u/denis.pelli)\
**Post date:** [May 7, 2020, 3:34am UTC](https://psychtoolbox.discourse.group/t/contribute-macdisplaysettings-to-psychcontributed-folder/3210/9 "2020-05-07T03:34:46Z")

</div>

Dear Ian  
ok. I typed your commands into Terminal and they ran without a hitch!

 ![image.jpg](https://global.discourse-cdn.com/free1/uploads/psychtoolbox/original/1X/ffe9c7a35093a36d5721eb84eb33f81176ac4a4b.jpeg)

Now Tower seems to be comparing my folder with the master, which is great, but it says I’m 198 commits AHEAD!  
It doesn’t make sense for me to PUSH now, because Mario has already accepted my pull request for the only change I made. Any other difference I want the master, not my copy.  
I tried pulling, and there’s nothing to pull. Tower now seems happy, but those 198 commits waiting to be pushed worry me.

 ![image.jpg](https://global.discourse-cdn.com/free1/uploads/psychtoolbox/original/1X/808f4bdb2302aba760848db0451063d6ab02950e.jpeg)

How do I erase the differences and make my repository follow the master?  
Thanks!  
Best  
Denis

---

<div class="post-metadata">

**Author:** ![Ian-Max-Andolina](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/ian-max-andolina/32/4_2.png) [@Ian-Max-Andolina](https://psychtoolbox.discourse.group/u/Ian-Max-Andolina)\
**Post date:** [May 7, 2020, 4:31am UTC](https://psychtoolbox.discourse.group/t/contribute-macdisplaysettings-to-psychcontributed-folder/3210/10 "2020-05-07T04:31:24Z")

</div>

It think it is telling your `local` is now 198 commits ahead of your own fork which is `origin/master`, not that you are ahead of `upstream`.

As long as you haven’t pushed back to Github yet (I can’t see you have according to [https://github.com/denispelli/Psychtoolbox-3](https://github.com/denispelli/Psychtoolbox-3), which is saying you are 198 commits behind Mario), you can do a git reset again in terminal:

```auto
git reset --hard origin/master; # force reset back to your origin
git clean -fd; # not strictly necessary unless there are some left over files going back to the older revision.

```

You should get back to your previous state. I imagine Tower has a GUI version of `reset --hard`. Then when you are ready you can try to `merge` again and if you are happy, then you can push to your github `origin/master`.

In my fork of mario’s upstream, I tend to keep my master closely identical to Mario, but I only ever `merge` these changes individually, and when a beta is released, only then do I `push` that state to my fork. This means I can keep on the bleeding edge with the ability to `reset` my way back from danger if something breaks. Most users should stick to SVN, but once you get comfortable with Git (and if you don’t mind how much bigger the git repo is), it can be a really nice way to automate software updates across many lab machines…

---

<div class="post-metadata">

**Author:** ![denis.pelli](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/denis.pelli/32/7_2.png) [@denis.pelli](https://psychtoolbox.discourse.group/u/denis.pelli)\
**Post date:** [May 7, 2020, 11:31am UTC](https://psychtoolbox.discourse.group/t/contribute-macdisplaysettings-to-psychcontributed-folder/3210/11 "2020-05-07T11:31:57Z")

</div>

Dear Ian  
that did the trick. I now can make my Pull Request from within Tower. (I polished MacDisplaySettings.) This is great! Many thanks.  
Denis
